Search code examples
dockerdocker-imagepulumi

Pulumi - how to pull a docker image from a private registry?


I've declared a Kubernetes deployment which has two containers. One is built locally, another needs to be pulled from a private registry.

const appImage = new docker.Image("ledgerImage", {
    imageName: 'us.gcr.io/qwil-build/ledger',
    build: "../../",
});

const ledgerDeployment = new k8s.extensions.v1beta1.Deployment("ledger", {
  spec: {
    template: {
      metadata: {
        labels: {name: "ledger"},
        name: "ledger",
      },
      spec: {
        containers: [
          {
            name: "api",
            image: appImage.imageName,
          },
          {
            name: "ssl-proxy",
            image: "us.gcr.io/qwil-build/monolith-ssl-proxy:latest",
          }
        ],

      }
    }
  }
});

When I run pulumi up it hangs - this is happening because of a complaint that You don't have the needed permissions to perform this operation, and you may have invalid credentials. I see this complain when I run kubectl describe <name of pod>. However, when I run docker pull us.gcr.io/qwil-build/monolith-ssl-proxy:latest it executes just fine. I've re-reun gcloud auth configure-docker and it hasn't helped.

I found https://github.com/pulumi/pulumi-cloud/issues/112 but it seems that docker.Image requires a build arg which suggests to me it's meant for local images, not remote images.

How can I pull an image from a private registry?

EDIT:

Turns out I have a local dockerfile for building the SSL proxy I need. I've declared a new Image with

const sslImage = new docker.Image("sslImage", {
  imageName: 'us.gcr.io/qwil-build/ledger-ssl-proxy',
  build: {
    context: "../../",
    dockerfile: "../../Dockerfile.proxy"
  }
});

And updated the image reference in the Deployment correctly. However, I'm still getting authentication problems.


Solution

  • Turns out running pulumi destroy --yes && pulumi up --skip-preview --yes is what I needed. I guess I was in some weird inconsistent state but this is fixed now.