Paymahn Moghadasian
Paymahn Moghadasian

Reputation: 10329

Pulumi push docker image to GCR

I'm learning how to use Pulumi and I'm wondering I can correctly configure pulumi to push images to GCR. I have the following in index.ts

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

When I run pulumi preview I see that the image is successfully built:

 2:51PM /Users/paymahn/qwil/ledger/pulumi/infra pulumi ⬆ ⬇ ◼
 ❮❮❮ pulumi preview
Previewing update (qwil/dev):

     Type                                 Name                  Plan       Info
 +   pulumi:pulumi:Stack                  ledger-dev            create     1 message
 +   ├─ docker:image:Image                ledgerImage           create
 +   ├─ gcp:compute:Address               cloud-sql-private-ip  create
 +   ├─ kubernetes:core:Service           ledger                create
 +   ├─ gcp:servicenetworking:Connection  private_vpc           create
 +   ├─ gcp:sql:DatabaseInstance          ledger_db             create
 +   ├─ gcp:sql:SslCert                   clientCert            create
 +   ├─ gcp:sql:User                      master                create
 +   ├─ kubernetes:core:Secret            ledger-db-tls         create
 +   └─ kubernetes:extensions:Deployment  ledger                create     1 warning

Diagnostics:
  pulumi:pulumi:Stack (ledger-dev):

  kubernetes:extensions:Deployment (ledger):
    warning: extensions/v1beta1/Deployment is not supported by Kubernetes 1.16+ clusters. Use apps/v1/Deployment instead.

Resources:
    + 10 to create

Permalink: https://app.pulumi.com/qwil/ledger/dev/previews/3f96f06f-ba49-4f52-91db-2884389a6b62

However, when I visit the permalink I see the following output in the Diff Log view at the very end of the image build step: Successfully pushed to docker. When I visit our private GCR repo I don't see any updates/new pushes of the image.

My questions are:

  1. Does Pulumi push the image when previewing?
  2. When pushing, does pulumi decide on the repository based on the image name?
  3. If yes, why does the output of my preview say the image was pushed to docker?

Upvotes: 1

Views: 516

Answers (1)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35134

To your questions:

  1. During preview, the Image resource will build the image and return the target image name, without pushing. During a normal update, it will do the same, as well as tag and push the image.
  2. Yes.
  3. The output is a bit confusing here, see (1).

Here is an example of a docker image pushed to GCR, worked for me just yesterday: https://github.com/pulumi/examples/pull/519/files#diff-982498c859f8161c992d7246993ab441R48-R53

Upvotes: 2

Related Questions