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

add helm hook to add manifest annotation #1358

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

KubeKyrie
Copy link
Collaborator

@KubeKyrie KubeKyrie commented Sep 2, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

  1. add helm pre-upgrade hook to add annotation helm.sh/resource-policy=keep for all manifests when upgrade
  2. add helm pre-uninstall hook to delete all manifests when uninstall

Note that, manifests could not be deleted due to the resource policy when uninstall kubean and error occurs when reinstall kubean on not kubean-system ns. See https://github.com/kubean-io/kubean/actions/runs/10654653524/job/29532457171#logs

So we need add hook to help delete all manifests, which is necessary when kubean uninstalled.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@KubeKyrie KubeKyrie changed the title add helm hook to add manifest annotation [WIP]add helm hook to add manifest annotation Sep 3, 2024
@KubeKyrie
Copy link
Collaborator Author

Run helm uninstall, all manifest resources were deleted in pre-hook job.

➜   helm uninstall kubean -n kubean-system --debug                         
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/kyrieqin/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/kyrieqin/.kube/config
uninstall.go:102: [debug] uninstall: Deleting kubean
client.go:486: [debug] Starting delete for "kubean-pre-hook-job" ServiceAccount
client.go:490: [debug] Ignoring delete failure for "kubean-pre-hook-job" /v1, Kind=ServiceAccount: serviceaccounts "kubean-pre-hook-job" not found
client.go:142: [debug] creating 1 resource(s)
client.go:486: [debug] Starting delete for "kubean-pre-hook-job" ClusterRole
client.go:490: [debug] Ignoring delete failure for "kubean-pre-hook-job" rbac.authorization.k8s.io/v1, Kind=ClusterRole: clusterroles.rbac.authorization.k8s.io "kubean-pre-hook-job" not found
client.go:142: [debug] creating 1 resource(s)
client.go:486: [debug] Starting delete for "kubean-pre-hook-job" ClusterRoleBinding
client.go:490: [debug] Ignoring delete failure for "kubean-pre-hook-job" rbac.authorization.k8s.io/v1, Kind=ClusterRoleBinding: clusterrolebindings.rbac.authorization.k8s.io "kubean-pre-hook-job" not found
client.go:142: [debug] creating 1 resource(s)
client.go:486: [debug] Starting delete for "kubean-pre-hook-delete-all-manifest" Job
client.go:490: [debug] Ignoring delete failure for "kubean-pre-hook-delete-all-manifest" batch/v1, Kind=Job: jobs.batch "kubean-pre-hook-delete-all-manifest" not found
client.go:142: [debug] creating 1 resource(s)
client.go:712: [debug] Watching for changes to Job kubean-pre-hook-delete-all-manifest with timeout of 5m0s
client.go:740: [debug] Add/Modify event for kubean-pre-hook-delete-all-manifest: ADDED
client.go:779: [debug] kubean-pre-hook-delete-all-manifest: Jobs active: 1, jobs failed: 0, jobs succeeded: 0
client.go:740: [debug] Add/Modify event for kubean-pre-hook-delete-all-manifest: MODIFIED
client.go:779: [debug] kubean-pre-hook-delete-all-manifest: Jobs active: 1, jobs failed: 0, jobs succeeded: 0
client.go:740: [debug] Add/Modify event for kubean-pre-hook-delete-all-manifest: MODIFIED
client.go:779: [debug] kubean-pre-hook-delete-all-manifest: Jobs active: 1, jobs failed: 0, jobs succeeded: 0
client.go:740: [debug] Add/Modify event for kubean-pre-hook-delete-all-manifest: MODIFIED
client.go:779: [debug] kubean-pre-hook-delete-all-manifest: Jobs active: 0, jobs failed: 0, jobs succeeded: 0
client.go:740: [debug] Add/Modify event for kubean-pre-hook-delete-all-manifest: MODIFIED
client.go:486: [debug] Starting delete for "kubean-pre-hook-job" ServiceAccount
client.go:486: [debug] Starting delete for "kubean-pre-hook-job" ClusterRole
client.go:486: [debug] Starting delete for "kubean-pre-hook-job" ClusterRoleBinding
client.go:486: [debug] Starting delete for "kubean-pre-hook-delete-all-manifest" Job
client.go:486: [debug] Starting delete for "kubean-admission" Service
client.go:486: [debug] Starting delete for "kubean" Service
client.go:486: [debug] Starting delete for "kubean-admission" Deployment
client.go:486: [debug] Starting delete for "kubean" Deployment
client.go:486: [debug] Starting delete for "kubean" RoleBinding
client.go:486: [debug] Starting delete for "kubean" Role
client.go:486: [debug] Starting delete for "kubean" ClusterRoleBinding
client.go:486: [debug] Starting delete for "kubean" ClusterRole
client.go:486: [debug] Starting delete for "kubean-config" ConfigMap
client.go:486: [debug] Starting delete for "kubean" ServiceAccount
client.go:486: [debug] Starting delete for "kubean-admission-webhook" ValidatingWebhookConfiguration
uninstall.go:155: [debug] purge requested for kubean
These resources were kept due to the resource policy:
[Manifest] manifest-2.24-1688e05

release "kubean" uninstalled

…fest when uninstall

Signed-off-by: KubeKyrie <shaolong.qin@daocloud.io>
@KubeKyrie KubeKyrie changed the title [WIP]add helm hook to add manifest annotation add helm hook to add manifest annotation Sep 3, 2024
@ErikJiang ErikJiang merged commit 6a3c3ad into kubean-io:main Sep 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants