kubernetes/minikube

Make the kubelet hostPort feature usable by default

オープン

#3,056 opened on 2018/08/08

 (12 件のコメント) (2 件のリアクション) (0 人の担当者)Go (5,222 件のフォーク)batch import
area/cnihelp wantedkind/featurepriority/backlog

Repository metrics

Stars
 (31,799 個のスター)
PR merge metrics
 (平均マージ 12d 19h) (30d で 43 merged PRs)

説明

Is this a BUG REPORT or FEATURE REQUEST? (choose one): FEATURE REQUEST

Please provide the following details:

Environment: Debian stretch

Minikube version (use minikube version): v0.28.0

  • OS (e.g. from /etc/os-release): Debian GNU/Linux 9 (stretch)
  • VM Driver (e.g. cat ~/.minikube/machines/minikube/config.json | grep DriverName): kvm2
  • ISO version (e.g. cat ~/.minikube/machines/minikube/config.json | grep -i ISO or minikube ssh cat /etc/VERSION):
  • Install tools: v0.28.0
  • Others:

What happened: I'm enabling cni plugins for minikube by using the following command: minikube start --vm-driver kvm2 --network-plugin=cni --extra-config=kubelet.network-plugin=cni --extra-config=kubelet.cni-conf-dir=/etc/cni/net.d --extra-config=kubelet.cni-bin-dir=/opt/cni/bin

I then want to use a pod with a hostPort, to access the pod easily from inside and outside the minikube VM. Unfortunatly, the default cni conf file doesn't enable the "portmap" cni plugin, which enable the hostport feature. So by default, when using cni plugins, a pod can't be accessed through a hostPort, even if it is configured.

What you expected to happen: I expect the hostPort feature to work by default.

Anything else do we need to know:

Since the portmap cni plugin is available in the minikube VM, at /opt/cni/bin, having the hostport feature enabled by default is just a matter of cni configuration file.

I removed the default /etc/cni/net.d/k8s.conf and added the file /etc/cni/net.d/10-k8s-portmap.conflist with the following content:

{
    "cniVersion": "0.3.1",
    "name": "rkt.kubernetes.io",
    "plugins": [
        {
            "type": "bridge",
            "bridge": "mybridge",
            "mtu": 1460,
            "addIf": "true",
            "isGateway": true,
            "ipMasq": true,
            "ipam": {
                "type": "host-local",
                "subnet": "10.1.0.0/16",
                "gateway": "10.1.0.1",
                "routes": [
                    {
                        "dst": "0.0.0.0/0"
                    }
                ]
            }
        },
        {
            "type": "portmap",
            "capabilities": {"portMappings": true},
            "externalSetMarkChain": "KUBE-MARK-MASQ"
        }
    ]
}

After restarting kubelet, a pod with hostPort enabled is accessible through minikube_ip:hostport, as expected.

コントリビューターガイド