Endpoint:
•endpoint是k8s集群中的一个资源对象,存储在etcd中,用来记录一个service对应的所有pod的访问。
自动endpoint:
[root@master01 svc]# cat ./* apiVersion: v1 kind: Pod metadata: name: nginx-01 labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 apiVersion: v1 kind: Pod metadata: name: nginx-02 labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 apiVersion: v1 kind: Pod metadata: name: nginx-03 labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 apiVersion: v1 kind: Service metadata: name: nginx-clusterip-svc spec: selector: app: nginx type: ClusterIP ports: - name: http port: 8000 targetPort: 80
[root@master01 svc]# kubectl get endpoints nginx-clusterip-svc -ntest -o yaml apiVersion: v1 kind: Endpoints metadata: annotations: endpoints.kubernetes.io/last-change-trigger-time: "2020-01-16T11:10:26+08:00" creationTimestamp: "2020-01-16T03:10:16Z" name: nginx-clusterip-svc namespace: test resourceVersion: "61585" selfLink: /api/v1/namespaces/test/endpoints/nginx-clusterip-svc uid: 09bad5a7-b858-4438-978b-57b9a8c5a787 subsets: - addresses: - ip: 172.20.0.14 nodeName: 192.168.198.155 targetRef: kind: Pod name: nginx-03 namespace: test resourceVersion: "61576" uid: be10871d-4744-4764-aaa7-70770d307806 - ip: 172.20.1.21 nodeName: 192.168.198.154 targetRef: kind: Pod name: nginx-02 namespace: test resourceVersion: "61582" uid: 62856668-e432-4669-b76b-ab401392e0ec - ip: 172.20.2.26 nodeName: 192.168.198.156 targetRef: kind: Pod name: nginx-01 namespace: test resourceVersion: "61584" uid: b5115eed-3fb5-4101-8645-1023b3cd806e ports: - name: http port: 80 protocol: TCP
手动endpoint:
[root@master01 external]# cat ./* kind: Endpoints apiVersion: v1 metadata: name: mysql-svc subsets: - addresses: - ip: 192.168.198.156 ports: - port: 3306 apiVersion: v1 kind: Pod metadata: name: mysql labels: app: mysql spec: containers: - name: mysql image: mysql:5.6 ports: - containerPort: 3306 env: - name: MYSQL_ROOT_PASSWORD value: '123456' apiVersion: v1 kind: Service metadata: name: mysql-svc spec: ports: - port: 3306
event:
•K8s集群中发生的各种事件
kubectl get event -ntest
kubectl get event -ntest -owide
kubectl get event nginx-01.15ea3f4c73c5c11b -ntest -o yaml
kubectl edit event nginx-01.15ea3f4c73c5c11b -ntest
kubectl delete event nginx-01.15ea3f4c73c5c11b -ntest
kubectl label event nginx-01.15ea3f4d688a650f -ntest testlabe=test
kubectl annotate event nginx-01.15ea3f4d688a650f -ntest testlabe=test