-
Notifications
You must be signed in to change notification settings - Fork 0
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
Do you have an example of querying a custom resource? #9
Comments
Hey @justinmchase , Here's how I normally set this up. First, I have a directory in my project which contains my CRD files. For this example I'll create Next I create a shell script #!/bin/sh -eux
# Regenerates the Kubernetes CR client modules.
CodegenSrc="https://raw.githubusercontent.com/cloudydeno/deno-kubernetes_apis/main/generation/run-on-crds.ts"
# Path to import /x/kubernetes_apis from, align this with your own imports.
ApisImportUrl="https://deno.land/x/[email protected]/"
InputDirectory="deploy/crds"
TargetDirectory="."
deno run --allow-read=. --allow-write=lib "$CodegenSrc" "$InputDirectory" "$TargetDirectory" "$ApisImportUrl" At this point my project looks like this: > tree
.
├── deploy
│ └── crds
│ └── crontab.yaml
└── generate-api.sh Then I run that script: > chmod +x ./generate-api.sh # just once after creating the script
> ./generate-api.sh
+ CodegenSrc=https://raw.githubusercontent.com/cloudydeno/deno-kubernetes_apis/main/generation/run-on-crds.ts
+ ApisImportUrl=https://deno.land/x/[email protected]/
+ deno run --allow-read=. --allow-write=lib https://raw.githubusercontent.com/cloudydeno/deno-kubernetes_apis/main/generation/run-on-crds.ts deploy/crds . https://deno.land/x/[email protected]/
Wrote lib/stable.example.com@v1/structs.ts
Wrote lib/stable.example.com@v1/mod.ts And now I have a client module in a new > tree
.
├── deploy
│ └── crds
│ └── crontab.yaml
├── generate-api.sh
└── lib
└── stable.example.com@v1
├── mod.ts
└── structs.ts From here this module can be imported like so, and used just like the built-in clients: import { autoDetectClient } from 'https://deno.land/x/[email protected]/mod.ts';
const kubernetes = await autoDetectClient();
import { StableExampleComV1Api } from "./lib/stable.example.com@v1/mod.ts"
const exampleApi = new StableExampleComV1Api(kubernetes).namespace("default");
// just something arbitrary idk
await exampleApi.createCronTab({
metadata: {
name: 'my-crontab',
},
spec: {
cronSpec: '@daily',
image: 'cleanup-something',
replicas: 1,
},
}); Hopefully this is enough information to get the ball rolling for you. I didn't really have a good prior art when I set this up because I've found the Best, Dan |
I sort of did this manually for now but this is a great comment and I hope anyone in the future with this issue follows this advice. Thank you! |
I've created a custom resource definition and I see the api for CustomResourceDefinitions, but how do I then use this api to query for my custom resources?
The text was updated successfully, but these errors were encountered: