2021-10-09 14:39:29 +07:00
# Installation Guide for Kubernetes Cluster
### 1. Download kubectl
```shell
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
```
### 2. Validate kubectl
```shell
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(< kubectl.sha256 ) kubectl " | sha256sum --check
```
### 3. Install kubectl
```shell
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
```
##### If none-root access (for local user)
```shell
chmod +x kubectl
mkdir -p ~/.local/bin/kubectl
mv ./kubectl ~/.local/bin/kubectl
# and then add ~/.local/bin/kubectl to $PATH
```
### 4. Verify kubectl installed
```shell
kubectl version --client
```
2021-10-09 14:48:19 +07:00
# Install Helm 3
```shell
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
```
2021-10-09 15:06:35 +07:00
# Setup network
```shell
cat < < EOF | sudo tee / etc / modules-load . d / k8s . conf
br_netfilter
EOF
cat < < EOF | sudo tee / etc / sysctl . d / k8s . conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
```
2021-10-09 15:13:25 +07:00
2021-10-09 15:18:30 +07:00
# Install kubernetes tools
2021-10-09 15:41:48 +07:00
### 1. Install CNI plugins (required for most pod network)
2021-10-09 15:13:25 +07:00
```shell
CNI_VERSION="v0.8.2"
ARCH="amd64"
sudo mkdir -p /opt/cni/bin
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz" | sudo tar -C /opt/cni/bin -xz
```
2021-10-09 15:18:30 +07:00
```shell
DOWNLOAD_DIR=/usr/local/bin
sudo mkdir -p $DOWNLOAD_DIR
```
2021-10-09 15:41:48 +07:00
### 2. Install crictl (required for kubeadm / Kubelet Container Runtime Interface (CRI))
2021-10-09 15:18:30 +07:00
```shell
CRICTL_VERSION="v1.17.0"
ARCH="amd64"
curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" | sudo tar -C $DOWNLOAD_DIR -xz
```
2021-10-09 15:41:48 +07:00
### 3. Install kubeadm, kubelet and add a kubelet systemd service
2021-10-09 15:18:30 +07:00
```shell
RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
ARCH="amd64"
cd $DOWNLOAD_DIR
sudo curl -L --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/${ARCH}/{kubeadm,kubelet}
sudo chmod +x {kubeadm,kubelet}
RELEASE_VERSION="v0.4.0"
curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | sudo tee /etc/systemd/system/kubelet.service
sudo mkdir -p /etc/systemd/system/kubelet.service.d
curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf" | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | sudo tee /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
2021-10-09 15:41:48 +07:00
sudo systemctl enable --now kubelet
```
### 4. Verify installation for kubernetes tools
```shell
kubeadm version
```
#### Install Docker
```shell
sudo swapoff -a
wget https://sh.osa.cubetiqs.com/docker-setup.sh
bash docker-setup.sh
```
#### Install some required tools
```shell
sudo apt-get -y install socat
sudo apt install conntrack
```
### 5. Cluster on Master node
```shell
kubeadm init --apiserver-advertise-address=10.10.0.10 --pod-network-cidr=172.15.0.0/16
2021-10-09 15:18:30 +07:00
```