k8s flanneld网络配置

接着上面的博客继续写

  3台主机

  192.168.1.71

  192.168.1.72

  192.168.1.73

  执行 yum install flannel -y

step1:  

  在192.168.1.71主机执行

  创建一个网络

  etcdctl --endpoints=https://192.168.1.71:2379 --ca-file=/etc/kubernetes/ssl/ca.pem --cert-file=/etc/etcd/ssl/etcd-1-71.pem --key-file=/etc/etcd/ssl/etcd-1-71.key mkdir /k8s/network

  查看

  etcdctl --endpoints=https://192.168.1.71:2379 --ca-file=/etc/kubernetes/ssl/ca.pem --cert-file=/etc/etcd/ssl/etcd-1-71.pem --key-file=/etc/etcd/ssl/etcd-1-71.key ls /k8s

  设置网络地址段

  下面地址非常大 能使用的ip有 四百一十九万四千多

  etcdctl --endpoints=https://192.168.1.71:2379 --ca-file=/etc/kubernetes/ssl/ca.pem --cert-file=/etc/etcd/ssl/etcd-1-71.pem --key-file=/etc/etcd/ssl/etcd-1-71.key set /k8s/network/config '{"Network": "10.64.0.0/10","Backend": {"Type": "vxlan"}}'

  

step2:

  编辑修改flanneld配置文件

  192.168.1.71

  vi /etc/sysconfig/flanneld  

# Flanneld configuration options  

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="https://192.168.1.71:2379,https://192.168.1.72:2379,https://192.168.1.73:2379"

# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/k8s/network"

# Any additional options that you want to pass
FLANNEL_OPTIONS="-etcd-cafile=/etc/kubernetes/ssl/ca.pem -etcd-certfile=/etc/etcd/ssl/etcd-1-71.pem -etcd-keyfile=//etc/etcd/ssl/etcd-1-71.key"

  192.168.1.72

  vi /etc/sysconfig/flanneld  

# Flanneld configuration options  

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="https://192.168.1.71:2379,https://192.168.1.72:2379,https://192.168.1.73:2379"

# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/k8s/network"

# Any additional options that you want to pass
FLANNEL_OPTIONS="-etcd-cafile=/etc/kubernetes/ssl/ca.pem -etcd-certfile=/etc/etcd/ssl/etcd-1-72.pem -etcd-keyfile=/etc/etcd/ssl/etcd-1-72.key"

  192.168.1.73

  vi /etc/sysconfig/flanneld  

# Flanneld configuration options  

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="https://192.168.1.71:2379,https://192.168.1.72:2379,https://192.168.1.73:2379"

# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/k8s/network"

# Any additional options that you want to pass
FLANNEL_OPTIONS="-etcd-cafile=/etc/kubernetes/ssl/ca.pem -etcd-certfile=/etc/etcd/ssl/etcd-1-73.pem -etcd-keyfile=/etc/etcd/ssl/etcd-1-73.key"

step3:

  3台 主机启动 flanneld

  systemctl start flanneld

  设置开机启动

  systemctl enable flanneld

  查看有没有获取到 10.64网段ip地址

  ifconfig

step4:

  三台主机都执行

  安装 docker-ce 获取 flanneld ip地址段

  推荐安装 docker-ce 在实际的使用过程中

  下载镜像源 -> 清华大学镜像源

  curl https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo

  sed -i 's#download.docker.com#mirrors.tuna.tsinghua.edu.cn/docker-ce#g' /etc/yum.repos.d/docker-ce.repo

  yum install -y docker-ce

  创建目录修改docker镜像的保存路径

  mkdir /data/docker -pv

  编辑dockerq启动文件程序

  以下操作3台主机都执行

  vi /usr/lib/systemd/system/docker.service  

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.service
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
EnvironmentFile=-/run/docker_opts.env
EnvironmentFile=-/run/flannel/subnet.env
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
EnvironmentFile=-/run/docker_opts.env
ExecStart=/usr/bin/dockerd \
      --data-root /data/docker \
      $DOCKER_OPT_BIP \
      $DOCKER_OPT_IPMASQ \
      $DOCKER_OPT_MTU
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
[Install]
WantedBy=multi-user.target

  启动docker

  systemctl daemon-reload

  systemctl start docker

  systemctl enable docker

  检查docker是否获取到了flanneld网络地址

  ifconfig

猜你喜欢

转载自www.cnblogs.com/S--S/p/10886782.html