k8s记录的一些
1、查看node的标签
kubectl get node --show-labels
Pod绑定标签配置
nodeSelector:
fs-my: ""
fs-my是标签的key
添加label
kubectl label node 192.168.1.205 mem=large
删除label
kubectl label node 192.168.1.205 mem-
2、通过kubectl查看yaml文件内容 -o yaml
kubectl get ingress -n test-id -o yaml
3、pod探针配置
1、就绪探针,pod启动后,探测接口ok后才会分配流量
2、存活探针,pod运行时,探测接口不ok后会重启pod
4、配置grpc映射端口
kubectl edit cm tcp-services -n ingress-nginx
5、客户端报503,但是访问pod和svc是ok
1、查看nginx的日志,请求是已经到nginx并已经转发到upstream
2、查看pod svc的请求都是正常的
3、那这时就去查看ingress的日志
kubectl exec -it new-nginx-ingress-controller-7847f778f6-4584c bash -n ingress-nginx
登陆ingress pod容器内
bash-5.0# pwd
/var/log/nginx
127.0.0.1 - - [18/Aug/2021:10:25:42 +0000] test.biz POST "/upload/v2" 200 28 "-" "Go-http-client/2.0" 1770 0.026 [server-test-16000] [] 100.95.201.38:16000 28 0.024 200 6515f7b5aa64ed68df7220377412e509
这里可以看到请求去到哪个ns哪个svc
6、k8s的资源的删除和备份
1.备份k8s的grpc-nginx-ingress-controller的deployment
kubectl -n ingress-nginx get deploy grpc-nginx-ingress-controller -oyaml > grpc-nginx.yaml
2.删除k8s的grpc-nginx-ingress-controller deployment
kubectl -n ingress-nginx delete deploy grpc-nginx-ingress-controller
3.进行观察
回滚步骤:
1.重新apply grpc-nginx的deployment
kubectl apply -f grpc-nginx.yaml
7、查看job和cronjob信息
kubectl get job -n spc
kubectl get cronjob -n spc