咖啡香

K8S: Install Kubernetes on Bare-Metal

Prepare:

apt-get install -y bridge-utils

// Remove Docker bridge
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0

iptables -t nat -A POSTROUTING ! -d 10.0.0.0/8 -o eth0 -j MASQUERADE
sysctl net.ipv4.ip_forward=1

// Re-start docker with K8S's bridge
docker daemon -H unix:///var/run/docker.sock --bridge=cbr0 --iptables=false --ip-masq=false

Build ~/.kube/config by:

export CLUSTER_NAME=k8s_cluster
export CONTEXT_NAME=k8s_cxt
export CONTEXT_USER=root
export MASTER_IP=ma1demo2:8888

kubectl config set-cluster $CLUSTER_NAME --server=http://$MASTER_IP --insecure-skip-tls-verify=true
kubectl config set-context $CONTEXT_NAME --cluster=$CLUSTER_NAME --user=$CONTEXT_USER
kubectl config use-context $CONTEXT_NAME

Start kubelet on each node:

kubelet --allow-privileged=true --api-servers=http://ma1demo2:8888 --configure-cbr0=true

Start kube-proxy on each node:

kube-proxy --master=http://ma1demo2:8888

Start etcd:

docker run --privileged --net=host -d quay.io/coreos/etcd \
--listen-client-urls http://0.0.0.0:4001 \
--advertise-client-urls http://9.21.58.21:4001

Start kube-apiserver:

kube-apiserver --allow-privileged=true --address=`hostname -i` \
--etcd-servers=http://ma1demo1:4001 \
--service-cluster-ip-range=10.10.10.0/24 --port=8888 

Start kube-controller:

kube-controller-manager --master=http://ma1demo2:8888 --allocate-node-cidrs=true \
--cluster-cidr=10.0.0.0/16

Start kube-scheduler:

kube-scheduler --address=`hostname -i` --master=http://ma1demo2:8888

comments powered by Disqus