Kubernetes remote cluster tool to connect k8s
1. Copy the file into the Master of kubectl Node
scp k8s/kubernetes/server/bin/kubectl [email protected]:/root/
2, create admin json file the certificate, the certificate is: k8s administrator certificate
{ "CN": "admin", "hosts": [], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "BeiJing", "ST": "BeiJing", "O": "system:masters", "OU": "System" } ] }
3. Create a certificate according to json file
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes admin-csr.json | cfssljson -bare admin
4, create a script to the next certificate directory to generate the config file
# Set the connection api address kubectl config SEt- Cluster Kubernetes \ --server = HTTPS: //192.168.1.120: 6443 \ --embed-certs = to true \ --certificate-Authority = ca.pem \ --kubeconfig = config # using a certificate provided kubectl credentials Cluster-config-sET ADMIN \ --certificate-Authority = ca.pem \ --embed-certs = to true \ --client-Key = admin- the key.pem \ --client-certificate = ADMIN. PEM \ --kubeconfig = config # generate a configuration file and certificate kubectl config set-context default --cluster = kubernetes --user = cluster-admin --kubeconfig =config kubectl config use-context default --kubeconfig=config
5, execute script
bash kubeconfig.sh
6, see the generated files
ls config
7, config files will be sent to the remote end, sent me here to test Node end
scp config [email protected]:/root/
8, Node end, use kubectl plus remote access configuration files
./kubectl --kubeconfig=./config get node
NAME STATUS ROLES AGE VERSION
192.168.1.110 Ready <none> 43h v1.12.1
192.168.1.111 Ready <none> 43h v1.12.1