All Projects → xcoulon → kubectl-terminate

xcoulon / kubectl-terminate

Licence: Apache-2.0 license
kubectl-terminate, a kubectl plugin to remove finalizers and finally delete k8s resources

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to kubectl-terminate

kourier
Kourier is a Knative Serving Ingress. It has been adopted by Knative, and we keep developing it at: github.com/knative/net-kourier
Stars: ✭ 47 (+104.35%)
Mutual labels:  openshift
kubectl-skew
a simple kubectl plugin to make the "skew" visible
Stars: ✭ 18 (-21.74%)
Mutual labels:  kubectl-plugins
okd-installation-centos
This repository is used to create OKD 3.11 Cluster with 9 simple steps on Bare VM's
Stars: ✭ 23 (+0%)
Mutual labels:  openshift
verification-tests
Blackbox test suite for OpenShift.
Stars: ✭ 41 (+78.26%)
Mutual labels:  openshift
loki-operator
viaq.github.io/loki-operator/
Stars: ✭ 30 (+30.43%)
Mutual labels:  openshift
hybrid-cloud-serverless
Bursting Cloud (K)native Services across clouds using OpenShift and Skupper
Stars: ✭ 35 (+52.17%)
Mutual labels:  openshift
kube-lineage
A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.
Stars: ✭ 238 (+934.78%)
Mutual labels:  kubectl-plugins
OpenShift-Azure-Terraform
⛑ Deploy OpenShift Origin on Azure using Terraform and Ansible
Stars: ✭ 21 (-8.7%)
Mutual labels:  openshift
grafana-operator
An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
Stars: ✭ 449 (+1852.17%)
Mutual labels:  openshift
spring-cloud-dataflow-server-openshift
This project provides a Spring Cloud Data Flow server for deployments to OpenShift 3
Stars: ✭ 26 (+13.04%)
Mutual labels:  openshift
jbpm-spring-boot
Sample of a jbpm service with spring boot. It runs on OpenShift and it has prometheus metrics and a grafana dashboard
Stars: ✭ 16 (-30.43%)
Mutual labels:  openshift
cryostat-operator
An OpenShift Operator to facilitate setup and management of Cryostast and expose the Cryostat API through Kubernetes Custom Resources.
Stars: ✭ 25 (+8.7%)
Mutual labels:  openshift
ibm-spectrum-scale-csi
The IBM Spectrum Scale Container Storage Interface (CSI) project enables container orchestrators, such as Kubernetes and OpenShift, to manage the life-cycle of persistent storage.
Stars: ✭ 41 (+78.26%)
Mutual labels:  openshift
ods-jenkins-shared-library
Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Stars: ✭ 51 (+121.74%)
Mutual labels:  openshift
wildfly-operator
Kubernetes Operator for WildFly
Stars: ✭ 28 (+21.74%)
Mutual labels:  openshift
codewind-eclipse
Plugin for developing cloud-native, containerized applications from Eclipse IDE
Stars: ✭ 13 (-43.48%)
Mutual labels:  openshift
techlab
This repository contains the APPUiO and OpenShift Techlab tutorials.
Stars: ✭ 51 (+121.74%)
Mutual labels:  openshift
docker-phpmyadmin
phpMyAdmin as Docker container, based on official image, always latest version
Stars: ✭ 40 (+73.91%)
Mutual labels:  openshift
declarative-openshift
Working examples of manifests for openshift for use in a declarative management strategy.
Stars: ✭ 17 (-26.09%)
Mutual labels:  openshift
kubectl-extras
A collection of mini plugins for kubectl.
Stars: ✭ 109 (+373.91%)
Mutual labels:  kubectl-plugins

kubectl-terminate

GoDoc Go Report Card CI Codecov License

WARNING

Use at your own risk!

Sometimes (hopefully on your dev cluster) you may find yourself with a namespace stuck in Terminating phase because one of its child resource has a finalizer, but the operator (or controller) in charge of dealing with this finalizer is already gone (for example, it has been uninstalled). This is quite annoying and sadly the --force, grace-period, etc. flags won’t help. The only way to get rid of the resource is to PATCH it in order to remove the finalizers, then delete it. Doing it with a good old curl command is possible, but let’s admit it, it’s a bit cumbersome 😬

Say hello to kubectl-terminate 👋

This command takes care of removing the finalizers and deleting the resource on your behalf, using the connection settings of your choice, i.e, using the KUBECONFIG env var if it exists, the --kubeconfig flag if specified or the default location ($HOME on Linux and macOS and %USERPROFILE% on Windows).

And since its name follows the kubectl-* pattern, it also works as a plugin for kubectl and oc (for OpenShift 4 users). Just make sure that the binary is in your $PATH and use it with kubectl terminate pod/cheesecake or oc terminate pod/cheesecake 🎉

Installation

  • run go install github.com/xcoulon/kubectl-terminate/cmd and add $GOPAH/bin to $PATH or move $GOPAtH/bin/kubectl-terminate in one of the directories of $PATH

  • clone this repository, run make install and add $GOPAH/bin to $PATH or move $GOPAtH/bin/kubectl-terminate in one of the directories of $PATH

Demo

On your own Kubernetes or OpenShift cluster, you can try it with the following commands:

# create 2 pods called `keep-me` and `delete-me` that don't do anything
$ kubectl run --image radial/busyboxplus --restart=Never keep-me -- sleep 3600
pod/delete-me created

$ kubectl run --image radial/busyboxplus --restart=Never delete-me -- sleep 3600
pod/delete-me created

# patch the `delete-me` pod by adding a custom finalizer
$ kubectl patch pod/delete-me -p '{"metadata":{"finalizers":["demo/block-me"]}}'
pod/delete-me patched

# try to delete it with the regular `delete` command
$ kubectl delete pod/delete-me
pod "delete-me" deleted
^C

# ... but the command blocks and the pod still exists
$ kubectl get pods
NAME        READY   STATUS        RESTARTS   AGE
delete-me   0/1     Terminating   0          51s
keep-me     1/1     Running       0          54s

# delete it with the `terminate` command
$ kubectl terminate pod/delete-me
pod "delete-me" terminated

# verify
$ kubectl get pods
NAME      READY   STATUS    RESTARTS   AGE
keep-me   1/1     Running   0          82s

Contribution

Feel free to open issues if you find bugs or require more features. Also, PRs are welcome if you’re in the mood for that 🙌

License

This code is licensed under the Apache License, version 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].