Skip to main content

Kubernetes the Chinese Way

Shenzhen, China

DRAFT - this article is still undergoing some "research"...

When trying to run a Kubernetes cluster in China you quickly realize that 404s will take away the fun from it. This tutorial is based on a Github repository but re-written to cater for CentOS servers.

Prerequisites

Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the device mapper storage driver:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
swapoff -a
setenforce 0

Edit the following file to disable nano /etc/sysconfig/selinux SELinux - SELINUX=disabled.

And for iptables create the following file nano /etc/sysctl.d/k8s.conf with the content below:

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

And apply those changes with the following command sysctl --system.

Installing Docker

Now we can install DockerCE using the Aliyun cloud mirror.

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

Kubernetes Aliyun

Now you can start and enable the Docker service, to have it automatically run in the background when you start your server:

systemctl start docker
systemctl enable docker

Kubernetes Aliyun

Installing Kubernetes

Kubernetes can be installed from the Alibaba Mirror which holds both a Debian/Ubuntu (apt) as well as a RHEL/CentOS (yum) version. For CentOS their currently two versions hosted, el6 and el7, for RHEL6/CentOS6 and REHL7/CentOS7, respectively:

Kubernetes Aliyun

On CentOS 7 we have to install the el7 version by adding the repository nano /etc/yum.repos.d/kubernetes.repo:

[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0

NOTE: The following installation fails when you activate the gpgcheck. Re-running the installation after setting gpgcheck=0 "solved" this. I find this slightly troublesome, but will proceed for now - since this is just a local test server environment.

Kubernetes Aliyun

rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
yum update
yum install -y kubelet kubeadm kubectl

Kubernetes Aliyun

As described above - this install failed du to the active key check. Going back to nano /etc/yum.repos.d/kubernetes.repo and setting gpgcheck=0 solved this for now:

Kubernetes Aliyun