Search code examples
amazon-web-servicesdockerkubernetesbitnamikubeadm

How to add insecure Docker registry certificate to kubeadm config


I'm quite new to Kubernetes, and I managed to get an Angular app deployed locally using minikube. But now I'm working on a Bitnami Kubernetes Sandbox EC2 instance, and I've run into issues pulling from my docker registry on another EC2 instance.

Whenever I attempt to apply the deployment, the pods log the following error

Failed to pull image "registry-url.net:5000/app": no available registry endpoint:
failed to do request: Head https://registry-url.net/v2/app/manifests/latest:
x509: certificate signed by unknown authority

The docker registry certificate is signed by a CA (Comodo RSA), but I had to add the registry's .crt and .key files to /etc/docker/certs.d/registry-url.net:5000/ for my local copy of minikube and docker.

However, the Bitnami instance doesn't have an /etc/docker/ directory and there is no daemon.json file to add insecure registry exceptions, and I'm not sure where the cert files are meant to be located for kubeadm.

So is there a similar location to place .crt and .key files for kubeadm, or is there a command I can run to add my docker registry to a list of exceptions?

Or better yet, is there a way to get Kubernetes/docker to recognize the CA of the registry's SSL certs?

Thanks

Edit: I've included my deployment and secret files below:

app-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
        - name: app
          image: registry-url.net:5000/app
          ports:
            - containerPort: 80
          env:
            ...

      imagePullSecrets:
        - name: registry-pull-secret

registry-secret.yaml

apiVersion: v1
kind: Secret
metadata:
  name: registry-pull-secret
data:
 .dockerconfigjson: <base-64 JSON>
type: kubernetes.io/dockerconfigjson


Solution

  • So I ended up solving my issue by manually installing docker via the following commands:

    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    sudo apt-get install docker-ce docker-ce-cli containerd.io
    

    Then I had to create the directory structure /etc/docker/certs.d/registry-url:5000/ and copy the registry's .crt and .key files into the directory.

    However, this still didn't work; but after stopping the EC2 instance and starting it again, it appears to pull from the remote registry with no issues.

    When I initially ran service kubelet restart the changes didn't seem to take effect, but restarting did the trick. I'm not sure if there's a bettre way of fixing my issue, but this was the only solution that worked for me.