How to replace image with build results in CRD resource (not deployment but similar)

432 views
Skip to first unread message

Ke Zhu

unread,
Jul 2, 2021, 6:45:42 PM7/2/21
to skaffol...@googlegroups.com

I’m using skaffold v1.27.0 with kustomize 4.2.0

Background: The platform I use provides a CRD to manage deployment instead of the k8s deployment itself, more like:

Kind: Application
spec:
   image: xxx

This is the command I used: skaffold build --dry-run -q | skaffold render --digest-source='tag' --build-artifacts - --offline=true -p noprod | kpt cfg grep “kind=Application"

The expectation would be:

Kind: Application
spec:
   Image: my-awesome-repo/xxx:tag

But the actual result is:

Kind: Application
spec:
   image: xxx

Notice: skaffold build --dry-run -q  works as expected with env variable SKAFFOLD_DEFAULT_REPO=my-awesome-repo where it renders the build artifacts as expected:

{"builds":[{"imageName”:"xxx","tag”:”my-awesome-repo/xxx:7f3eef8"}]}

I thought this could be a kustomize problem where the `newImage` and `newTag` doesn’t work with the above CRD, but I wonder if skaffold community could help 

Ke Z

unread,
Jul 7, 2021, 4:35:16 PM7/7/21
to skaffold-users
I pasted this answer in stackflow by using the ImageTagTransformer https://stackoverflow.com/a/68292689/914967

However, still need help on how to get it to work with skaffold workflow

Brian de Alwis

unread,
Jul 7, 2021, 5:35:12 PM7/7/21
to Ke Z, skaffold-users
Sorry for this late reply.  Skaffold disabled image rewriting for all manifests except for those in an allowlist a while ago as it was causing some issues with CRDs and CRs that weren't expecting some of the changes.  We have an open issue to improve this (#4081).

In the meantime, you can hack the Skaffold source to add your custom resource to the allowlist:


If it's a public custom resource, please submit a PR and we can incorporate the change.

--
You received this message because you are subscribed to the Google Groups "skaffold-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skaffold-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skaffold-users/c94a9999-02f4-4ee9-aa19-c7fc847ca63dn%40googlegroups.com.

Ke Z

unread,
Jul 12, 2021, 10:58:23 AM7/12/21
to skaffold-users
Brian,

Thanks for the reply and pointer of the allowlist! I've included this into my answer.

Reply all
Reply to author
Forward
0 new messages