kubernetes 网络故障遇见的坑

1.记录一下自己搭建kubernetes 集群遇见的坑。

过程是我学技术以来最大的bug,处处都是坑,稍微写成一点, 就完全起不来, 起不来之后, 还找不到故障点, 郁闷之极。

后续会慢慢分享给大家。

2.kubernetes部署 Flannel网络 

1)写入分配的子网段etcd,供flanneld使用

# etcdctl -endpoint="http://192.168.1.195:2379" set /coreos.com/network/config  '{ "Network": "172.17.0.0/16", "Backend": {"Type": "vxlan"}}'

2)下载二进制包

# wget https://github.com/coreos/flannel/releases/download/v0.9.1/flannel-v0.9.1-linux-amd64.tar.gz

# tar zxvf flannel-v0.9.1-linux-amd64.tar.gz

# mv flanneld mk-docker-opts.sh /usr/bin

3)配置Flannel

vi /etc/sysconfig/flanneld

FLANNEL_OPTIONS="--etcd-endpoints=http://192.168.1.195:2379  --ip-masq=true"

4)systemd管理Flannel

# vi /usr/lib/systemd/system/flanneld.service

[Unit]

Description=Flanneld overlay address etcd agent

After=network.target

After=network-online.target

Wants=network-online.target

Before=docker.service

 

[Service]

Type=notify

EnvironmentFile=/etc/sysconfig/flanneld

ExecStart=/usr/bin/flanneld  $FLANNEL_OPTIONS

ExecStartPost=/usr/bin/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/subnet.env

Restart=on-failure

 

[Install]

WantedBy=multi-user.target

RequiredBy=docker.service

5)配置Docker启动指定子网段

修改成如图:

 [root@node01 ~]# vi  /usr/lib/systemd/system/docker.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=/run/flannel/subnet.env
ExecStart=/usr/bin/dockerd $DOCKER_NETWORK_OPTIONS
#--insecure-reqistry reqistry.jwis.cn
ExecReload=/bin/kill -s HUP $MAINPID

posted @ 2018-08-17 17:54  Mr.zou  阅读(630)  评论(1编辑  收藏  举报