Skip to content
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

How do I get Custom Resource Definition properties? #458

Closed
sfxworks opened this issue May 9, 2019 · 2 comments · Fixed by #484
Closed

How do I get Custom Resource Definition properties? #458

sfxworks opened this issue May 9, 2019 · 2 comments · Fixed by #484

Comments

@sfxworks
Copy link

sfxworks commented May 9, 2019

I created a namespaced scope CRD.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: payloads.hook-to-k8s.sfxworks.net
spec:
  group: hook-to-k8s.sfxworks.net
  versions:
    - name: v1
      served: true
      storage: true
  scope: Namespaced
  names:
    plural: payloads
    singular: payload
    kind: Payload
    shortNames:
    - pl
    - payl

I am able to run kubectl-proxy and see that my CRD is active via http://127.0.0.1:8001/apis/hook-to-k8s.sfxworks.net/v1

With the client configured to use a service account in the pod and the pod configured to use a service account that has the proper Role/Role bindings, I get an error when trying to access this resource.

Using
const payloads = await client.apis["hook-to-k8s"].sfxworks.net.v1.namespaces.default.payloads.get()
I get

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'sfxworks' of undefined

I have tried renaming this several ways, including
const payloads = await client.apis["hook-to-k8s.sfxworks.net"].v1.namespaces.default.payloads.get()

and I still get undefined when trying to access any object after apis. How do I retrieve and post to my resource?

@sfxworks
Copy link
Author

After following https://github.com/godaddy/kubernetes-client/blob/master/examples/using-crds.js I was able to get this working. I wasn't registering this. However, I did notice it didn't like how version wasn't in an array and named "versions" instead. https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definition-versioning/#specify-multiple-versions

@silasbw
Copy link
Contributor

silasbw commented May 13, 2019

Glad you figured out a workaround @sfxworks and thanks for pointing out that issue. We should fix it. We receive PRs with a warm welcome :)

iffyio added a commit to iffyio/kubernetes-client that referenced this issue May 25, 2019
Currently, it's only possible to specify one api
version for CRD objects via the deprecated
`version` field when building their spec paths.
This commit adds support for building spec paths
for multiple CRD versions specified in the
`versions` list while maintaining compatibility
with `version`.

Fixes godaddy#458
silasbw pushed a commit that referenced this issue May 29, 2019
Currently, it's only possible to specify one api
version for CRD objects via the deprecated
`version` field when building their spec paths.
This commit adds support for building spec paths
for multiple CRD versions specified in the
`versions` list while maintaining compatibility
with `version`.

Fixes #458
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants