安装cni网络插件-非必须

安装cni网络插件


安装cni
# 安装 cni
# 百度云链接:https://pan.baidu.com/s/1-PputObLs5jouXLnuBCI6Q 密码:tzqm
cd /server/software/k8s
wget https://github.com/containernetworking/plugins/releases/download/v0.7.1/cni-plugins-amd64-v0.7.1.tgz
mkdir -pv /opt/cni/bin
tar xf cni-plugins-amd64-v0.7.1.tgz -C /opt/cni/bin
ls -l /opt/cni/bin
cd $HOME


vi /etc/cni/net.d/10-mynet.conf

{
    "cniVersion": "0.7.0",
    "name": "mynet",
    "type": "bridge",
    "bridge": "cni0",
    "isGateway": true,
    "ipMasq": true,
    "ipam": {
        "type": "host-local",
        "subnet": "172.30.0.0/16",
        "routes": [
            { "dst": "0.0.0.0/0" }
        ]
    }
}


cat >/etc/cni/net.d/99-loopback.conf <<EOF
{
    "cniVersion": "0.6.0",
    "name": "lo",
    "type": "loopback"
}
EOF



获取subnet:


etcdctl \
  --endpoints=${ETCD_ENDPOINTS} \
  --ca-file=/etc/kubernetes/cert/ca.pem \
  --cert-file=/etc/flanneld/cert/flanneld.pem \
  --key-file=/etc/flanneld/cert/flanneld-key.pem \
  ls ${FLANNEL_ETCD_PREFIX}/subnets

/kubernetes/network/subnets/172.30.43.0-24
/kubernetes/network/subnets/172.30.49.0-24
/kubernetes/network/subnets/172.30.30.0-24
/kubernetes/network/subnets/172.30.44.0-24


echo 1 > /sys/devices/virtual/net/docker0/bridge/nf_call_iptables

插件必须设置net/bridge/bridge-nf-call-iptables sysctl为1,以确保iptables代理功能正常。

参照地址: k8s这区文档:   https://k8smeetup.github.io/docs/concepts/cluster-administration/network-plugins/

 

posted @ 2018-11-25 09:10  effortsing  阅读(3746)  评论(0编辑  收藏  举报