I recently applied this CRD file
https://raw.githubusercontent.com/jetstack/cert-manager/release-0.11/deploy/manifests/00-crds.yaml
With
kubectl apply to install this: https://hub.helm.sh/charts/jetstack/cert-manager
I think I managed to apply it successfully:
xetra11@x11-work configuration]$ kubectl apply -f ./helm-charts/certificates/00-crds.yaml --validate=false
customresourcedefinition.apiextensions.k8s.io/challenges.acme.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/orders.acme.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/certificates.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/clusterissuers.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/issuers.cert-manager.io created
But now I would like to "see" what I just applied here. I have no idea how to list those definitions or for example remove them if I think they will screw up my cluster somehow.
I was not able to find any information to that here: https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#preparing-to-install-a-custom-resource
kubectl get customresourcedefinitions, or kubectl get crd.
You can then use
kubectl describe crd <crd_name> to get a description of the CRD. And of course kubectl get crd <crd_name> -o yaml to get the complete definition of the CRD.
To remove you can use
kubectl delete crd <crd_name>.Custom Resources are like any other native Kubernetes resource.
All the basic kubeclt CRUD operations work fine for CRDs. So just use any of the below commands.
kubectl get crd <name of crd>
kubectl describe crd <name of crd>
kubectl get crd <name of crd> -o yaml
First, you can list all your CRD's with
kubectl get crd for example:
$ kubectl get crd
NAME CREATED AT
secretproviderclasses.secrets-store.csi.x-k8s.io 2022-07-06
secretproviderclasspodstatuses.secrets-store.csi.x-k8s.io 2022-07-06
This is the list of available CRD's definitions, then you take the name of one and launch a
kubectl get <crd_name> to get a list of applied resources from this CRD. For example:
$ kubectl get secretproviderclasses.secrets-store.csi.x-k8s.io
NAME AGE
azure-kv 5d
Note: Use
-A to target all namespaces or -n <namespace>You may arrive here confused about why you see your CRDs in
kubectl get api-resources, e.g. this Istio Telemetry resource:
kubectl api-resources --api-group=telemetry.istio.io
NAME SHORTNAMES APIVERSION NAMESPACED KIND
telemetries telemetry telemetry.istio.io/v1alpha1 true Telemetry
but then attempting to
kubectl describe them yields an error like
kubectl describe crd Telemetry.telemetry.istio.io Error from server (NotFound): customresourcedefinitions.apiextensions.k8s.io "Telemetry.telemetry.istio.io" not found
or
kubectl describe crd telemetry.istio.io/v1alpha1 error: there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'kubectl get resource/<resource_name>' instead of 'kubectl get resource resource/<resource_name>'
That's because you must use the plural form of the full name of the CRD. See
kubectl get crd for the names, e.g.:
$ kubectl get crd |grep -i telemetry
telemetries.telemetry.istio.io 2022-03-21T08:49:29Z
So
kc describe crd telemetries.telemetry.istio.io will work for this CRD.List the crds (no namespace as crds are cluster scoped):
kubectl get crds
Describe the crd:
kubectl describe crd challenges.acme.cert-manager.io
Since CRDs are not namespaced (but in cluster scope), you'll probably want to list all the custom resources that were created in a specific namespace:
kubectl api-resources --verbs=list --namespaced -o name \ | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <namespace>
You can read more about it here https://github.com/kubernetes/kubectl/issues/151