Creating arbitrary resources #4013
-
In my operator, I somehow decided to first build a collection of all the resources that need to be created or updated, then create all of them in one fellow swoop. I'm using a loop like this: for (HasMetadata resource : resources) {
kubernetesClient.resource(resource).inNamespace(namespace).createOrReplace();
} This works great for types supported directly by the client, but I'm having trouble with a custom resources (see the other discussion). My question is: how should I do this properly given a Collection? Or shouldn't I be doing this, instead using the client to immediately create the resource when I know I'd like to have it? Collecting the list beforehand allows me to do some post processing of all resources, and having type-specific code to create resources seems odd to me. The cheatsheet always shows creating resources like this: I'm not in favor of this duplication of type information, in a way that is not visible to Java (there is no immediate relationship between Pod and client.pods() on the language level). Is there a reason there doesn't seem to be a generic interface? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It is mostly support in 5.11 or later - with the exception of a couple of bugs. Those have been addressed in 6.0, so you should be able to do this however you like - with a for loop, with
Or with the basic server side apply support
|
Beta Was this translation helpful? Give feedback.
It is mostly support in 5.11 or later - with the exception of a couple of bugs.
Those have been addressed in 6.0, so you should be able to do this however you like - with a for loop, with
Or with the basic server side apply support