Logo ByteGopher
  • English
    中文
Logo Inverted Logo
  • Posts
  • Blog
  • CloudNative
  • Infrastructure
    • TimeSeriesDB
  • Kubernetes
  • Note C
  • Note Go
  • React
  • Tips
  • Nodus
  • Interview
  • Life
  • Linux
Hero Image
K8s 源码阅读 4

Short Names and Categories Like native resources, custom resources might have long resources names. CRs can have short names as well. Again, kubectl learns about short names via discovery information. 1apiVersion: apiextensions.k8s.io/v1beta1 2kind: CustomResourcesDefinition 3metadata: 4 name: ats.cnat.programming-kubernetes.info 5spec: 6 ... 7 shortNames: 8 - at Further, CRs–as any other resources–can be part of categories. The most common use is the all category, as in kubectl get all. Is lists all user-facing resources in a cluster, like pods and services.

January 1, 0001 Read
Hero Image
K8s 源码阅读 6 Solutions for Writing Operators

Following sample-controller Bootstraping Business Logic We are now in the position to implement the business logic of the custom controller. That is, we implement the state transitions between the three phases–form PhasePending to PhaseRuning to PhaseDone–in controller.go. processNextWorkItem() processNextWorkItem() bool will read a single work item off the workquque and attempt to process it, by calling the syncHandler. 1func (c *Controller) processNextWorkItem() bool{ 2 obj, shutdowon := c.workqueue.Get() 3 4 if shutdown{ 5 return false 6 } 7 8 // We wrap this block in a func so we can defer c.

January 1, 0001 Read
Hero Image
K8s 源码阅读7

In this chapter we’ll discuss the operational aspects of controllers and operators, showing you how to package them, walking you through best practices for running controllers in production, and making sure that your extension points don’t break your Kubernetes cluster, security, or performance-wise. Lifecycle Management and Packaging Let’s start with the low-hanging fruit: packaging and delivering your controllers so that a user can install it in a straightforward manner. Packaging: The Challenge While Kubernetes defines resources with manifest, typically written in YAML, a low-level interface to declare the state of resources, these manifest files have shortcoming.

January 1, 0001 Read
Hero Image
Kubenetes Pod

Pod 在Kubernetes中,一切都是资源,你可以通过create/get/describe/delete 来操作这些资源。 在操作一种资源之前,我们需要先对这个资源进行定义,在k8s中常用的是yaml配置文件配置。 1# 00-siample-pod.yaml 2--- 3apiVersion: v1 4kind: Pod 5metadata: 6 name: first-pod 7 labels: 8 app: nginx 9spec: 10 containers: 11 - name: 00-simple-pod-nginx 12 images: nginx:1.17.0 apiVersion:资源的版本,可以理解为你要创建的是 PodV1{}还是PodVn{} kind: 资源的类型 metadata: ​ name: 创建出来的资源的名字 ​ labels:与其他资源粒度或者操作的关联 spec: 资源的参数 通过kubectl apply -f创建资源 1kubectl apply -f 00-simple-pod.yaml 如果需要更新资源,修改yaml后,重新kubectl apply -f xxx.yaml 就可以。 获取Pod状态 1kubectl get pod first-pod 2# get more detail 3kubectl get pod first-pod -o wide 4# get all pods of all-namespace 5kubectl get po -A 获取Pod 详情

January 1, 0001 Read
Hero Image
Kubernetes API Basic

Controller and Operator In this section you’ll learn about controllers and operators in Kubernetes and how they work. The API server has the following core responsibilities: To serve the Kubernetes API. This API is used cluster-internally by the master components, the worker nodes, and you Kubernetes-native apps, as well as externally by clients such as kubectl. To proxy cluster components, such as the Kubernetes dashboard, or stream logs, services ports, or serve kubectl exec sessions.

January 1, 0001 Read
Hero Image
Kubernetes CRD

Kubernetes 1.16 正式GA了CRD。 CRD介绍 声明式编程 在Kubernetes中我们使用了Deployment/DamenSet/tatefulSet来管理应用workdload,使用Service/Ingress来管理应用的 https://zhuanlan.zhihu.com/p/34445114

January 1, 0001 Read
Hero Image
Kubernetes Replication Controller

Replication Controller 1# replica.yaml 2--- 3apiVersion: v1 4kind: ReplicationController 5metadata: 6 name: first-replic 7spec: 8 replicas: 3 9 template: 10 metadata: 11 name: simple-pod 12 labels: 13 app: simple-pod 14 spec: 15 containers: 16 - name: timemachine 17 image: lukelau/rest-docker:0.0.1 18 args: 19 - -server.addr=0.0.0.0:8000 以上配置会保证Pod的数量稳定为3个。当我们删除一个Pod之后,Replication Controller就会创建出一个新的Pod来维持Pod的数量。 RC之所以会发现Pod已经挂掉了,是因为探针(Container probes)的存在。在K8s中, kubelet会通过指定的探针方式去探测容器是否存活。 三种探针方式 三种类型的handler ExecAction: Executes a specified sommand inside the container. The diagnostic is considered successful if the command exits with a status code of 0.

January 1, 0001 Read
Hero Image
Kubernetes Service

Pod是最小的单元, 往往我们在运行一个应用的时候,对Pod有一些额外的要求,例如高可用或者多实例,这就意味着如果你只记住一个Pod的IP,那么很多时候时有问题的。 例如高可用,可能会因为Pod的重建而改变,这样你记住的那个IP就失效了。一个很自然的想法就是固定IP。 为什么要使用service 因为K8s里面的Pod是可以被调度的,并且重建的,所以没有固定的IP Pod的数量可能不只一个,当有多个Pod实例的时候负载均衡的需求。 1# service.yaml 2--- 3apiVersion: v1 4kind: Service 5metadata: 6 name: first-service 7spec: 8 type: NodePort 9 selector: 10 app: nginx 11 ports: 12 - protocol: TCP 13 port: 5580 14 targetPort: 80 15 nodePort: 32280 selector 过滤携带label app=nginx的pod targetPort: pod 提供服务的端口 service代理Pod的内部端口为5580: 内部访问,固定IP:Port service代理Pod的外部端口为32280, 通过k8s集群的IP,可以进行 外部可访问 1# create service 2kubectl apply -f service.yaml 3# get service status 4kubectl get service first-service 外部访问service 上面这个配置之所以可以在外部访问,是因为制定了Service的Type为NodePort, 在K8s中如果不指定这个Type的话,service时只能在K8s集群内部访问的,集群外部是访问不了的。

January 1, 0001 Read
Hero Image
Linux Network Command

nc Netcat(or nc) is a command-line utility that reads and write data across network connections, using the TCP or UDP protocols. It is one of the most powerful tools in the network and system administrators arsenal, and it as considered as a Swiss army knife of networking tools. Netcat is cross-platform, and it’s available for Linux, macOS, Windows , and BSD. You can use Netcat to debug and monitor network connections, scan for open ports, transfer data, as a proxy and more.

January 1, 0001 Read
Hero Image
Linux socket

Internet domain socket Unix domain socket You can forward the unix domain socket with the -R option of the ssh command. 1ssh -R remote_socket:local_socket https://github.com/nikhilroxtomar/Multiple-Client-Server-Program-in-C-using-fork

January 1, 0001 Read
Hero Image
Make

The marker - means ignore the err of this line command @ only prints the result of command.

January 1, 0001 Read
Hero Image
Multi-Cluster Kubernetes

What is Multi-Clusters Multi-cluster Kubernetes is a kubernetes deployments method that consists of to or more clusters. This deployment method is highly flexible. You can have clusters on the same physical host or different hosts in the same data center. You can also create a multi-cloud environment with clusters living in different clouds and even in different countries. cluster network connections: https://submariner.io/getting-started/ https://isovalent.com/data/multi-cluster-ebook.pdf Multi clusters server deployment: https://github.com/karmada-io/karmada https://github.com/clusternet/clusternet Submariner Submariner allows pods to directly communicate between Kubernetes clusters

January 1, 0001 Read
  • ««
  • «
  • 18
  • 19
  • 20
  • 21
  • 22
  • »
  • »»
Navigation
  • About
  • Skills
  • Recent Posts
  • My Story
Contact me:
  • renqiqiang@outlook.com

Stay up to date with email notification

By entering your email address, you agree to receive the newsletter of this website.

Toha Theme Logo Toha
© 2020-2022 Copyright.
Powered by Hugo Logo