https://pulumi.com logo
m

most-pager-38056

12/28/2018, 7:25 PM
Hello! 👋 I’m trying to automate our db migrations execution using Pulumi + Kubernetes. So far, i’ve tried to do it using two approaches: 1. Creating a k8s job that runs into completation, but both Pulumi and Kubernetes doesn’t have a resource lifecycle feature, like “delete this job after completion”. 2. By changing the image or name of the job. Since both fields are immutable, Pulumi should recreate the resource, but that’s not the case 😬.
Copy code
Job.batch "api-migration-job-zdq5ov6o" is invalid: spec.template: Invalid value: [job spec]: field is immutable
I’ve tried to look at the
@pulumi/kubernetes
source code, but seems like it’s generated automatically. In this case, how do we fix that? 🤔
c

creamy-potato-29402

12/28/2018, 7:27 PM
that’s a bug.
part of it is generated automatically, but this is a bug in the fields that we check to see if a resource needs to be replaced.
@most-pager-38056 we’ll fix it soon for sure. I’m technically on vacation, usually we try to turn this sort of bug around in a couple hours.
m

most-pager-38056

12/28/2018, 7:30 PM
Sorry, i thought change detection was from the Terraform Kubernetes provider or something like that.
c

creamy-potato-29402

12/28/2018, 7:30 PM
we don’t use TF for k8s.
Our k8s provider is 100%, artisanal, hand-written kubernetes/client-go code. 🙂
m

most-pager-38056

12/28/2018, 7:32 PM
Great to know! Now i understand why it’s so good 🙂 Can you help me to figure out where the change detection source code lives in?
c

creamy-potato-29402

12/28/2018, 7:32 PM
yes.
I can give you the exact line.
m

most-pager-38056

12/28/2018, 7:32 PM
Thanks!
c

creamy-potato-29402

12/28/2018, 7:33 PM
add the missing field there using jsonpath syntax
It should be a 1-line change.
m

most-pager-38056

12/28/2018, 7:34 PM
That’s beatiful. I’m going to create a PR right now 🙂
Looks like not only
name
and
image
fields are immutable, but any
containers[*]
field. Should i add every single field or the whole
spec.template.spec.containers[*]
rule?`
c

creamy-potato-29402

12/28/2018, 8:11 PM
hmm
If every field is immutable, then it seems like the second one should work.
we don’t actually use the wildcard pattern anywhere.
so this is kind of unprecedented. 🙂
that said, we tend to enumerate every field elsewhere…
I forget the precisely how this works in jsonpath.
m

most-pager-38056

12/28/2018, 8:16 PM
Hm, i thought the expression was
[*]
because it’s used here: https://github.com/pulumi/pulumi-kubernetes/blob/master/pkg/provider/diff.go#L87
I’ll search about jsonpath.
c

creamy-potato-29402

12/28/2018, 8:21 PM
I think it is?
m

most-pager-38056

12/28/2018, 8:24 PM
c

creamy-potato-29402

12/28/2018, 8:40 PM
just responded. 🙂
💜 1