Self-built Kubernetes on Alibaba Cloud


  1. A valid Alibaba Cloud account. If you don’t have one already, sign up to the Free Trial to enjoy $300 worth in Alibaba Cloud products.
  2. An ECS instance running Ubuntu 16.04 or RHEL7 or Centos7. You can select your preferred region and configurations; this will not affect the outcome of the server setup.
  3. A sudo password for your server.

Kubernetes Security Group Setup

  1. Log on to the ECS console.
  2. Select a region.
  3. In the left-side navigation pane, select Networks & Security and select Security Group.
  4. Click Create Security Group.
  5. Set the Inbound rules for your pod network as shown below. For my example, is the pod network IP address; you’ll need to replace it with your own.
  1. Alibaba Cloud Container Service and the pod CIDR block cannot overlap with the VPC CIDR block.
  2. The service CIDR block cannot overlap with the VPC CIDR block or pod CIDR block.
  3. The security group rules is enable communication between kubernetes master and cluster.

Connect to Your Alibaba Cloud Server

  1. ECS public IP is enabled.
  2. ECS is up and running.
  3. ECS security group is pointed to pods-security group.
  4. ECS security group Authorization Object matches with ECS instance.

Setup Environment

Install Kubernetes-master and Kubernetes-minion

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
sysctl --system
yum -y update
yum install -y docker
apt-get update 
apt-get install -y
systemctl start docker
systemctl enable docker
systemctl status docker

Install Kubernetes

  1. kubeadm: the command to bootstrap the cluster.
  2. kubelet: the component that runs on all of the machines in your cluster and does things like starting pods and containers.
  3. kubectl: the command line util to talk to your cluster.

Kubernetes Installation on CentOS7/RHEL7

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
yum install -y kubelet kubeadm kubectl

Kubernetes Installation on Ubuntu

apt-get install -y apt-transport-https curl
apt-get install -y
curl -s | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main
apt-get update
apt-get install -y kubelet kubeadm kubectl

Running Kubernetes

systemctl enable kubelet  
systemctl start kubelet
docker info | grep -i cgroup
Cgroup Driver: cgroupfs
systemctl daemon-reload
systemctl restart kubelet
kubeadm reset -f
  1. For flannel to work correctly, — pod-network-cidr= has to be passed to kubeadm init.
  2. For Calico to work correctly, — pod-network-cidr= has to be passed to kubeadm init.

Creating flannel Networks

kubeadm init --service-cidr --kubernetes-version v1.11.0 --pod-network-cidr --apiserver-advertise-address
To start using your cluster, you need to run the following as a regular user:  mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
You can now join any number of machines by running the following on each node
as root:
kubeadm join --token 5m8qxr.46rpadiwt8fcka0v --discovery-token-ca-cert-hash sha256:b05a0b8849a57432247c06200864f5ce99d40ffdcae965293c0026204ef33da4
root@kube-master:kubectl get nodes
kube-master Ready master 2m v1.11.0
kube-minion Ready <none> 47s v1.11.0
kubectl apply -f created created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.extensions/kube-flannel-ds created
systemctl restart kubelet
systemctl status kubelet

Verifying the Installation

root@kube-master: kubectl cluster-info 
Kubernetes master is running at
KubeDNS is running at
root@kube-master:kubectl get services -n kube-system
kube-dns ClusterIP <none> 53/UDP,53/TCP 2m
[root@kube-master ~]kubeadm token create 
I0710 04:08:37.149017 8685 feature_gate.go:230] feature gates: &{map[]}




Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

You should <React/> to this!


We’re partnering with Lumos Labs to bring to you the Streamr Data Challenge

How to Send Text Messages from FileMaker — 360Works Email Plugin Leverages AWS for SMS Sending

How to flatten JSON array in Athena

Writing My First Chia Blockchain Program — Part 3 — Smart Coin

Learning amidst challenges

Managing Windows Server Drives on Alibaba Cloud

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:

More from Medium

Using Instana for Apache HTTPd tracing monitoring and performance management

Istio Integration Project Calico on AWS — AWS Roadmap

Create Kubernetes Controller using Rego and MetaController


Getting started on Prometheus