-
Notifications
You must be signed in to change notification settings - Fork 11
feat(webhook): unblock cluster deletion by removing deletion schedule handling #2082
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
Open
jellonek
wants to merge
3
commits into
main
Choose a base branch
from
unblock_cluster_deletion
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,7 @@ description: > | |
| ## Content Overview | ||
|
|
||
| - [Pre-requisites](#pre-requisites) | ||
| - [Schedule Deletion](#schedule-deletion) | ||
| - [Impact](#impact) | ||
| - [Immediate Deletion](#immediate-deletion) | ||
| - [Off-boarding](#off-boarding) | ||
| - [Troubleshooting](#troubleshooting) | ||
|
|
||
| This guides describes how to off-board an existing Kubernetes cluster in your Greenhouse organization. | ||
|
|
@@ -25,103 +23,20 @@ While all members of an organization can see existing clusters, their management | |
|
|
||
| ### Pre-requisites | ||
|
|
||
| Offboarding a `Cluster` in Greenhouse requires authenticating to the `greenhouse` cluster via `kubeconfig` file: | ||
| Off-boarding a `Cluster` in Greenhouse requires authenticating to the `greenhouse` cluster via `kubeconfig` file: | ||
|
|
||
| - `greenhouse`: The cluster where Greenhouse installation is running on. | ||
| - `organization-admin` or `cluster-admin` privileges is needed for deleting a `Cluster` resource. | ||
|
|
||
| ### Schedule Deletion | ||
|
|
||
| By default `Cluster` resource deletion is blocked by `ValidatingWebhookConfiguration` in Greenhouse. | ||
| This is done to prevent accidental deletion of cluster resources. | ||
| ## Off-boarding | ||
|
|
||
| List the clusters in your Greenhouse organization: | ||
| Off-board a `Cluster` in Greenhouse is initiated by calling the command: | ||
|
|
||
| ```shell | ||
| kubectl --namespace=<greenhouse-organization-name> get clusters | ||
| kubectl --namespace=<greenhouse-organization-name> delete cluster <cluster-name> | ||
| ``` | ||
|
|
||
| A typical output when you run the command looks like | ||
|
|
||
| ```shell | ||
| NAME AGE ACCESSMODE READY | ||
| mycluster-1 15d direct True | ||
| mycluster-2 35d direct True | ||
| mycluster-3 108d direct True | ||
| ``` | ||
|
|
||
| Delete a `Cluster` resource by annotating it with `greenhouse.sap/delete-cluster: "true"`. | ||
|
|
||
| Example: | ||
|
|
||
| ```shell | ||
| kubectl annotate cluster mycluster-1 greenhouse.sap/delete-cluster=true --namespace=my-org | ||
| ``` | ||
|
|
||
| Once the `Cluster` resource is annotated, the `Cluster` will be scheduled for deletion in 48 hours (UTC time). | ||
| This is reflected in the `Cluster` resource annotations and in the status conditions. | ||
|
|
||
| View the deletion schedule by inspecting the `Cluster` resource: | ||
|
|
||
| ```shell | ||
| kubectl get cluster mycluster-1 --namespace=my-org -o yaml | ||
| ```` | ||
|
|
||
| A typical output when you run the command looks like | ||
|
|
||
| ```yaml | ||
| apiVersion: greenhouse.sap/v1alpha1 | ||
| kind: Cluster | ||
| metadata: | ||
| annotations: | ||
| greenhouse.sap/delete-cluster: "true" | ||
| greenhouse.sap/deletion-schedule: "2025-01-17 11:16:40" | ||
| finalizers: | ||
| - greenhouse.sap/cleanup | ||
| name: mycluster-1 | ||
| namespace: my-org | ||
| spec: | ||
| accessMode: direct | ||
| kubeConfig: | ||
| maxTokenValidity: 72 | ||
| status: | ||
| ... | ||
| statusConditions: | ||
| conditions: | ||
| ... | ||
| - lastTransitionTime: "2025-01-15T11:16:40Z" | ||
| message: deletion scheduled at 2025-01-17 11:16:40 | ||
| reason: ScheduledDeletion | ||
| status: "False" | ||
| type: Delete | ||
| ``` | ||
|
|
||
| In order to cancel the deletion, you can remove the `greenhouse.sap/delete-cluster` annotation: | ||
|
|
||
| ```shell | ||
| kubectl annotate cluster mycluster-1 greenhouse.sap/delete-cluster- --namespace=my-org | ||
| ``` | ||
|
|
||
| > the `-` at the end of the annotation name is used to remove the annotation. | ||
|
|
||
| ### Impact | ||
|
|
||
| When a `Cluster` resource is scheduled for deletion, all `Plugin` resources associated with the `Cluster` resource will skip the reconciliation process. | ||
|
|
||
| When the deletion schedule is reached, the `Cluster` resource will be deleted and all associated resources `Plugin` resources will be deleted as well. | ||
|
|
||
| ### Immediate Deletion | ||
|
|
||
| In order to delete a `Cluster` resource immediately - | ||
|
|
||
| 1. annotate the `Cluster` resource with `greenhouse.sap/delete-cluster`. (see [Schedule Deletion](#schedule-deletion)) | ||
| 2. update the `greenhouse.sap/deletion-schedule` annotation to the current date and time. | ||
|
|
||
| You can also annotate the `Cluster` resource with `greenhouse.sap/delete-cluster` and `greenhouse.sap/deletion-schedule` at the same time and set the current date and time for deletion. | ||
|
|
||
| > The time and date should be in `YYYY-MM-DD HH:MM:SS` format or golang's `time.DateTime` format. | ||
| > The time should be in UTC timezone. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a Warning or Info Admonition to explain the consequences of deleting a cluster by explaining that all Plugins (if any) deployed to the cluster, will be uninstalled during cluster deletion. |
||
| ## Troubleshooting | ||
|
|
||
| If the cluster deletion has failed, you can troubleshoot the issue by inspecting - | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.