Step-by-Step Guide: Manually Install Kubernetes 1.9.9 on CentOS 7
This tutorial walks you through the complete process of manually installing a Kubernetes 1.9.9 master‑worker cluster on CentOS 7, covering environment preparation, binary downloads, configuration of etcd and Kubernetes components, creation of systemd services, and verification of the deployment.
This guide explains how to manually install Kubernetes v1.9.9 on a CentOS 7 master‑worker cluster.
Prerequisites
Prepare the environment on both nodes (master: 192.168.29.102, worker: 192.168.29.103): configure local yum repositories, disable the firewall or open required ports, set SELinux appropriately, and ensure you have root privileges.
Download binaries
mkdir /data && cd /data wget https://github.com/coreos/etcd/releases/download/v3.3.9/etcd-v3.3.9-linux-amd64.tar.gz wget https://dl.k8s.io/v1.9.9/kubernetes-server-linux-amd64.tar.gzInstall etcd
tar -zxvf etcd-v3.3.9-linux-amd64.tar.gz && cd etcd-v3.3.9-linux-amd64 mv etcd* /usr/binConfigure etcd
mkdir /etc/etcd cat <<EOF >>/etc/etcd/etcd.conf
ETCD_NAME=ansible-k8s2
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_DATA_DIR="/var/lib/etcd/"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.29.102:2379"
EOFInstall Kubernetes binaries
tar -zxvf kubernetes-server-linux-amd64.tar.gz && cd kubernetes/server/bin/ mv kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet kubectl /usr/binCreate Kubernetes configuration files
mkdir /etc/kubernetes && cd /etc/kubernetes # apiserver cat <<EOF >>apiserver
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.29.102:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=192.168.4.0/24"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"
KUBE_API_ARGS=""
EOF # config cat <<EOF >>config
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.29.102:8080"
EOF # controller-manager cat <<EOF >>controller-manager
KUBE_CONTROLLER_MANAGER_ARGS=""
EOF # scheduler cat <<EOF >>scheduler
KUBE_SCHEDULER_ARGS=""
EOFCreate systemd service units
cat <<EOF >>/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
Documentation=https://github.com/coreos/etcd
After=network.target
[Service]
User=root
Type=notify
EnvironmentFile=-/etc/etcd/etcd.conf
ExecStart=/usr/bin/etcd
Restart=on-failure
RestartSec=10s
LimitNOFILE=40000
[Install]
WantedBy=multi-user.target
EOF cat <<EOF >>/lib/systemd/system/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target etcd.service
Wants=etcd.service
[Service]
User=root
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/apiserver
ExecStart=/usr/bin/kube-apiserver \
$KUBE_LOGTOSTDERR \
$KUBE_LOG_LEVEL \
$KUBE_ETCD_SERVERS \
$KUBE_API_ADDRESS \
$KUBE_API_PORT \
$KUBELET_PORT \
$KUBE_ALLOW_PRIV \
$KUBE_SERVICE_ADDRESSES \
$KUBE_ADMISSION_CONTROL \
$KUBE_API_ARGS
Restart=on-failure
Type=notify
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF cat <<EOF >>/lib/systemd/system/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=etcd.service kube-apiserver.service
Requires=etcd.service kube-apiserver.service
[Service]
User=root
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/controller-manager
ExecStart=/usr/bin/kube-controller-manager \
$KUBE_LOGTOSTDERR \
$KUBE_LOG_LEVEL \
$KUBE_MASTER \
$KUBE_CONTROLLER_MANAGER_ARGS
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF cat <<EOF >>/lib/systemd/system/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/kubernetes/kubernetes
[Service]
User=root
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/scheduler
ExecStart=/usr/bin/kube-scheduler \
$KUBE_LOGTOSTDERR \
$KUBE_MASTER
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOFEnable and start services on master
systemctl daemon-reload for service in etcd.service kube-apiserver.service kube-controller-manager.service kube-scheduler.service; do
systemctl enable $service;
systemctl start $service;
systemctl status $service;
doneWorker node setup
# Download and extract worker binaries wget https://dl.k8s.io/v1.9.9/kubernetes-node-linux-amd64.tar.gz tar -zxvf kubernetes-node-linux-amd64.tar.gz && cd kubernetes/node/bin/ mv kube* /usr/bin # Worker configuration mkdir -p /etc/kubernetes && cd /etc/kubernetes cat <<EOF >>config
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=3"
KUBE_ALLOW_PRIV="--allow-privileged=false"
EOF # kubeconfig for kubelet mkdir /var/lib/kubelet cat <<EOF >>/var/lib/kubelet/kubeconfig
apiVersion: v1
kind: Config
users:
- name: kubelet
clusters:
- name: kubernetes
cluster:
server: http://192.168.29.102:8080
contexts:
- context:
cluster: kubernetes
user: kubelet
name: service-account-context
current-context: service-account-context
EOF # kubelet service file cat <<EOF >>/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/kubelet
ExecStart=/usr/bin/kubelet \
$KUBE_LOGTOSTDERR \
$KUBE_LOG_LEVEL \
$KUBELET_API_SERVER \
$KUBELET_ADDRESS \
$KUBELET_PORT \
$KUBELET_HOSTNAME \
$KUBE_ALLOW_PRIV \
$KUBELET_POD_INFRA_CONTAINER \
$KUBELET_ARGS
Restart=on-failure
KillMode=process
[Install]
WantedBy=multi-user.target
EOF # proxy service file cat <<EOF >>/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
[Service]
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/proxy
ExecStart=/usr/bin/kube-proxy \
$KUBE_LOGTOSTDERR \
$KUBE_LOG_LEVEL \
$KUBE_MASTER \
$KUBE_PROXY_ARGS
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOFInstall Docker on worker
cd /data/ yum -y install container-selinux libcgroup libltdl.so.7 pigz libtool-ltdl rpm -ivh docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm --nodepsEnable and start Docker and Kubernetes services on worker
systemctl daemon-reload for service in docker.service kube-proxy.service kubelet.service; do
systemctl enable $service;
systemctl start $service;
doneVerification
# On master kubectl get nodes # Expected output shows both master and worker as Ready kubectl get csAll core components (controller‑manager, etcd, scheduler) should report Healthy.
Troubleshooting
If
kubectlreports “cannot execute binary file”, re‑extract the binaries and move them again.
For more details, see the original GitHub repository: install_k8s_by_manual .
Ops Development Stories
Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.