Setup Kubernetes on Ubuntu 16.04

Summary

This setup is supposedly to install the kubernetes on ubuntu machine with version 16.04 (64bit). I did this in the cloud and have worked perfectly.

$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https
$ sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ sudo echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update -y
$ sudo apt install docker.io
$ sudo apt-get install -y kubelet kubeadm kubernetes-cni
$ cat /proc/swaps
$ swapoff
$ kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=<private IP>
$ sudo useradd kube -G sudo -m
$ sudo passwd kube
$ sudo su - kube
$ sudo cp /etc/kubernetes/admin.conf $HOME/
$ sudo chown $(id -u):$(id -g) $HOME/admin.conf
$ export KUBECONFIG=$HOME/admin.conf
$ echo "export KUBECONFIG=$HOME/admin.conf" | tee -a ~/.bashrc

Check pods status, wait until all running

$ kubectl get pods --all-namespaces
$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml

# or

$ kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
$ kubectl taint nodes --all node-role.kubernetes.io/master-

Install kubernetes dashboard

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

Create user dashboard

create-user.yml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system

create-role.yml

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system
$ kubectl create -f create-user.yml
$ kubectl create -f create-role.yml
$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print }')

References :

Setup puppet master & puppet agent on Ubuntu 16.04

Overview

– puppet-master (ubuntu 16.04)
– db1 (ubuntu 16.04)

Setup puppet master

On master server, do the following steps:
Add puppet host in /etc/hosts

$ vim /etc/hosts
ip-private puppet-master

Install puppet master:

$ wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
$ sudo dpkg -i puppetlabs-release-pc1-xenial.deb
$ sudo apt-get update -y
$ sudo apt-get install puppetserver -y

Change memory allocation:

open /etc/default/puppetserver, change the JAVA_ARGS to:

JAVA_ARGS="-Xms512m -Xmx512m"

Set puppet master hostname:

open/etc/puppetlabs/puppet/puppet.conf, and add the following lines at the bottom of the file:

....
[main]
certname = puppet-master
server = puppet-master
environment = production

Open port 8140:

$ sudo ufw allow 8140

Start the service, and enable to run on boot:

$ sudo systemctl start puppetserver
$ sudo systemctl enable puppetserver

Setup puppet agent

Add puppet-master host in /etc/hosts

$ vim /etc/hosts
ip-private puppet-master

Install puppet agent

$ wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
$ sudo dpkg -i puppetlabs-release-pc1-xenial.deb
$ sudo apt-get update
$ sudo apt-get install puppet-agent
$ sudo systemctl start puppet-agent
$ sudo systemctl enable puppet-agent

Add configuration for puppet agent:

$ vim /etc/puppetlabs/puppet/puppet.conf
[main]
certname = db1
server = puppet-master
environment = production

Start the service, and enableĀ  to run on boot:

$ sudo systemctl start puppet
$ sudo systemctl enable puppet

Sign the puppet agent certificate on puppet master

$ sudo /opt/puppetlabs/bin/puppet cert list
"db1" (SHA256) 7C:28:E8:AF:09:23:55:19:AF:C1:EE:C3:66:F2:02:73:AD:7F:53:17:28:CE:B0:26:AE:C7:6C:67:16:05:6F:2E

Sign the incoming certificate from specific hostname (db1):

$ sudo /opt/puppetlabs/bin/puppet cert sign db1

or if you prefer to sign all certificates at once, use this command:

$ sudo /opt/puppetlabs/bin/puppet cert sign --all

Test the connection:

$ sudo /opt/puppetlabs/bin/puppet agent --test