Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Wants: kubectel delete -k . should only delete all the awx resources, but not the entire namespace #1864

Closed
3 tasks done
wangzhihaocom opened this issue May 20, 2024 · 2 comments

Comments

@wangzhihaocom
Copy link

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX Operator is open source software provided for free and that I might not receive a timely response.

Feature Summary

Currently., when I deploy the awx in the existing namespace, I use kustomization.yaml
kubectl apply -k . command ,

but when I want to delete all the resources, I use kubectl delete -k .

It will terminate all the resources, as well as the entire existing namespace( including our other existing pod in the namespace), which is not good.

Is there a better to just delete all the awx resource but not to delete the entire namespace?

This is my kustomization.yaml

namespace: devops

generatorOptions:
  disableNameSuffixHash: true

secretGenerator:
  - name: awx-postgres-configuration
    type: Opaque
    literals:
      - host=<host>
      - port=<port>
      - database=<db>
      - username=<user>
      - password=<password>
      - type=unmanaged
      - sslmode=prefer

  - name: awx-admin-password
    type: Opaque
    literals:
      - password=admin

resources:
  - github.com/ansible/awx-operator/config/default?ref=2.16.1
  - awx.yaml

images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.16.1
@TheRealHaoLiu
Copy link
Member

@rooftopcellist I am using this command to delete the AWX resources, the resources got deleted but I got some error at the end . so that my gitlab CICD job failed. Is this command correct?

kubectl kustomize . | sed '/kind: Namespace/,+5d' | kubectl delete -f -

customresourcedefinition.apiextensions.k8s.io "awxbackups.awx.ansible.com" deleted > customresourcedefinition.apiextensions.k8s.io "awxmeshingresses.awx.ansible.com" deleted > customresourcedefinition.apiextensions.k8s.io "awxrestores.awx.ansible.com" deleted customresourcedefinition.apiextensions.k8s.io "awxs.awx.ansible.com" deleted serviceaccount "awx-operator-controller-manager" deleted role.rbac.authorization.k8s.io "awx-operator-awx-manager-role" deleted role.rbac.authorization.k8s.io "awx-operator-leader-election-role" deleted clusterrole.rbac.authorization.k8s.io "awx-operator-metrics-reader" deleted clusterrole.rbac.authorization.k8s.io "awx-operator-proxy-role" deleted rolebinding.rbac.authorization.k8s.io "awx-operator-awx-manager-rolebinding" deleted rolebinding.rbac.authorization.k8s.io "awx-operator-leader-election-rolebinding" deleted clusterrolebinding.rbac.authorization.k8s.io "awx-operator-proxy-rolebinding" deleted configmap "awx-operator-awx-manager-config" deleted secret "awx-admin-password" deleted secret "awx-postgres-configuration" deleted service "awx-operator-controller-manager-metrics-service" deleted deployment.apps "awx-operator-controller-manager" deleted ingress.networking.k8s.io "awx" deleted Error from server (NotFound): error when deleting "STDIN": the server could not find the requested resource (delete awxs.awx.ansible.com awx)

here's the last thing you posted on #ansible/awx#15173

so basically there's a "order of operation" that need to happen when deleting

we need to delete awx customresource before deleting the operator and crds (or else the deployments gets orphaned and nothing is left to clean it up)

i do not think kubectl delete -k will be do able u might be able to script around it something like

namespace=`cat kustomization.yaml | grep namespace | awk -F ' ' '{print $2}'`
kubectl delete awx --all -n ${namespace} # delete all awx instance in the namespace 
kubectl kustomize . | sed '/kind: Namespace/,+5d' | kubectl delete -f - # proceed to delete the operator

note this will retain the postgres PVC so if u want that gone u also need to explicitly delete that

this is not a feature we looking to support in the project if you have any further question we can start a discussion thread on the forum.ansible.com

@TheRealHaoLiu TheRealHaoLiu closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
@kevrrnet
Copy link

kevrrnet commented Aug 5, 2024

This is still an issue/bug, it just delete my entire namespace, very bad , please fix.

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

No branches or pull requests

3 participants