https://pulumi.com logo
#kubernetes
Title
# kubernetes
s

some-king-80791

08/05/2021, 3:28 PM
Hi. Does anyone know how to change
apiVersion
field for apiextentions.CustomResource? I tried out specifying
aliases
option, but it didn't help..
Before:
Copy code
new kubernetes.apiextensions.CustomResource("test", {
  apiVersion: "<http://cloud.google.com/v1beta1|cloud.google.com/v1beta1>",
  kind: "BackendConfig",
  metadata: {
    name: "backendconfig",
    namespace: "test-namespace",
  },
  spec: {
    timeoutSec: 300,
  },
}, {})
After (changing v1beta1 to v1 with alias option):
Copy code
new kubernetes.apiextensions.CustomResource("test", {
  apiVersion: "<http://cloud.google.com/v1|cloud.google.com/v1>",
  kind: "BackendConfig",
  metadata: {
    name: "backendconfig",
    namespace: "test-namespace",
  },
  spec: {
    timeoutSec: 300,
  },
}, {
  aliases: [{ type: "kubernetes:<http://cloud.google.com/v1beta1:BackendConfig|cloud.google.com/v1beta1:BackendConfig>" }],
})
and I got
Copy code
* the Kubernetes API server reported that "test-namespace/backendconfig" failed to fully initialize or become live: <http://BackendConfig.cloud.google.com|BackendConfig.cloud.google.com> "backendconfig" is invalid: apiVersion: Invalid value: "<http://cloud.google.com/v1|cloud.google.com/v1>": must be <http://cloud.google.com/v1beta1|cloud.google.com/v1beta1>
From Kubernetes API log, looks Pulumi called PATCH API of
v1beta1
, and got rejected. I use pulumi-kubernetes v2.9.1
b

bored-table-20691

08/05/2021, 3:56 PM
Does changing the apiVersion field directly work?
s

some-king-80791

08/05/2021, 4:19 PM
Thanks for the response. Yes. Changing apiVersion field with
kubectl
instead of Pulumi works.
Kubernetes API log told that
kubectl
called PATCH API of
v1
b

bored-table-20691

08/05/2021, 4:32 PM
Sorry, I meant changing the apiVersion here:
Copy code
new kubernetes.apiextensions.CustomResource("test", {
  apiVersion: "<http://cloud.google.com/v1|cloud.google.com/v1>",
s

some-king-80791

08/05/2021, 4:42 PM
@bored-table-20691 You meant without
aliases
option?
If I didn't specify
aliases
option, Pulumi tried to delete the
v1beta
resource and create the
v1
resource.
b

bored-table-20691

08/05/2021, 4:45 PM
That would be my expectation - I don’t think changing resource version is a change you can do “in place” really, though I could be wrong.
What are you trying to do?
s

some-king-80791

08/05/2021, 4:52 PM
I want to bump apiVersion in-place. Kubernetes API supports this, as I succeeded with
kubectl
. Also, Pulumi Kubernetes supports this for some built-in resources. https://github.com/pulumi/pulumi-kubernetes/pull/798
b

bored-table-20691

08/05/2021, 4:58 PM
I see - thanks for clarifying. Unfortunately, I don’t have anything useful to add 🙂
👍 1
w

worried-city-86458

08/05/2021, 10:26 PM
This would be good to know as k8s 1.22 will require lots of these changes iirc
s

some-king-80791

08/05/2021, 11:55 PM
I am wondering why Pulumi Kubernetes calls
v1beta1
API instead of
v1
API even I specify
v1
manifest. Looks apiextentions.CustomResource honors previous API version in the state.
4 Views