Skip to content

slemvs/kubernetes-install

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

kubernetes-install

Install and Deploy Kubernetes on Ubuntu 18.04 LTS

  1. Install Docker on all nodes:
sudo apt install docker.io
  1. Check docker install:
docker --version
  1. Enable Docker on all nodes:
sudo systemctl enable docker
  1. Add the Kubernetes signing key on all nodes:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
  1. Add Kubernetes Repository on all nodes:
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
  1. Install Kubeadm:
sudo apt install kubeadm
  1. Check Kubeadm installation:
kubeadm version
  1. Disable swap memory on all nodes:
sudo swapoff -a

and eliminate any occurrence of swap in /etc/fstab using

sudo nano /etc/fstab
  1. Initialize Kubernetes on the master node:
sudo kubeadm init
  1. Run the following:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
  1. On the remaining nodes run the command starts with:
kubeadm join 192.168.100.6:6443 --token ...

You can find the full command in the results of step 9

  1. Create pod network through the master node:
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
  1. Check the cluster works correctly:
kubectl get nodes

on master node

Configure local kubectl to access newly created cluster

Generate admin.key and admin.csr using openssl

openssl genrsa -out admin.key 2048
openssl req -new -key admin.key -out admin.csr -subj "/O=system:masters/CN=kubernetes-admin"

Now create CSR in kubernetes using above openssl admin.csr

cat <<EOF | kubectl create -f -
apiVersion: certificates.k8s.io/v1beta1
kind: CertificateSigningRequest
metadata:
  name: admin_csr
spec:
  groups:
  - system:authenticated
  request: $(cat admin.csr | base64 | tr -d '\n')
  usages:
  - digital signature
  - key encipherment
  - client auth
EOF

Now approve the CSR generated using

kubectl certificate approve admin_csr

Now extract the admin.crt from approved CSR

kubectl get csr admin_csr -o jsonpath='{.status.certificate}' | base64 -d > admin.crt

Now change the current user and context to use the new admin key and certificates

kubectl config set-credentials kubernetes-admin --client-certificate=/home/centos/certs/admin.crt  --client-key=/home/centos/certs/admin.key
kubectl config set-context kubernetes-admin@kubernetes --cluster=kubernetes --user=kubernetes-admin

About

Install and Deploy Kubernetes on Ubuntu 18.04 LTS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published