kubernetesskaffoldk3d

Skaffold image can't be pulled using k3d cluster and local registry


I have the following skaffold yaml file:

apiVersion: skaffold/v1
kind: Config
build:
  artifacts:
  - image: k3d-my-registry.localhost:12345/getting-started2
deploy:
  kubectl:
    manifests:
      - target/kubernetes/kubernetes.yml

And the following Deplyment yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    app.quarkus.io/build-timestamp: 2021-12-23 - 20:50:40 +0000
  labels:
    app.kubernetes.io/name: getting-started2
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
  name: getting-started2
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: getting-started2
      app.kubernetes.io/version: 1.0.0-SNAPSHOT
  template:
    metadata:
      annotations:
        app.quarkus.io/build-timestamp: 2021-12-23 - 20:50:40 +0000
      labels:
        app.kubernetes.io/name: getting-started2
        app.kubernetes.io/version: 1.0.0-SNAPSHOT
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          image: k3d-my-registry.localhost:12345/getting-started2
          imagePullPolicy: Always
          name: getting-started2
          ports:
            - containerPort: 8787
              name: http
              protocol: TCP

A local k3d registry and cluster which created as follows:

k3d registry create my-registry.localhost --port 12345
k3d cluster create my-cluster --registry-use k3d-my-registry.localhost:12345 --port 8787:8787@loadbalancer

When I do skaffold dev I get an error saying that the image can't be pulled

 - deployment/getting-started2: container getting-started2 is waiting to start: k3d-my-registry.localhost:12345/getting-started2:84e506a59b832cdf63f54ccc45d9b1ccb61f29f066415fe8f162a0604e2fc625 can't be pulled
    - pod/getting-started2-859f8f44c5-pwbvx: container getting-started2 is waiting to start: k3d-my-registry.localhost:12345/getting-started2:84e506a59b832cdf63f54ccc45d9b1ccb61f29f066415fe8f162a0604e2fc625 can't be pulled
 - deployment/getting-started2 failed. Error: container getting-started2 is waiting to start: k3d-my-registry.localhost:12345/getting-started2:84e506a59b832cdf63f54ccc45d9b1ccb61f29f066415fe8f162a0604e2fc625 can't be pulled.

I had to manually push the generated image by skaffold to the local k3d registry to make skaffold dev at least deploy the application

  docker tag k3d-my-registry.localhost:12345/getting-started2:84e506a59b832cdf63f54ccc45d9b1ccb61f29f066415fe8f162a0604e2fc625 localhost:12345/getting-started2:84e506a59b832cdf63f54ccc45d9b1ccb61f29f066415fe8f162a0604e2fc625
  docker push localhost:12345/getting-started2:84e506a59b832cdf63f54ccc45d9b1ccb61f29f066415fe8f162a0604e2fc625

Does skaffold even support k3d? I don't know what's going on. Any idea/


Solution

  • Skaffold does not support pushing to a registry with a different name outside of the cluster from inside the cluster. There is an issue tracking the feature request.