K8S: Install Kubernetes on Bare-Metal

2016-01-18 Klaus Ma 更多博文 » 博客 » GitHub »

原文链接 http://www.k8s.tips/tech/2016/01/18/k8s_install_1/
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。


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