-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How to setup the client to access cluster wide (custom) resources #4800
Comments
Hi @MartijnStraatman , sorry for the delay, I missed this issue. #! /bin/bash
set -x
CRD=$1
CRD_NAME="${2:-default}"
# .XXXXXXX makes it cross-compatible Mac/Linux
TMP_DIR=$(mktemp -d -t $CRD_NAME.XXXXXXX)
cp ${CRD} $TMP_DIR/$CRD_NAME.yaml
mkdir -p $TMP_DIR/src
jbang io.fabric8:java-generator-cli:6.4.1 -u https://raw.githubusercontent.com/clastix/capsule/master/charts/capsule/crds/tenant-crd.yaml --target=$TMP_DIR/src
cat <<EOF >> $TMP_DIR/$CRD_NAME.java
//DEPS io.fabric8:kubernetes-client:6.2.0
//DEPS io.fabric8:generator-annotations:6.2.0
//DEPS io.sundr:builder-annotations:0.90.4
//DEPS org.projectlombok:lombok:1.18.24
//DEPS io.sundr:builder-annotations:0.90.4
//DEPS javax.validation:validation-api:2.0.1.Final
//SOURCES src/**.java
EOF
(
cd $TMP_DIR
jbang export portable --force $TMP_DIR/$CRD_NAME.java
jbang --class-path $TMP_DIR/$CRD_NAME.jar -i
)
rm -rf $TMP_DIR you have access to a shell session where you can reproduce the issue: import io.fabric8.kubernetes.client.*
var client = new KubernetesClientBuilder().build();
client.resources(io.clastix.capsule.v1beta1.Tenant.class).create(new io.clastix.capsule.v1beta1.Tenant()) You get the following StackTrace:
|
kubernetes-client/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JCRObject.java Line 134 in 591d421
Should not always be added only for those CRDs with scope |
Thanks @manusa , yes the bug has been identified, will fix it in a while. |
thx!! |
Thank you for reporting! Don't know how we could have missed it 😅 |
We are building some kind of self-service api for users to create tenants on multi-tenant k8s clusters. This is a clusterscoped resource, hence we stumbled upon it. |
I added a controller to our Kubernetes cluster which operates at the cluster wide level. I want to create object with this client.
So I created java code from the controller's crd's.
When i try to create an object, the client seems to be namespace-scoped by default.
For example:
https://xxxx:xxxx/apis/capsule.clastix.io/v1beta1/namespaces/default/tenants
This returns a 404 because this path does not exist at the api-server.
I expect it to be:
https://xxxx:xxxx/apis/capsule.clastix.io/v1beta1/tenants
How can I instrument the client so it won't use the namespace while creating the url.
I noticed while creating the java classes with the
java-generator-cli-6.4.0.sh
the Tenant class implements theio.fabric8.kubernetes.api.model.Namespaced
interface. If I remove the interface, things work as expected..Thx
The text was updated successfully, but these errors were encountered: