zoukankan      html  css  js  c++  java
  • Kubernetes网络配置

    #flannel
    #所有node都安装
    #下载https://github.com/coreos/flannel/releases
    #解压并把flanneld和mk-codker-opts.sh复制到/usr/bin
    #配置服务
    cp mk-docker-opts.sh flanneld /usr/bin/
    cat << EOF > /usr/lib/systemd/system/flanneld.service
    [Unit]
    Description=flanneld overlay address etcd agent
    After=network.target
    Before=docker.service

    [Service]
    Type=notify
    EnvironmentFile=/etc/sysconfig/flannel
    ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} $FLANNEL_OPTIONS

    [Install]
    RequiredBy=docker.service
    WantedBy=multi-user.target
    EOF
    #创建文件,192.168.1.1:2379替换为etcd所在的IP与端口
    cat << EOF > /etc/sysconfig/flannel
    FLANNEL_ETCD="http://192.168.1.1:2379"
    FLANNEL_ETCD_KEY="/coreos.com/network"
    EOF
    #ETCD上操作,设置网络段
    etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'
    #启动flannel
    systemctl start flanneld
    systemctl enable flanneld
    #设置docker网络
    mk-docker-opts.sh -i
    source /run/flannel/subnet.env
    ifconfig docker0 ${FLANNEL_SUBNET}
    #设置docker网络文件
    mk-docker-opts.sh -d /etc/docker/docker_opts.env -c
    #/usr/lib/systemd/system/docker.service增加
    EnvironmentFile=/etc/docker/docker_opts.env
    #docker应用flannel网络设置
    systemctl daemon-reload
    systemctl stop docker
    #验证
    ip addr
    #etcd验证
    etcdctl ls /coreos.com/network/subnets
    #ping验证,通过etcd查看到的网段,IP替换为节点获取到的ip
    ping 10.1.50.1
    ping 10.1.46.1
    #docker禁止了转发,导致创建的pod无法跨主机互通
    iptables -P FORWARD ACCEPT

  • 相关阅读:
    Codeforces Round #384 (Div. 2)
    Codeforces Round #383 (Div. 2)
    bzoj-4514(网络流)
    bzoj-4518 4518: [Sdoi2016]征途(斜率优化dp)
    bzoj-1096 1096: [ZJOI2007]仓库建设(斜率优化dp)
    hdu-5988 Coding Contest(费用流)
    hdu-5992 Finding Hotels(kd-tree)
    用链表实现杭电1276士兵队列训练问题
    循环链表
    图书管理系统
  • 原文地址:https://www.cnblogs.com/cainiaoit/p/8580755.html
Copyright © 2011-2022 走看看