Use Kubekey to quickly deploy Kubernetes
Introduction
Kubekey is an open source Kubernetes Rapid Deployment Tool developed by Qingyun and is the next generation of kubesphere installation tools. With Kubekey you can easily deploy a Kubernetes/Kubespher environment, my experience is simply too simple!
This article focuses on Kubekey for rapid deployment of kubernets single nodes, and multi-node deployment will be covered in the next article.
Download Kubekey
#specified versionCurl –sfl https://get-kk.kubesphere.io |VERSION=v1.2.1 sh#Latest versionCurl –sfl https://get-kk.kubesphere.io | sh |
Start writing deployment profiles
Start by creating a default configuration file with the KK Command
[root@lan1 temp]# kk create config[root@lan1 temp]# lsconfig-sample.yaml[root@lan1 temp]# cat config-sample.yaml |
apiVersion: kubekey.kubesphere.io/v1alpha1kind: Clustermetadata: name: samplespec: hosts: - {name: kk1, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: Qcloud@123} etcd: - node1 master: - node1 worker: - node1 controlPlaneEndpoint: ##Internal loadbalancer for apiservers #internalLoadbalancer: haproxy domain: lb.kubesphere.local address: "" port: 6443 kubernetes: version: v1.19.8 clusterName: cluster.local network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 registry: registryMirrors: [] insecureRegistries: [] addons: [] |
Modify the node-related information for their own actual node information, you can see a I modified my configuration file
apiVersion: kubekey.kubesphere.io/v1alpha1kind: Clustermetadata: name: lanspec: hosts: - {name: kk1, address: 192.168.3.152, internalAddress: 10.0.2.11, user: root, password: 123,port: 111} roleGroups: etcd: - kk1 master: - kk1 worker: - kk1 controlPlaneEndpoint: domain: lb.kubesphere.local address: "" port: 6443 kubernetes: version: v1.19.8 clusterName: cluster.local network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 registry: registryMirrors: [] insecureRegistries: [] |
I deployed Kubernetes for version 1.19.8, and CNI used Kubekey's default calico. NET.
Start the deployment
Set the environment variables before deployment:
export KKZONE=cn |
Because by default KK is binary file to github (KUBECTLKUBELETKUBEADM...) and to dockerhub to download the container image, after setting the above environment variable, uh, the download binary file will go to Qingyun to download the binary file, as well as to Ali's mirror warehouse to download the required images, it is necessary to use domestic materials in network.
Then start deploying:
[root@lan1 tmp]# kk create cluster -f config-sample.yaml -yINFO[11:40:08 EDT] Downloading Installation Files INFO[11:40:08 EDT] Downloading kubeadm ... INFO[11:40:10 EDT] Downloading kubelet ... INFO[11:40:11 EDT] Downloading kubectl ... INFO[11:40:11 EDT] Downloading helm ... INFO[11:40:11 EDT] Downloading kubecni ... INFO[11:40:12 EDT] Downloading etcd ... INFO[11:40:12 EDT] Downloading docker ... INFO[11:40:12 EDT] Downloading crictl ... INFO[11:40:12 EDT] Configuring operating system ... [kk0 192.168.3.152] MSG:net.ipv4.ip_forward = 1net.bridge.bridge-nf-call-arptables = 1...INFO[11:40:24 EDT] Installing Container Runtime ... INFO[11:40:26 EDT] Start to download images on all nodes [kk2] Downloading image: registry.cn-beijing.aliyuncs.com/kubesphereio/pause:3.2[kk0] Downloading image: registry.cn-beijing.aliyuncs.com/kubesphereio/pause:3.2[kk2] Downloading image: registry.cn-beijing.aliyuncs.com/kubesphereio/kube-proxy:v1.19.8[kk0] Downloading image: registry.cn-beijing.aliyuncs.com/kubesphereio/kube-apiserver:v1.19.8...INFO[11:42:41 EDT] Creating etcd service Push /root/repo/git/tmp/kubekey/v1.19.8/amd64/etcd-v3.4.13-linux-amd64.tar.gz to 192.168.3.152:/tmp/kubekey/etcd-v3.4.13-linux-amd64.tar.gz DoneINFO[11:42:45 EDT] Starting etcd cluster ... |
Kubekey will finish installing Dockercontainerd, binary file everything you need, and start deploying Kubernetes with KUBEADM. one-click deployment is almost too comfortable!
All you have to do is wait.
Deployment complete, check pod status
When you see the Pod successfully deployed, take a look at the Pod:
[root@kk1 ~]# kubectl get po -ANAMESPACE NAME READY STATUS RESTARTS AGEkube-system calico-kube-controllers-d75c96f46-dqq4z 1/1 Running 0 37mkube-system calico-node-hkpq9 1/1 Running 0 37mkube-system coredns-867b49865c-qtjrz 1/1 Running 0 37mkube-system coredns-867b49865c-vmsgs 1/1 Running 0 37mkube-system kube-apiserver-kk1 1/1 Running 0 37mkube-system kube-controller-manager-kk1 1/1 Running 0 37mkube-system kube-proxy-x7722 1/1 Running 0 37mkube-system kube-scheduler-kk1 1/1 Running 0 37mkube-system nodelocaldns-8hh5d 1/1 Running 0 37m |
As you can see, all the pods are up and running, and you can happily use the Kubernetes.
- Be careful
- The internalAddressneeds to be filled in with the IP address of the network card, which is used by ETCD, otherwise it will fail to deploy etcd.
- Remember to set the environment variable kkzone = cn, otherwise it might be very slow to download the binary file!

浙公网安备 33010602011771号