1、登录服务器
2、创建 ~/.kube文件夹
3、cd ~/.kube
4、下载或创建k8s集群的config文件:wget config文件连接
apiVersion: v1
kind: Config
clusters:
- cluster:
api-version: v1
insecure-skip-tls-verify: true
server: "https://172.172.241.170:8080/r/projects/1a9/kubernetes:6443"
name: "k8s-platform"
contexts:
- context:
cluster: "k8s-platform"
user: "k8s-platform"
name: "k8s-platform"
current-context: "k8s-platform"
users:
- name: "k8s-platform"
user:
token: "QmFzaWMgTWpJeE9UWXhRVUV3UVRrMk5UWTJRekUyTkVNNlNscDZNV1JyUzNrek0wTk1kVVo2VEZGR1dXdFJlbXRJVEZWR01rMUJNM0ZsVmswNWIzQm1XQT09"
5、下载kubectl二进制文件:wget 文件地址
或:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl
6、授权
chmod 777 kubectl //这时使用要:./kubectl get pod -A
7、设置环境变量:把kubectl拷贝到环境变量中去
sudo mv ./kubectl /usr/local/bin/kubectl
这时在任意位置都可以使用:kubectl get pod -A