pulumi-kubernetes
pulumi-kubernetes copied to clipboard
Java: Missing class CustomResource
Hello!
CustomResource class are missing on the Java version as a consequence to not able to create Kubernetes custom ressource like ServiceMonitor.
- Vote on this issue by adding a 👍 reaction
Issue details
Documentation of the missing class: https://www.pulumi.com/registry/packages/kubernetes/api-docs/apiextensions/customresource/ Location where missing class expect to be find: https://github.com/pulumi/pulumi-kubernetes/tree/master/sdk/java/src/main/java/com/pulumi/kubernetes/apiextensions
Affected area/feature
Java pulumi-kubernetes
As someone trying to configure my cluster with Java Pulumi, this seems like a fairly important feature.
Is there a workaround from the Pulumi side? Of course you can execute imperative kubectl apply
to the k8s cluster directly.
Also, any estimate of effort or steps that need to be done? e.g. is it an intended omission since it requires some other significant feature?
A good workaround for this is to use the com.pulumi.kubernetes.yaml.v2.ConfigGroup
resource (new in v4.10), specifically the objs
property since it accepts object literals. The effect is similar to creating a CustomResource
.
See this blog post for more information: https://www.pulumi.com/blog/kubernetes-yaml-v2/#object-literals
Here's an example of how to create a custom resource (in this case, an Issuer
) using the Pulumi Java SDK:
package myproject;
import java.util.Map;
import com.pulumi.Pulumi;
import com.pulumi.kubernetes.core.v1.Namespace;
import com.pulumi.kubernetes.core.v1.NamespaceArgs;
import com.pulumi.kubernetes.yaml.v2.ConfigGroup;
import com.pulumi.kubernetes.yaml.v2.ConfigGroupArgs;
public class App {
public static void main(String[] args) {
Pulumi.run(ctx -> {
var ns = new Namespace("ns", NamespaceArgs.builder().build());
var issuer = new ConfigGroup("example", ConfigGroupArgs.builder()
.objs(Map.ofEntries(
Map.entry("apiVersion", "cert-manager.io/v1"),
Map.entry("kind", "Issuer"),
Map.entry("metadata", Map.ofEntries(
Map.entry("name", "my-issuer"),
Map.entry("namespace", ns.metadata().applyValue(m -> m.name()))
)),
Map.entry("spec", Map.ofEntries(
Map.entry("selfSigned", Map.ofEntries())
))
))
.build());
});
}
}