Error: server gave HTTP response to HTTPS client

Hello,

Trying to align image registries between my linux-k3s and windows-minikube deployment files, I found how to setup a registry with the same name, so I can use the same deployment files no matter which cluster I use.

From the container as I pulled images, I had this error.

So even if you set your registry and host files to match K3S cluster, minikube cluster will still try to fetch on https.

Failed to pull image "k3d-mycluster-registry:5000/automation-machine:latest": failed to pull and unpack image "k3d-mycluster-registry:5000/automation-machine:latest": failed to resolve reference "k3d-mycluster-registry:5000/automation-machine:latest": failed to do request: Head "https://k3d-mycluster-registry:5000/v2/automation-machine/manifests/latest": http: server gave HTTP response to HTTPS client

I wanted to share the solution, it took me hours to figure this out

create a file and put this in

server = "http://k3d-mycluster-registry:5000"

[host.”http://k3d-mycluster-registry:5000″]

capabilities = [“pull”, “resolve”] skip_verify = true

then from windows prompt

minikube ssh -- "sudo mkdir -p /etc/containerd/certs.d/k3d-mycluster-registry:5000 && sudo mv /tmp/hosts.toml /etc/containerd/certs.d/k3d-mycluster-registry:5000/hosts.toml && sudo systemctl restart containerd"

minikube ssh -- "cat /etc/containerd/certs.d/k3d-mycluster-registry:5000/hosts.toml"

create and adapt registry-service.yaml with PC ip, then apply

apiVersion: v1
kind: Endpoints
metadata:
  name: k3d-mycluster-registry
subsets:
  - addresses:
      - ip: 192.168.1.182
    ports:
      - port: 5000
---
apiVersion: v1
kind: Service
metadata:
  name: k3d-mycluster-registry
spec:
  ports:
    - port: 5000
      targetPort: 5000

update your local hosts file

127.0.0.1    k3d-mycluster-registry

update minikube internal host file

minikube ssh -- "cat /etc/hosts"
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.49.2    minikube
192.168.65.254  host.minikube.internal
192.168.49.2    control-plane.minikube.internal
minikube ssh -- "echo '192.168.65.254 k3d-mycluster-registry' | sudo tee -a /etc/hosts"

create and use your local registry

docker run -d -p 5000:5000 --name k3d-mycluster-registry --restart=always -v registry-data:/var/lib/registry registry:2
cmd.exe /c minikube start --driver=docker --container-runtime=containerd --insecure-registry=k3d-mycluster-registry:5000

then minikube is able to use the same deployment files that I sue on k3s

let me know if I forgot something or if you have an easier solution :slight_smile:

Bye

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป