Connect to AWS EC2 instance from Windows using PuTTYhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html Execute the following commands in the Master and Slave machines- Switch to the root user (sudo -s or sudo su)
- yum update
- yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
Note: yum-config-manager --enable is to enable/disable extra and optional repos. yum update - yum install -y docker
systemctl enable docker && systemctl start docker yum install -y kubelet kubeadm kubectl systemctl enable kubelet && systemctl start kubelet - Execute the following commands to reload and restart docker:
systemctl daemon-reload systemctl restart docker Execute the following commands in the Master Machine- # kubeadm init
In case, kubernetes cluster configuration located in $HOME/.kube/config then run the following command To start using your cluster, run below commands: # mkdir -p $HOME/.kube # sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config # sudo chown $(id -u):$(id -g) $HOME/.kube/config # export KUBECONFIG=$HOME/.kube/config # cp /etc/kubernetes/admin.conf /usr/share/tomcat/ (In RHEL, Tomcat expects the admin.conf to be present in /usr/share/tomcat where BuildOn App is hosted. In tomcat log if it expects kube.config in a different directory place it correspondigly ). Note |
---|
Add “export KUBECONFIG=$HOME/.kube/config” to ~/.bashrc file in order to export the conf file. If this is not added, the export will be applicable only to the current putty session. For a new session, the Kubernetes API will be unreachable. |
2. In order to communicate on the network, run the following commands # kubectl apply -f https://git.io/weave-kube-1.6 3. To create Kubernetes dashboard, run the following commands - # kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml Note |
---|
Dashboard will run as a Kube service either in the Master or in any one of the Slaves. Run “kubectl get svc –all-namespaces” to identify the PORT number of the dashboard. Access the dashboard through https://IP:PORT. |
4. Create a cluster role and bind all services then allow anonymous user to access Kube API If the below kubectl commands are not executed, you will get an error - 'User "system:serviceaccount:default:default" cannot list pods in the namespace "default"' # kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts # kubectl create rolebinding bob-admin-binding --clusterrole=admin --user=system:anonymous --namespace=default (OR) Use below authentication token (preferred one) # curl -k `(kubectl config view | grep server | cut -f 2- -d ":" | tr -d " ")`/api/v1/namespaces/default/pods/web/log --header "Authorization: Bearer `(kubectl describe secret $(kubectl get secrets | grep default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d '\t')`" Execute the following command in the Slave machines to connect to the Master machine- After kubeadm init, you will obtain a token as shown below -
# kubeadm join --token <token id> <Primary IP>:6443 Execute it in the slave machines. 2. Post execution, go to the Master machine and run “kubectl get nodes”, and verify if the nodes have joined the cluster. 3. Verify if all pods are up and running. #kubectl get pods --all-namespaces You will get an output similar to the one shown below -
|