Cloud Native 17 min read

How to Install Kubernetes in China Without a VPN – Step‑by‑Step Guide

This guide walks you through installing a Kubernetes (K8S) cluster on CentOS 7.3 in China, covering environment preparation, downloading required packages and images via local mirrors, configuring Docker and the network, initializing the master node with kubeadm, joining worker nodes, and optionally deploying the dashboard and flannel network plugin.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Install Kubernetes in China Without a VPN – Step‑by‑Step Guide

Installation Environment

We use kubeadm for installation, following the official tutorial. The target platform is Alibaba Cloud VPC (virtual machines also work) with CentOS 7.3, Docker 1.12.6, and Kubernetes 1.6.*.

Host Configuration

Update the system and install Docker 1.12 (the version tested with K8S 1.6.x). Disable Docker updates by adding exclude=docker-engine* to /etc/yum.conf. Configure Docker registry mirrors in /etc/docker/daemon.json and start Docker.

Enable bridge networking required by Flannel by setting net.bridge.bridge-nf-call-iptables=1 and applying it.

Download Software

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 -downloadonly kubelet kubeadm kubectl kubernetes-cni

Package RPMs are then bundled and transferred back to the local network.

Download Images

#!/usr/bin/env bash
images=(
    kube-proxy-amd64:v1.6.2
    kube-controller-manager-amd64:v1.6.2
    kube-apiserver-amd64:v1.6.2
    kube-scheduler-amd64:v1.6.2
    kubernetes-dashboard-amd64:v1.6.0
    k8s-dns-sidecar-amd64:1.14.1
    k8s-dns-kube-dns-amd64:1.14.1
    k8s-dns-dnsmasq-nanny-amd64:1.14.1
    etcd-amd64:3.0.17
    pause-amd64:3.0
)
for imageName in ${images[@]}; do
    docker pull gcr.io/google_containers/$imageName
    docker tag gcr.io/google_containers/$imageName registry.cn-beijing.aliyuncs.com/bbt_k8s/$imageName
    docker push registry.cn-beijing.aliyuncs.com/bbt_k8s/$imageName
done
docker tag quay.io/coreos/flannel:v0.7.0-amd64 registry.cn-beijing.aliyuncs.com/bbt_k8s/flannel:v0.7.0-amd64
docker push registry.cn-beijing.aliyuncs.com/bbt_k8s/flannel:v0.7.0-amd64

The script pushes images to a private Alibaba Cloud registry; replace the registry address with your own if needed.

Install K8S Packages

yum install -y *.rpm
systemctl enable kubelet

Configure /etc/systemd/system/kubelet.service.d/10-kubeadm.conf with appropriate environment variables (e.g., pod network CIDR, DNS settings, and custom pause image).

Initialize Master Node

export KUBE_REPO_PREFIX="registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s"
export KUBE_ETCD_IMAGE="registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s/etcd-amd64:3.0.17"
kubeadm init --kubernetes-version=v1.6.2 --pod-network-cidr=10.96.0.0/12

The command creates certificates, kubeconfig files, and starts the control plane. After initialization, copy /etc/kubernetes/admin.conf to $HOME/.kube/config and set KUBECONFIG accordingly.

Deploy Network Plugin (Flannel)

# kube-flannel-rbac.yml and kube-flannel-ds.yaml are applied as follows:
kubectl create -f kube-flannel-rbac.yml
kubectl create -f kube-flannel-ds.yaml

Flannel uses the 10.96.0.0/12 pod network defined earlier.

Join Worker Nodes

export KUBE_REPO_PREFIX="registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s"
export KUBE_ETCD_IMAGE="registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s/etcd-amd64:3.0.17"
kubeadm join --token 1111.111111111111 *.*.*.*:6443

Use the token printed by kubeadm init to join each node.

Optional: Install kubectl and Dashboard

brew install kubectl

Copy /etc/kubernetes/admin.conf from the master to ~/.kube/config on your local machine, then run kubectl get nodes to verify the cluster.

# Dashboard deployment (kubernetes-dashboard.yaml) and RBAC (dashboard-rbac.yml)
kubectl create -f dashboard-rbac.yml
kubectl create -f kubernetes-dashboard.yaml

Expose the dashboard via a NodePort and access it with http://<NodeIP>:<NodePort>.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerKubernetesChinaInstallationk8sFlannel
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.