Kubernetes 1.4 Cluster SetupKubernetes 1.4 Cluster Setup
Distance kubernetes 1.4 has been released for some time, version 1.4 adds many new features, one of the more useful features is the addition to quickly create a cluster of basic needs only two commands will be able to build success; but due to reasons known to all (fuck GFW), resulting in kuadm command does not work, the following records for a moment solutions
First, prepare the environment
3 basic environment for virtual machines, virtual machine information is as follows
192.168.1.107 master
192.168.1.126 node1
192.168.1.217 node2
install docker
docker used here is the 1.12.1 version, install directly from the official tutorial, if slower speed can be switched domestic sources, such as Tsinghua docker source, specifically requested
Google
tee /etc/yum.repos.d/docker.repo
<<-‘EOF'[dockerrepo]name=Docker
Repositorybaseurl=https://yum.dockerproject.org/repo/main/CentOS/7/enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpgEOF
yum install docker-engine -y
systemctl enable dockersystemctl
start dockersystemctl status
docker1.2,
modify the hostname
3 Because virtual machines are copied from a virtual machine basis, in order not to affect the kubectl get nodesquery, you need to change the host name of virtual machines, the following example for the master node, the other nodes correspond to amend
echo “master” > /etc/hostname
# hosts localhost
vim /etc/hosts
127.0.0.1 master::1
192.168.1.107 master
192.168.1.126 node1
192.168.1.217 node2
Second, build a cluster kubernetes
2.1, mounting basic components
According to the official documentation tutorial need to install kubelet, kubeadm, kubectl, kubernetes-cnifour rpm package, but due to the fact GFW reason Google can not download the source rpm, the following is my downloaded to the local through the ladder, rpm download method can help yumdownloader tools specifically requested
socat
yum install -y socat
rpms=(5ce829590fb4d5c860b80e73d4483b8545496a13f68ff3033ba76fa72632a3b6-kubernetes-cni-0.3.0.1-0.07a8a2.x86_64.rpm \
bbad6f8b76467d0a5c40fe0f5a1d92500baef49dedff2944e317936b110524eb-kubeadm-1.5.0-0.alpha.0.1534.gcf7301f.x86_64.rpm \
c37966352c9d394bf2cc1f755938dfb679aa45ac866d3eb1775d9c9b87d5e177-kubelet-1.4.0-0.x86_64.rpm \
fac5b4cd036d76764306bd1df7258394b200be4c11f4e3fdd100bfb25a403ed4-kubectl-1.4.0-0.x86_64.rpm)
for rpmName in ${rpms[@]}; do
wget http://upyun.mritd.me/kubernetes/$rpmName
done
rpm -ivh *.rpm
systemctl enable docker
systemctl enable kubelet
systemctl start docker
systemctl start kubelet
systemctl enable dockersystemctl enable kubeletsystemctl start dockersystemctl start kubeletAt this view kubelet in fact failed to start because of the lack of configuration, the deployment will automatically restart after a successful
Before the official use kubeadm create a cluster also need to turn off selinux, the next version of this issue has been resolved
# selinuxsetenforce 02.3, import the relevant image
kubeadm will pull relevant image, due to GFW will cause eventual failure can not be downloaded, so the best way is to use a ladder pull down, and then go in to load, the following is required load into a mirror
gcr.io/google_containers/kube-proxy-amd64 | v1.4.0 |
gcr.io/google_containers/kube-discovery-amd64 | 1.0 |
gcr.io/google_containers/kubedns-amd64 | 1.7 |
gcr.io/google_containers/kube-scheduler-amd64 | v1.4.0 |
gcr.io/google_containers/kube-controller-manager-amd64 | v1.4.0 |
gcr.io/google_containers/kube-apiserver-amd64 | v1.4.0 |
gcr.io/google_containers/etcd-amd64 | 2.2.5 |
gcr.io/google_containers/kube-dnsmasq-amd64 | 1.3 |
gcr.io/google_containers/exechealthz-amd64 | 1.1 |
gcr.io/google_containers/pause-amd64 | 3.0 |
images=(kube-proxy-amd64:v1.4.0 kube-discovery-amd64:1.0 kubedns-amd64:1.7 kube-scheduler-amd64:v1.4.0 kube-controller-manager-amd64:v1.4.0 kube-apiserver-amd64:v1.4.0 etcd-amd64:2.2.5 kube-dnsmasq-amd64:1.3 exechealthz-amd64:1.1 pause-amd64:3.0 kubernetes-dashboard-amd64:v1.4.0)
for imageName in ${images[@]} ; do
docker pull mritd/$imageName
docker tag mritd/$imageName gcr.io/google_containers/$imageName
docker rmi mritd/$imageName
done
kubeadm init --api-advertise-addresses=192.168.1.107
? ~ kubeadm init --api-advertise-addresses=192.168.1.107
<master/tokens> generated token: "42354d.e1fb733ed0c9a932"
<master/pki> created keys and certificates in "/etc/kubernetes/pki"
<util/kubeconfig> created "/etc/kubernetes/kubelet.conf"
<util/kubeconfig> created "/etc/kubernetes/admin.conf"
<master/apiclient> created API client configuration
<master/apiclient> created API client, waiting for the control plane to become ready
<master/apiclient> all control plane components are healthy after 18.921781 seconds
<master/apiclient> waiting for at least one node to register and become ready
<master/apiclient> first node is ready after 2.014976 seconds
<master/discovery> created essential addon: kube-discovery, waiting for it to become ready
<master/discovery> kube-discovery is ready after 3.505092 seconds
<master/addons> created essential addon: kube-proxy
<master/addons> created essential addon: kube-dns
Kubernetes master initialised successfully!
You can now join any number of machines by running the following on each node:
kubeadm join --token 42354d.e1fb733ed0c9a932 192.168.1.107
kubeadm join --token 42354d.e1fb733ed0c9a932 192.168.1.107
master ? get nodes ? master pod? master kubectl taint nodes --all dedicated
? ~ kubectl get nodes
NAME STATUS AGE
master Ready 1m
node1 Ready 1m
node2 Ready 1m
kubectl apply -f https://git.io/weave-kube
Recent Comments