1、将新的config文件替换到制定的目录下
通常情况下,Kubernetes config 文件的默认位置为:文章来源地址https://www.toymoban.com/news/detail-565437.html
Linux/macOS:~/.kube/config(当前用户的主目录下的 .kube/config 文件)
Windows:%USERPROFILE%\.kube\config(当前用户的主目录下的 .kube\config 文件)
2、列出所有的命名空间
kubens
sunyuhua@sunyuhua-PC:~$ kubens
infra
global
traefik
dev-mgmt
kube-system
kube-public
logging
uat-mgmt
kube-node-lease
3、切换到自己所需要的命名空间
kubens infra
sunyuhua@sunyuhua-PC:~$ kubens global
Context "cci80knavo1j1h24nq7s0@4176145-kci80n8qvo1j1h24nq80g" modified.
Active namespace is "global".
4、查找命名空间下的pod节点
kubectl get pod
sunyuhua@sunyuhua-PC:~$ kubectl get pod
NAME READY STATUS RESTARTS AGE
fastone-help-859b9d4497-h9gcz 1/1 Running 0 5d2h
balance-76cd5568f5-nbb96 1/1 Running 0 5d2h
billing-mgr-6b7cb86bcd-l8ndz 1/1 Running 0 5d2h
gateway-6bcf84d88-vgw4d 1/1 Running 0 5d2h
notification-6889988575-hkzrb 1/1 Running 0 5d2h
cc-ui-794bffb66b-cwdkh 1/1 Running 0 2d23h
global-api-5d75f6498b-m7t4d 1/1 Running 0 5d2h
5、进入pod内部进行操作
kubectl exec -it XXXXX /bin/bash -n infra
sunyuhua@sunyuhua-PC:~$ kubectl exec -it postgres-billing-fbdf45b4d-qn84z /bin/bash -n infra
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
bash-5.1# psql -U sa
psql (13.5)
Type "help" for help.
文章来源:https://www.toymoban.com/news/detail-565437.html
到了这里,关于k8s 更换config文件,并进入pod的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!