ll /etc/kubernetes/ total 24 -rw-r--r--. 1 root root 1028 Sep 1 04:47 apiserver -rw-r--r--. 1 root root 656 Aug 30 03:27 config -rw-r--r--. 1 root root 189 Mar 6 2017 controller-manager -rw-r--r--. 1 root root 768 Aug 31 01:15 kubelet -rw-r--r--. 1 root root 103 Mar 6 2017 proxy -rw-r--r--. 1 root root 111 Mar 6 2017 scheduler
修改apiserver
1 2 3 4 5 6 7 8 9 10 11
# The address on the local server to listen to. KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" # Comma separated list of nodes in the etcd cluster KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379" # Address range to use for services KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # default admission control policies # 去除了ServiceAccount--需要认证 KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" # Add your own! KUBE_API_ARGS=""
修改config
1 2 3 4 5 6 7
KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers KUBE_ALLOW_PRIV="--allow-privileged=false" # How the controller-manager, scheduler, and proxy find the apiserver KUBE_MASTER="--master=http://k8s-master:8080"
修改kubelet
1 2 3 4 5 6 7 8 9
# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) KUBELET_ADDRESS="--address=0.0.0.0" # You may leave this blank to use the actual hostname KUBELET_HOSTNAME="--hostname-override=k8s-master" # location of the api-server KUBELET_API_SERVER="--api-servers=http://k8s-master:8080" # pod infrastructure container # 这个地址是使用的私有的harbor地址(docker images的仓库) KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=192.168.12.200/myproj/pause-amd64:3.0"
1.1.4. 配置etcd
1 2 3
vi /etc/etcd/etcd.conf ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"
vi /etc/sysconfig/flanneld FLANNEL_ETCD="http://k8s-master:2379" FLANNEL_ETCD_KEY="/kube-centos/network" FLANNEL_OPTIONS=""
1.1.6. 重启服务
1 2 3 4 5
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do systemctl restart $SERVICES systemctl enable$SERVICES systemctl status $SERVICES done
ll /etc/kubernetes/ total 12 -rw-r--r--. 1 root root 655 Aug 30 03:41 config -rw-r--r--. 1 root root 769 Aug 30 22:59 kubelet -rw-r--r--. 1 root root 103 Mar 6 2017 proxy
修改config文件如下
1 2 3 4 5 6 7 8
# logging to stderr means we get it in the systemd journal KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers KUBE_ALLOW_PRIV="--allow-privileged=true" # How the controller-manager, scheduler, and proxy find the apiserver KUBE_MASTER="--master=http://k8s-master:8080"
修改kubelet文件如下
1 2 3 4 5 6 7 8 9
# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) KUBELET_ADDRESS="--address=0.0.0.0" # You may leave this blank to use the actual hostname KUBELET_HOSTNAME="--hostname-override=k8s-slave1" # location of the api-server KUBELET_API_SERVER="--api-servers=http://k8s-master:8080" # pod infrastructure container # 这个地址是使用的私有的harbor地址(docker images的仓库) KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=192.168.12.200/myproj/pause-amd64:3.0"
1.2.4. 修改flannel的配置文件
1
vi /etc/sysconfig/flanneld
1 2 3 4 5 6 7 8
# etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment # 必须与master节点配置flannel时的路径一致 FLANNEL_ETCD_PREFIX="/kube-centos/network" # Any additional options that you want to pass #FLANNEL_OPTIONS=""
1.2.5. 重启服务
1 2 3 4 5
for SERVICES in kube-proxy kubelet flanneld docker; do systemctl restart $SERVICES systemctl enable$SERVICES systemctl status $SERVICES done
此时在master节点执行如下命令,验证是否能够查到该节点
1 2 3
$ kubectl get nodes NAME STATUS AGE k8s-node1 Ready 6d