安装

配置 repo:

[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

安装:

yum install -y kubelet kubeadm kubectl kubernetes-cni cri-tools
systemctl enable kubelet --now
kubeadm init --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --kubernetes-version v1.18.0

使用 macvlan:

{
  "plugins": [
    {
      "cniVersion": "0.4.0",
      "name": "macvlannet",
      "type": "macvlan",
      "master": "eth0",
      "mode": "vepa",
      "isGateway": true,
      "ipMasq": false,
      "ipam": {
        "type": "dhcp"
      }
    }
  ]
}

启动 DHCP 客户端:

/opt/cni/bin/dhcp daemon
  • vepa 模式下需要交换机配置 hairpin mode ,否则 host-containercontainer-container 都不通。

  • bridge 模式下不配置 hairpin host-container 不通, container-container 通。

  • bridge 模式下 host 配置 macvlan 子接口, host-container 通, container-container 通。