之前做的实验都是单台服务器上进行,最近做到需要在其它节点部署pod
master部署可以参考之前的文档,node节点上只需要启动两个进程。首先安装软件:yum install etcd kubernetes -y

两台节点ip:
192.168.1.82 master
192.168.1.83 node1

cat /etc/kubernetes/kubelet | egrep -v ‘(^#|^$)’
KUBELET_ADDRESS=”–address=0.0.0.0” #绑定主机ip 0.0.0.0使用全部网络接口
KUBELET_HOSTNAME=”–hostname-override=node1” #设置节点名称
KUBELET_API_SERVER=”–api-servers=http://192.168.1.82:8080” #指定api地址
KUBELET_POD_INFRA_CONTAINER=”–pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest” pod内网络命名空间基础镜像
KUBELET_ARGS=”“

cat /etc/kubernetes/proxy | egrep -v ‘(^#|^$)’
KUBE_PROXY_ARGS=”–master=http://192.168.1.82:8080” # 指定master

systemctl start kubelet
systemctl start kube-proxy

提示:记得关闭防火墙,selinux我的测试中是没有关闭的,好像没有什么影响,master etcd的端口记得开发,
master:
kubectl get node
NAME STATUS AGE
127.0.0.1 Ready 2d
node1 Ready 1h
容器之间的网络还需要安装flannel:
yum install flannel

[root@localhost ~]# cat /etc/sysconfig/flanneld | egrep -v ‘(^#|^$)’
FLANNEL_ETCD_ENDPOINTS=”http://192.168.1.82:2379”
FLANNEL_ETCD_PREFIX=”/atomic.io/network”
flannel使用需要etcdctl,这是之前安装etcd的原因
systemctl stop docker
etcdctl set /atomic.io/network/config “{ “Network”: “10.1.0.0/16” }”
systemctl restart flanneld

### docker-opts.sh -i ##yum安装的方式没有改命令

source /run/flannel/subnet.env
ifconfig docker0 ${FLANNEL_SUBNET}

ifconfig
对比之前的docker0 ip信息,ping master docker0

ping 10.1.53.1
PING 10.1.53.1 (10.1.53.1) 56(84) bytes of data.
64 bytes from 10.1.53.1: icmp_seq=1 ttl=62 time=0.392 ms
64 bytes from 10.1.53.1: icmp_seq=2 ttl=62 time=0.171 ms
64 bytes from 10.1.53.1: icmp_seq=3 ttl=62 time=0.199 ms
64 bytes from 10.1.53.1: icmp_seq=4 ttl=62 time=0.181 ms

Logo

开源、云原生的融合云平台

更多推荐