Skip to content

Instantly share code, notes, and snippets.

@anitsh
Created March 25, 2020 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anitsh/436877f8144cfda8928d9029c41a4e98 to your computer and use it in GitHub Desktop.
Save anitsh/436877f8144cfda8928d9029c41a4e98 to your computer and use it in GitHub Desktop.
Delete custom resource in Kubernetes
#Resource location: thttps://raw.githubusercontent.com/inlets/inlets-operator/master/artifacts/crd.yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: tunnels.inlets.inlets.dev
spec:
group: inlets.inlets.dev
version: v1alpha1
names:
kind: Tunnel
plural: tunnels
scope: Namespaced
additionalPrinterColumns:
- name: Service
type: string
JSONPath: .spec.serviceName
- name: HostStatus
type: string
JSONPath: .status.hostStatus
- name: HostIP
type: string
JSONPath: .status.hostIP
- name: HostID
type: string
JSONPath: .status.hostId
- name: Tunnel
type: string
JSONPath: .spec.client_deployment.name
@anitsh
Copy link
Author

anitsh commented Mar 25, 2020

After executing command:

kubectl apply -f https://raw.githubusercontent.com/inlets/inlets-operator/master/artifacts/crd.yaml

At first I did not know what resources it created as it did not list Pods, Service or Deployments form kubectl get command.

After some research, I came to know it created a resource as a Kubernetes API.

kubectl api-resources

Output:
NAME SHORTNAMES APIGROUP NAMESPACED KIND
tunnels inlets.inlets.dev true Tunnel

Now, I wanted to know how to delete this. Tried to delete as other reosurce like:

kubectl delete <resource-type> <resource-name>

But it did not work. Then after some research I was able to successfully, delete the resource.

kubectl delete -f https://raw.githubusercontent.com/inlets/inlets-operator/master/artifacts/crd.yaml

Output:
"customresourcedefinition.apiextensions.k8s.io "tunnels.inlets.inlets.dev" deleted"

Further. Sometimes the resources settings can cause the complete deletion issue. An example discussion below:
https://stackoverflow.com/questions/52009124/not-able-to-completely-remove-kubernetes-customresource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment