欢迎关注我的公众号:

k8s资源之endpoint &event_mysql

 目前刚开始写一个月,一共写了18篇原创文章,文章目录如下:

​istio多集群探秘,部署了50次多集群后我得出的结论​

​istio多集群链路追踪,附实操视频​

​istio防故障利器,你知道几个,istio新手不要读,太难!​

​istio业务权限控制,原来可以这么玩​

​istio实现非侵入压缩,微服务之间如何实现压缩​

​不懂envoyfilter也敢说精通istio系列-http-rbac-不要只会用AuthorizationPolicy配置权限​

​不懂envoyfilter也敢说精通istio系列-02-http-corsFilter-不要只会vs​

​不懂envoyfilter也敢说精通istio系列-03-http-csrf filter-再也不用再代码里写csrf逻辑了​

​不懂envoyfilter也敢说精通istio系列http-jwt_authn-不要只会RequestAuthorization​

​不懂envoyfilter也敢说精通istio系列-05-fault-filter-故障注入不止是vs​

​不懂envoyfilter也敢说精通istio系列-06-http-match-配置路由不只是vs​

​不懂envoyfilter也敢说精通istio系列-07-负载均衡配置不止是dr​

​不懂envoyfilter也敢说精通istio系列-08-连接池和断路器​

​不懂envoyfilter也敢说精通istio系列-09-http-route filter​

​不懂envoyfilter也敢说精通istio系列-network filter-redis proxy​

​不懂envoyfilter也敢说精通istio系列-network filter-HttpConnectionManager​

​不懂envoyfilter也敢说精通istio系列-ratelimit-istio ratelimit完全手册​

 

--------------------------------------------------------------------------------------------------------------------------

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