Hello! :wave: I’m trying to automate our db migrat...
# general
m
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
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
Sorry, i thought change detection was from the Terraform Kubernetes provider or something like that.
c
we don’t use TF for k8s.
Our k8s provider is 100%, artisanal, hand-written kubernetes/client-go code. 🙂
m
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
yes.
I can give you the exact line.
m
Thanks!
c
add the missing field there using jsonpath syntax
It should be a 1-line change.
m
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
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
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
I think it is?
m
c
just responded. 🙂
💜 1