diff --git a/README.md b/README.md index 4dd9d63..250ed51 100644 --- a/README.md +++ b/README.md @@ -375,3 +375,4 @@ kubectl apply -f awx-secret-tls.yaml - [📁 **Tips**](tips) - [📝Expose `/etc/hosts` to Pods on K3s](tips/expose-hosts.md) - [📝Redirect HTTP to HTTPS](tips/https-redirection.md) + - [📝Uninstall deployed resouces](tips/uninstall.md) diff --git a/tips/README.md b/tips/README.md index 944bfcf..95e31a0 100644 --- a/tips/README.md +++ b/tips/README.md @@ -2,3 +2,4 @@ - [📝Expose `/etc/hosts` to Pods on K3s](expose-hosts.md) - [📝Redirect HTTP to HTTPS](https-redirection.md) +- [📝Uninstall deployed resouces](uninstall.md) diff --git a/tips/expose-hosts.md b/tips/expose-hosts.md index d78d2cb..6cdd8d6 100644 --- a/tips/expose-hosts.md +++ b/tips/expose-hosts.md @@ -1,4 +1,3 @@ - # Expose your `/etc/hosts` to Pods on K3s If we don't have a DNS server and are using `/etc/hosts`, we will need to do some additional tasks to get the Pods on K3s to resolve names according to `/etc/hosts`. diff --git a/tips/uninstall.md b/tips/uninstall.md new file mode 100644 index 0000000..4753a94 --- /dev/null +++ b/tips/uninstall.md @@ -0,0 +1,69 @@ + +# Uninstall deployed resouces + + +## Table of Contents + +- [Uninstall resources on Kubernetes](#uninstall-resources-on-kubernetes) +- [Remove data in PVs](#remove-data-in-pvs) +- [Uninstall K3s](#uninstall-k3s) + +### Uninstall resources on Kubernetes + +In kubernetes, you can deploy resources with `kubectl create -f (-k)` or `kubectl apply -f (-k)` by specifying manifest files, and similarly, you can use manifest files to delete resources by `kubectl delete -f (-k)` command. + +For example, some resources deployed with the following command; + +```bash +$ kubectl apply -k base +namespace/awx created +secret/awx-admin-password created +secret/awx-postgres-configuration created +secret/awx-secret-tls created +persistentvolume/awx-postgres-volume created +persistentvolume/awx-projects-volume created +persistentvolumeclaim/awx-projects-claim created +awx.awx.ansible.com/awx created +``` + +can be deleted with the following command with same manifest files. + +```bash +$ kubectl delete -k base +namespace "awx" deleted +secret "awx-admin-password" deleted +secret "awx-postgres-configuration" deleted +secret "awx-secret-tls" deleted +persistentvolume "awx-postgres-volume" deleted +persistentvolume "awx-projects-volume" deleted +persistentvolumeclaim "awx-projects-claim" deleted +awx.awx.ansible.com "awx" deleted +``` + +Or, you can delete all resources in specific namespace by deleting that namespace. PVs cannot be deleted in this way since the PVs are namespace-independent resources, so they need to be deleted manually. + +```bash +$ kubectl delete ns awx +namespace "awx" deleted + +$ kubectl delete pv +persistentvolume "" deleted +``` + +### Remove data in PVs + +All manifest files in this repository, the PVs were persisted under `/data/` on the K3s host using `hostPath`. + +If you want to initialize the data and start all over again, for example, you can delete the data manually. + +```bash +sudo rm -rf /data/ +``` + +### Uninstall K3s + +K3s comes with a handy uninstall script. Once executed, it will perform an uninstall that includes removing all resources deployed on Kubeneretes. + +```bash +/usr/local/bin/k3s-uninstall.sh +```