[root@cx--0008 ~]# curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.13.5/bin/linux/amd64/kubectl
在~/.kube/目錄下建立config文件linux
[root@cx--0008 ~]# chmod +x ./kubectl [root@cx--0008 ~]# mv ./kubectl /usr/local/bin/kubectl [root@cx--0008 ~]# mkdir ~/.kube/ [root@cx--0008 ~]# vim .kube/config apiVersion: v1 kind: Config clusters: - name: "master138" cluster: server: "https://172.16.2.17/k8s/clusters/c-pqtft" certificate-authority-data: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM3akNDQ\ WRhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFvTVJJd0VBWURWUVFLRXdsMGFHVXQKY\ 21GdVkyZ3hFakFRQmdOVkJBTVRDV05oZEhSc1pTMWpZVEFlRncweE9UQTNNVEl4TkRFek16ZGFGd\ zB5T1RBMwpNRGt4TkRFek16ZGFNQ2d4RWpBUUJnTlZCQW9UQ1hSb1pTMXlZVzVqYURFU01CQUdBM\ VVFQXhNSlkyRjBkR3hsCkxXTmhNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ\ 0tDQVFFQTFLaGU2QnN3bWhKMnVTNXgKNWJmWkRLZGNic0xIRXRhWlhRdjFiSzVUc0ozQjc1RnVUb\ GlzeTAyQ25LbVZZTytuTlY3SlAyS1lOSmRObFFMVQpkZHluN1dKaThOaEsyR1dyTCtQMXVoc3NtV\ XhLVU8xZmdSc04rMDE3TWFOcXk2cTlIV2xsQUpWZ3NHcnZoODIwCmRJakMrakNaRWs1NCtSOC83V\ WZIUldSSXNESXBGdExYSjBFcWJSaUt5cXJVUW9qK1lSaHJ5alpSRStpcjJ1eHAKeU5pUEdXNFpDU\ GtqS2UxUVFwSG1FdmxjTkpMWC9ML0JQN1NIeE1mYWc2eTBtR2EzdWlwczFlMGdBODVWcVNPSApCc\ WF6TEIzSzE3T0ZmT2dMODJTK3c1eFp3cElaSHlDU1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ENFUlRJR\ klDQVRFLS0tLS0K" users: - name: "user-4xdhx" user: token: "kubeconfig-user-4xdhx.c-pqtft:6vrjrpt8sbjpxs2bcq2dnhr4qljwhhfw4htl86pvgq4f9jw4m5rps4" contexts: - name: "master138" context: user: "user-4xdhx" cluster: "master138" - name: "master138-cx--0008" context: user: "user-4xdhx" cluster: "master138-cx--0008" current-context: "master138"
驗證集羣vim
[root@cx--0008 ~]# kubectl cluster-info Kubernetes master is running at https://172.16.2.17/k8s/clusters/c-pqtft KubeDNS is running at https://172.16.2.17/k8s/clusters/c-pqtft/api/v1/namespaces/kube-system/services/kube-dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. [root@cx--0008 ~]# kubectl get pod NAME READY STATUS RESTARTS AGE details-v1-68c7c8666d-sq7c7 2/2 Running 0 17d httpbin-776487d667-ctw9b 2/2 Running 0 13d productpage-v1-54d799c966-5vlz6 2/2 Running 0 17d ratings-v1-8558d4458d-8bpr5 2/2 Running 0 17d reviews-v1-cb8655c75-679w9 2/2 Running 0 17d reviews-v2-7fc9bb6dcf-tjdqk 2/2 Running 0 17d reviews-v3-c995979bc-8vkmg 2/2 Running 0 17d
https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/api