Issue while pulling image from private registry in kubernetes Issue while pulling image from private registry in kubernetes kubernetes kubernetes

Issue while pulling image from private registry in kubernetes


The problem is the hostport is not working properly with CNI (see this issue).

You need to install a portmap plugin and create a .conflist file. All this can depend on how you set up your kubernetes cluster.

I used the following steps:

  • Set the portmap plugin (download via containernetworking/pluginsv0.6.0) in /opt/cni/bin
  • I'm using canal so my network config looks like this:

    {"name": "canal","cniVersion": "0.3.0","plugins": [{        "type": "flannel",        "delegate": {            "type": "calico",            "etcd_endpoints": "https://10.128.0.3:2379",            "etcd_key_file": "/opt/calicoctl/etcd-key",            "etcd_cert_file": "/opt/calicoctl/etcd-cert",            "etcd_ca_cert_file": "/opt/calicoctl/etcd-ca",            "log_level": "info",            "policy": {                "type": "k8s"            },            "kubernetes": {                "kubeconfig": "/root/cdk/kubeconfig"            }        }    },    {        "type": "portmap",        "capabilities": {            "portMappings": true        },        "snat": true    }]}

    make sure the file ends with .conflist. I saved this file in /etc/cni/net.d. More info about this can be found via Container Networking Interface Specification

  • Recreate the proxy pod.


I advise against using local registry with kubernetes!Sure it gives you nice localhost:5000 address in your config files that is the same as when you test with minikube, but it is actually dangerous.

If the cluster dies you will lose ALL your images.

Just use amazon docker registry, it is a safe a proper way to do this.