Ubuntu上手动安装部署Kubernetes详细指南(3)

  修改docker的systemd配置文件。

$ sudo mkdir /lib/systemd/system/docker.service.d $ sudo vim /lib/systemd/system/docker.service.d/flannel.conf [Service] EnvironmentFile=-/run/flannel/docker

  重启docker服务。

$ sudo systemctl daemon-reload $ sudo systemctl restart docker

  查看docker是否有了flannel的网络。

$ sudo ps -ef | grep docker root 11285 1 1 15:14 ? 00:00:01 /usr/bin/dockerd -H fd:// --bip=192.168.4.129/25 --ip-masq=true --mtu=1472 ... 配置kubelet服务 创建kubelet的数据目录 $ sudo mkdir /var/lib/kubelet 创建kubelete配置文件

  kubelet的专用配置文件为/etc/kubernetes/kubelet

$ sudo vim /etc/kubernetes/kubelet KUBELET_ADDRESS="--address=127.0.0.1" KUBELET_HOSTNAME="--hostname-override=192.168.56.161" KUBELET_API_SERVER="--api-servers=http://192.168.56.160:8080" # pod infrastructure container KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.RedHat.com/rhel7/pod-infrastructure:latest" KUBELET_ARGS="--enable-server=true --enable-debugging-handlers=true" 创建systemd文件 $ sudo vim /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 启动kubelet服务 $ sudo systemctl daemon-reload $ sudo systemctl enable kubelet $ sudo systemctl start kubelet 配置kube-proxy服务 创建kube-proxy配置文件

  kube-proxy的专用配置文件为/etc/kubernetes/proxy

$ sudo vim /etc/kubernetes/proxy # kubernetes proxy config # default config should be adequate # Add your own! KUBE_PROXY_ARGS="" 创建systemd文件 $ sudo vim /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 启动kube-proxy服务 $ sudo systemctl daemon-reload $ sudo systemctl enable kube-proxy $ sudo systemctl start kube-proxy 查询node状态 

  执行kubectl get node命令来查看node状态。都为Ready状态时,则说明node节点已经成功连接到master,如果不是该状态,则需要到该节点上,定位下原因。可通过journalctl -u kubelet.service命令来查看kubelet服务的日志。

$ kubectl get node NAME STATUS AGE 192.168.56.160 Ready d 192.168.56.161 Ready d Kubernetes测试  

  测试Kubernetes是否成功安装。

编写yaml文件

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/79524dc22edf9491c5c92273ce830cf0.html