Deletes all non-crucial OpenShift cluster projects, by
- logging in to what should be a system:admin or cluster-admin user
- gets list of projects and filters out the important ones
specifically: openshift-infra, openshift-node, openshift, logging, kube-system, kube-service-catalog, kube-public, openshift-template-service-broker, default, management-infra, openshift-ansible-service-broker, dashai, peometheus-metrics
- outputs the projects to be deleted to ansible debug output
- deletes said projects
This is useful for cleaning up lab environments or anywhere that the non-core projects need to be cleared away.
Be aware that while this playbook isn't built to be purely idempotent, if there are no extraneous groups in the cluster, then the delete step fails, as there are no namespaces to delete.
-
git clone this repo to a master server in the cluster.
-
setup the hosts.inv inventory file with a single master IP address and the remote username for ansible-ssh-ing.
Note That this playbook assumes the remote user has a kube/config in place so that the remote user gets system:admin.
- run the playbook from an ansible master and watch it complete.
ansible-playbook -i hosts.inv clean.yml