1. ##Setup kubernetes with flannel on Ubuntu Platform##
Hello everyone,
In the following article I will demonstrate how to :
• Deploy Kubernetes with 2 nodes (the master an a minion)
• Setup flannel as the network plugin
• Install and expose the kubernetes-dashboard application
Infrastructure description on GCP
• 2x Cloud VPS-SSD running Ubuntu 16.04 server 64bits
• 1 Master with 1vCPU 4 GB
• 1 Worker with 1 vCPU 4 GB
2. Install Kubernetes
Log as root
Some commands need to be run as root. To log as root simply type.
Install Docker
We have followed the Get Docker for Ubuntu guide. Here is the summary of commands :
Remove previous version of docker
Install docker community edition
3. Install Kubernetes
We are going to use the getting started kubeadm guide. We are going to sum-up the various
command we have to run.
On all nodes
We followed the Ubuntu install part.
On the Master
Before starting you need to know that you will need to pass the –pod-network-cidr flag for the init
command when using flannel (see https://kubernetes.io/docs/admin/kubeadm#kubeadm-
init and https://github.com/kubernetes/kubernetes/issues/36575#issuecomment-264622923)
Save the kubeadm join command that kubeadm init will output at the end. You will need your token
for your node.
Logout as a normal user and start the cluster:-
But you will see these below text when we complete the above process but you can do also type
below command.
Alternatively you can do as root user in your master server.
At this stage the master node should NOT be ready because it is missing a network plugin to start.
We have to install network plugin in nodes.
4. You can run below command in master node:-
Installing a pod network
We are going to install flannel as a pod network in master node:-
Check installation worked:-
You need to setup some RBAC permissions in master node:-
Then wait for some time (time for pods to restart automatically) you should get everything running..
5. Specific to Worker node
Run the join command as root (replace by your own specific values).
Login to master and check node as been added.
You can check that you have a new flannel-ds pod running.
Install Kubernetes Dashboard
https://github.com/kubernetes/dashboard
We are going to install dashboard following the alternative setup because we do not want to go too
deep into the certificate issues in this article. So the dashboard will be exposed over HTTP only..
This should be on master node:-
Check everything is fine and pod status is Running:-
6. Check the pod is running on node and not master
Access the UI from the web
We need to make the service visible to the outside world and not only inside the cluster from other
pods.
Edit kubernetes-dashboard service.
Change type: ClusterIP to type: NodePort and save file.
Then we need to retrieve the port on which dashboard is running, below you can see it is running on
port 30630
To access dashboard simply enter the following url
http://<node-ip>:<nodePort>
(if your pod has been deployed on the master then put the master ip)
7. Grant the necessary rights to the dashboard app
You will; probably encounter the following issue (and many more)
onfigmaps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard"
cannot list configmaps in the namespace "default"
It means kubernetes-dashboard does not have the correct rights to execute commands.
To solve we are going to grant dashboard the cluster-admon role. WARNING This is not suitable for
production environment !!! But this is not the purpose of this introduction article.
Paste the following content and save.
Then apply these changes
Reload your dashboard UI, it should work now.!!!
Thanks.