Travelling Techie

Adventures in VMware

User Tools

Site Tools


Sidebar

Network Virtualization
Compute Virtualization
Storage Virtualization
Cloud
Containers
Operating Systems
Automation
Tools
VMware Classes
Other Classes
Other

Tags

Recent Changes

About The Author

Brandon Neill is a VMware Certified Instructor and Consultant. He specializes in NSX and vRealize Automation. In addition to teaching Official VMware Classes, he provides contract training and consulting services.

install_kubernetes

This is an old revision of the document!


Install Kubernetes

Install kubernetes on CentOS 7

It took me several days to get a working Kubernetes installation on CentOS 7, pulling information from several different sources 1) 2) 3). This “script” documents all the changes I had to make to a stock CentOS 7 install to get Kubernetes up and running.

Ensure docker is installed

#!/bin/bash
# configure hostname (only necessary on AWS) 
# May also need to add appropriate entries to /etc/hosts 
# hostnamectl set-hostname <name>
 
# Set SELinux in permissive mode (effectively disabling it)
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
 
# Configure Kubernetes repo and install packages 
 
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
 
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
 
systemctl enable --now kubelet
 
# set up docker for systemd cgroups ((https://kubernetes.io/docs/setup/production-environment/container-runtimes/))
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF
 
mkdir -p /etc/systemd/system/docker.service.d
 
systemctl daemon-reload
systemctl restart docker
 
# Create /etc/sysctl.d/k8s.conf
cat > /etc/docker/daemon.json <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
 
# Reload Sysctl
sysctl --system
 
# Allow calico to manage tunl and cali interfaces
cat > /etc/NetworkManager/conf.d/calico.conf <<EOF
[keyfile]
unmanaged-devices=interface-name:cali*;interface-name:tunl*
EOF
 
# Open Firewall Ports (179 is for bgp (calico)
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10251/tcp
firewall-cmd --permanent --add-port=10252/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd --permanent --add-port=179/tcp
firewall-cmd --reload
 
# Disable Swap
sed -i '/swap/d' /etc/fstab
swapoff -a

Configure the Kube Master

#!/bin/bash
# Run kubeadm init (the cidr block is necessary for Calico)
# if you want to use a different block, you have to download and edit the calico yaml as well as changing it here.
kubeadm init --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors=SystemVerification,NumCPU
 
# Enable kube access for user
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
 
# Install Calico for networking
curl https://docs.projectcalico.org/v3.11/manifests/calico-etcd.yaml -o calico.yaml
kubectl apply -f calico.yaml

Useful Commands

$ kubeadm token create --print-join-command  // create new join token

Install Kubernetes on Ubuntu

(incomplete) https://www.poftut.com/setup-kubernetes-1-4-ubuntu/

$ sudo apt-get update
$ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ sudo cat <<EOF > /etc/apt/sources.list.d/kubernetes.list 
> deb http://apt.kubernetes.io/ kubernetes-xenial main 
> EOF
$ sudo apt-get update
$ sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni

I also had to disable swap in the /etc/fstab file then reboot.

Single Node Kubernetes

Other installation options

Kubernetes Sandbox from Bitnami

install_kubernetes.1577835538.txt.gz · Last modified: 2019/12/31 18:38 by brandon