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

feat: make delete protection to namespace kube-node-lease #85807

Open
wants to merge 1 commit into
base: master
from

Conversation

@beautytiger
Copy link
Contributor

beautytiger commented Dec 2, 2019

What type of PR is this?
/kind feature

What this PR does / why we need it:
Make delete protection to namespace kube-node-lease:

Namespace kube-system, default and kube-public already protected.

root@k8sn00:~# kubectl get ns
NAME              STATUS   AGE
default           Active   13d
ingress-nginx     Active   13d
kube-node-lease   Active   13d
kube-public       Active   13d
kube-system       Active   13d
monitoring        Active   13d
root@k8sn00:~# kubectl delete ns kube-system
Error from server (Forbidden): namespaces "kube-system" is forbidden: this namespace may not be deleted
root@k8sn00:~# kubectl delete ns default
Error from server (Forbidden): namespaces "default" is forbidden: this namespace may not be deleted
root@k8sn00:~# kubectl delete ns kube-public
Error from server (Forbidden): namespaces "kube-public" is forbidden: this namespace may not be deleted

We should alse protect kube-node-lease from deletion since if we delete it, the cluster become unstable, and later the namespace will be recreated.

root@k8sn00:~# kubectl delete ns kube-node-lease
namespace "kube-node-lease" deleted
root@k8sn00:~# kubectl get node -w
NAME     STATUS   ROLES    AGE   VERSION
k8sn00   Ready    master   13d   v1.15.4
k8sn01   Ready    <none>   13d   v1.15.4
k8sn02   Ready    <none>   13d   v1.15.4
k8sn01   NotReady   <none>   13d   v1.15.4
k8sn01   NotReady   <none>   13d   v1.15.4
k8sn00   NotReady   master   13d   v1.15.4
k8sn00   NotReady   master   13d   v1.15.4
k8sn02   NotReady   <none>   13d   v1.15.4
k8sn02   NotReady   <none>   13d   v1.15.4
k8sn01   NotReady   <none>   13d   v1.15.4
k8sn01   Ready      <none>   13d   v1.15.4
k8sn01   Ready      <none>   13d   v1.15.4
k8sn01   Ready      <none>   13d   v1.15.4
k8sn00   Ready      master   13d   v1.15.4
k8sn00   Ready      master   13d   v1.15.4

However, in some conditon, delete kube-node-lease where stuck in Terminating and the hole cluster will become unrecoverable at all.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Namespace `kube-node-lease` are not allowed to be deleted by user.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Dec 2, 2019

Hi @beautytiger. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Dec 2, 2019

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: beautytiger
To complete the pull request process, please assign smarterclayton
You can assign the PR to them by writing /assign @smarterclayton in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@beautytiger

This comment has been minimized.

Copy link
Contributor Author

beautytiger commented Dec 2, 2019

/priority backlog
/sig cluster-lifecycle
/assign @smarterclayton

@liggitt

This comment has been minimized.

Copy link
Member

liggitt commented Dec 2, 2019

the intent of these namespace protections was to guard namespaces required for the control plane to operate (which could not auto-recover if deleted). that included the default namespace (because that's where the kubernetes service lives) and the kube-system namespace (because that's where the controller credentials for kube-controller-manager live).

it's not clear the node lease namespace qualifies.

@liggitt

This comment has been minimized.

Copy link
Member

liggitt commented Dec 2, 2019

/hold

@beautytiger

This comment has been minimized.

Copy link
Contributor Author

beautytiger commented Dec 4, 2019

@liggitt
Thanks for your good explaination, I see the reason why namespace should protected against deletion. Besides kube-node-lease will be recreated after some lease timeout, this is good.
The reason why I want this namespace protection is that when deleting a lot of namespaces, all of them stuck in 'Terminating' state, including the mis-deleted kube-node-lease, as a result, the cluster node stuck in the loop of NotReady and Ready, no more operations are accepted by this cluster.
Is there some other kind of delete protection for namespace, I think there are needs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.