Skip to content

Commit 34b3f3d

Browse files
authored
Merge pull request #14 from kubernetes/master
merge from upsteam
2 parents 0d57747 + 57cb82e commit 34b3f3d

File tree

559 files changed

+25752
-19913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

559 files changed

+25752
-19913
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ resources/
3333
# Netlify Functions build output
3434
package-lock.json
3535
functions/
36-
node_modules/
36+
node_modules/
37+
38+
# Generated files when building with make container-build
39+
.config/
40+
.npm/

OWNERS_ALIASES

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ aliases:
2727
- kbarnard10
2828
- kbhawkey
2929
- onlydole
30+
- pi-victor
3031
- reylejano
3132
- savitharaghunathan
3233
- sftim
@@ -232,3 +233,27 @@ aliases:
232233
- mrbobbytables
233234
- nikhita
234235
- parispittman
236+
# authoritative source: https://git.k8s.io/sig-release/OWNERS_ALIASES
237+
sig-release-leads:
238+
- hasheddan # SIG Technical Lead
239+
- jeremyrickard # SIG Technical Lead
240+
- justaugustus # SIG Chair
241+
- LappleApple # SIG Program Manager
242+
- saschagrunert # SIG Chair
243+
release-engineering-approvers:
244+
- cpanato # Release Manager
245+
- hasheddan # subproject owner / Release Manager
246+
- puerco # Release Manager
247+
- saschagrunert # subproject owner / Release Manager
248+
- justaugustus # subproject owner / Release Manager
249+
- xmudrii # Release Manager
250+
release-engineering-reviewers:
251+
- ameukam # Release Manager Associate
252+
- jimangel # Release Manager Associate
253+
- mkorbi # Release Manager Associate
254+
- palnabarun # Release Manager Associate
255+
- onlydole # Release Manager Associate
256+
- sethmccombs # Release Manager Associate
257+
- thejoycekung # Release Manager Associate
258+
- verolop # Release Manager Associate
259+
- wilsonehusin # Release Manager Associate

assets/scss/_custom.scss

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ body.cid-community > #deprecation-warning > .deprecation-warning > * {
444444
.td-sidebar__inner {
445445
form.td-sidebar__search {
446446

447-
button.td-sidebar__toggle {
447+
.td-sidebar__toggle {
448448
&:hover {
449449
color: #000000;
450450
}
@@ -482,10 +482,6 @@ main.content {
482482

483483
.td-blog {
484484

485-
.td-sidebar-nav {
486-
max-height: calc(100vh - 8rem);
487-
}
488-
489485
.widget-link {
490486
margin-bottom: 1rem;
491487

assets/scss/_tablet.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ $feature-box-div-width: 45%;
7777
position: relative;
7878
clear: both;
7979
display: table;
80-
height: 160px;
8180

8281
.content {
8382
display: table-cell;
@@ -124,6 +123,7 @@ $feature-box-div-width: 45%;
124123
position: relative;
125124
display: block;
126125
float: none;
126+
text-align: center;
127127
max-width: 100%;
128128
transform: none;
129129
}

content/en/blog/_posts/2020-12-02-dockershim-faq.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ and other ecosystem groups to ensure a smooth transition and will evaluate thing
4747
as the situation evolves.
4848

4949

50+
### Can I still use dockershim after it is removed from Kubernetes?
51+
52+
Update:
53+
Mirantis and Docker have [committed][mirantis] to maintaining the dockershim after
54+
it is removed from Kubernetes.
55+
56+
[mirantis]: https://www.mirantis.com/blog/mirantis-to-take-over-support-of-kubernetes-dockershim-2/
57+
58+
5059
### Will my existing Docker images still work?
5160

5261
Yes, the images produced from `docker build` will work with all CRI implementations.
@@ -178,4 +187,3 @@ discussion of the changes.
178187

179188
Always and whenever you want! 🤗🤗
180189

181-
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
---
2+
layout: blog
3+
title: 'Using Finalizers to Control Deletion'
4+
date: 2021-05-14
5+
slug: using-finalizers-to-control-deletion
6+
---
7+
8+
**Authors:** Aaron Alpar (Kasten)
9+
10+
Deleting objects in Kubernetes can be challenging. You may think you’ve deleted something, only to find it still persists. While issuing a `kubectl delete` command and hoping for the best might work for day-to-day operations, understanding how Kubernetes `delete` commands operate will help you understand why some objects linger after deletion.
11+
12+
In this post, I’ll look at:
13+
14+
- What properties of a resource govern deletion
15+
- How finalizers and owner references impact object deletion
16+
- How the propagation policy can be used to change the order of deletions
17+
- How deletion works, with examples
18+
19+
For simplicity, all examples will use ConfigMaps and basic shell commands to demonstrate the process. We’ll explore how the commands work and discuss repercussions and results from using them in practice.
20+
21+
## The basic `delete`
22+
23+
Kubernetes has several different commands you can use that allow you to create, read, update, and delete objects. For the purpose of this blog post, we’ll focus on four `kubectl` commands: `create`, `get`, `patch`, and `delete`.
24+
25+
Here are examples of the basic `kubectl delete` command:
26+
27+
```
28+
kubectl create configmap mymap
29+
configmap/mymap created
30+
```
31+
32+
```
33+
kubectl get configmap/mymap
34+
NAME DATA AGE
35+
mymap 0 12s
36+
```
37+
38+
```
39+
kubectl delete configmap/mymap
40+
configmap "mymap" deleted
41+
```
42+
43+
```
44+
kubectl get configmap/mymap
45+
Error from server (NotFound): configmaps "mymap" not found
46+
```
47+
48+
Shell commands preceded by `$` are followed by their output. You can see that we begin with a `kubectl create configmap mymap`, which will create the empty configmap `mymap`. Next, we need to `get` the configmap to prove it exists. We can then delete that configmap. Attempting to `get` it again produces an HTTP 404 error, which means the configmap is not found.
49+
50+
The state diagram for the basic `delete` command is very simple:
51+
52+
53+
{{<figure width="495" src="/images/blog/2021-05-14-using-finalizers-to-control-deletion/state-diagram-delete.png" caption="State diagram for delete">}}
54+
55+
Although this operation is straightforward, other factors may interfere with the deletion, including finalizers and owner references.
56+
57+
## Understanding Finalizers
58+
59+
When it comes to understanding resource deletion in Kubernetes, knowledge of how finalizers work is helpful and can help you understand why some objects don’t get deleted.
60+
61+
Finalizers are keys on resources that signal pre-delete operations. They control the garbage collection on resources, and are designed to alert controllers what cleanup operations to perform prior to removing a resource. However, they don’t necessarily name code that should be executed; finalizers on resources are basically just lists of keys much like annotations. Like annotations, they can be manipulated.
62+
63+
Some common finalizers you’ve likely encountered are:
64+
65+
- `kubernetes.io/pv-protection`
66+
- `kubernetes.io/pvc-protection`
67+
68+
The finalizers above are used on volumes to prevent accidental deletion. Similarly, some finalizers can be used to prevent deletion of any resource but are not managed by any controller.
69+
70+
Below with a custom configmap, which has no properties but contains a finalizer:
71+
72+
```
73+
cat <<EOF | kubectl create -f -
74+
apiVersion: v1
75+
kind: ConfigMap
76+
metadata:
77+
name: mymap
78+
finalizers:
79+
- kubernetes
80+
EOF
81+
```
82+
83+
The configmap resource controller doesn't understand what to do with the `kubernetes` finalizer key. I term these “dead” finalizers for configmaps as it is normally used on namespaces. Here’s what happen upon attempting to delete the configmap:
84+
85+
```
86+
kubectl delete configmap/mymap &
87+
configmap "mymap" deleted
88+
jobs
89+
[1]+ Running kubectl delete configmap/mymap
90+
```
91+
92+
Kubernetes will report back that the object has been deleted, however, it hasn’t been deleted in a traditional sense. Rather, it’s in the process of deletion. When we attempt to `get` that object again, we discover the object has been modified to include the deletion timestamp.
93+
94+
```
95+
kubectl get configmap/mymap -o yaml
96+
apiVersion: v1
97+
kind: ConfigMap
98+
metadata:
99+
creationTimestamp: "2020-10-22T21:30:18Z"
100+
deletionGracePeriodSeconds: 0
101+
deletionTimestamp: "2020-10-22T21:30:34Z"
102+
finalizers:
103+
- kubernetes
104+
name: mymap
105+
namespace: default
106+
resourceVersion: "311456"
107+
selfLink: /api/v1/namespaces/default/configmaps/mymap
108+
uid: 93a37fed-23e3-45e8-b6ee-b2521db81638
109+
```
110+
111+
In short, what’s happened is that the object was updated, not deleted. That’s because Kubernetes saw that the object contained finalizers and put it into a read-only state. The deletion timestamp signals that the object can only be read, with the exception of removing the finalizer key updates. In other words, the deletion will not be complete until we edit the object and remove the finalizer.
112+
113+
Here's a demonstration of using the `patch` command to remove finalizers. If we want to delete an object, we can simply patch it on the command line to remove the finalizers. In this way, the deletion that was running in the background will complete and the object will be deleted. When we attempt to `get` that configmap, it will be gone.
114+
115+
```
116+
kubectl patch configmap/mymap \
117+
--type json \
118+
--patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
119+
configmap/mymap patched
120+
[1]+ Done kubectl delete configmap/mymap
121+
122+
kubectl get configmap/mymap -o yaml
123+
Error from server (NotFound): configmaps "mymap" not found
124+
```
125+
126+
Here's a state diagram for finalization:
127+
128+
{{<figure width="617" src="/images/blog/2021-05-14-using-finalizers-to-control-deletion/state-diagram-finalize.png" caption="State diagram for finalize">}}
129+
130+
So, if you attempt to delete an object that has a finalizer on it, it will remain in finalization until the controller has removed the finalizer keys or the finalizers are removed using Kubectl. Once that finalizer list is empty, the object can actually be reclaimed by Kubernetes and put into a queue to be deleted from the registry.
131+
132+
## Owner References
133+
134+
Owner references describe how groups of objects are related. They are properties on resources that specify the relationship to one another, so entire trees of resources can be deleted.
135+
136+
Finalizer rules are processed when there are owner references. An owner reference consists of a name and a UID. Owner references link resources within the same namespace, and it also needs a UID for that reference to work. Pods typically have owner references to the owning replica set. So, when deployments or stateful sets are deleted, then the child replica sets and pods are deleted in the process.
137+
138+
Here are some examples of owner references and how they work. In the first example, we create a parent object first, then the child. The result is a very simple configmap that contains an owner reference to its parent:
139+
140+
```
141+
cat <<EOF | kubectl create -f -
142+
apiVersion: v1
143+
kind: ConfigMap
144+
metadata:
145+
name: mymap-parent
146+
EOF
147+
CM_UID=$(kubectl get configmap mymap-parent -o jsonpath="{.metadata.uid}")
148+
149+
cat <<EOF | kubectl create -f -
150+
apiVersion: v1
151+
kind: ConfigMap
152+
metadata:
153+
name: mymap-child
154+
ownerReferences:
155+
- apiVersion: v1
156+
kind: ConfigMap
157+
name: mymap-parent
158+
uid: $CM_UID
159+
EOF
160+
```
161+
162+
Deleting the child object when an owner reference is involved does not delete the parent:
163+
164+
```
165+
kubectl get configmap
166+
NAME DATA AGE
167+
mymap-child 0 12m4s
168+
mymap-parent 0 12m4s
169+
170+
kubectl delete configmap/mymap-child
171+
configmap "mymap-child" deleted
172+
173+
kubectl get configmap
174+
NAME DATA AGE
175+
mymap-parent 0 12m10s
176+
```
177+
178+
In this example, we re-created the parent-child configmaps from above. Now, when deleting from the parent (instead of the child) with an owner reference from the child to the parent, when we `get` the configmaps, none are in the namespace:
179+
180+
```
181+
kubectl get configmap
182+
NAME DATA AGE
183+
mymap-child 0 10m2s
184+
mymap-parent 0 10m2s
185+
186+
kubectl delete configmap/mymap-parent
187+
configmap "mymap-parent" deleted
188+
189+
kubectl get configmap
190+
No resources found in default namespace.
191+
```
192+
193+
To sum things up, when there's an override owner reference from a child to a parent, deleting the parent deletes the children automatically. This is called `cascade`. The default for cascade is `true`, however, you can use the --cascade=false option for `kubectl delete` to delete an object and orphan its children.
194+
195+
In the following example, there is a parent and a child. Notice the owner references are still included. If I delete the parent using --cascade=false, the parent is deleted but the child still exists:
196+
197+
```
198+
kubectl get configmap
199+
NAME DATA AGE
200+
mymap-child 0 13m8s
201+
mymap-parent 0 13m8s
202+
203+
kubectl delete --cascade=false configmap/mymap-parent
204+
configmap "mymap-parent" deleted
205+
206+
kubectl get configmap
207+
NAME DATA AGE
208+
mymap-child 0 13m21s
209+
```
210+
211+
The --cascade option links to the propagation policy in the API, which allows you to change the order in which objects are deleted within a tree. In the following example uses API access to craft a custom delete API call with the background propagation policy:
212+
213+
```
214+
kubectl proxy --port=8080 &
215+
Starting to serve on 127.0.0.1:8080
216+
217+
curl -X DELETE \
218+
localhost:8080/api/v1/namespaces/default/configmaps/mymap-parent \
219+
-d '{ "kind":"DeleteOptions", "apiVersion":"v1", "propagationPolicy":"Background" }' \
220+
-H "Content-Type: application/json"
221+
{
222+
"kind": "Status",
223+
"apiVersion": "v1",
224+
"metadata": {},
225+
"status": "Success",
226+
"details": { ... }
227+
}
228+
```
229+
230+
Note that the propagation policy cannot be specified on the command line using kubectl. You have to specify it using a custom API call. Simply create a proxy, so you have access to the API server from the client, and execute a `curl` command with just a URL to execute that `delete` command.
231+
232+
There are three different options for the propagation policy:
233+
234+
- `Foreground`: Children are deleted before the parent (post-order)
235+
- `Background`: Parent is deleted before the children (pre-order)
236+
- `Orphan`: Owner references are ignored
237+
238+
Keep in mind that when you delete an object and owner references have been specified, finalizers will be honored in the process. This can result in trees of objects persisting, and you end up with a partial deletion. At that point, you have to look at any existing owner references on your objects, as well as any finalizers, to understand what’s happening.
239+
240+
## Forcing a Deletion of a Namespace
241+
242+
There's one situation that may require forcing finalization for a namespace. If you've deleted a namespace and you've cleaned out all of the objects under it, but the namespace still exists, deletion can be forced by updating the namespace subresource, `finalize`. This informs the namespace controller that it needs to remove the finalizer from the namespace and perform any cleanup:
243+
244+
```
245+
cat <<EOF | curl -X PUT \
246+
localhost:8080/api/v1/namespaces/test/finalize \
247+
-H "Content-Type: application/json" \
248+
--data-binary @-
249+
{
250+
"kind": "Namespace",
251+
"apiVersion": "v1",
252+
"metadata": {
253+
"name": "test"
254+
},
255+
"spec": {
256+
"finalizers": null
257+
}
258+
}
259+
EOF
260+
```
261+
262+
This should be done with caution as it may delete the namespace only and leave orphan objects within the, now non-exiting, namespace - a confusing state for Kubernetes. If this happens, the namespace can be re-created manually and sometimes the orphaned objects will re-appear under the just-created namespace which will allow manual cleanup and recovery.
263+
264+
## Key Takeaways
265+
266+
As these examples demonstrate, finalizers can get in the way of deleting resources in Kubernetes, especially when there are parent-child relationships between objects. Often, there is a reason for adding a finalizer into the code, so you should always investigate before manually deleting it. Owner references allow you to specify and remove trees of resources, although finalizers will be honored in the process. Finally, the propagation policy can be used to specify the order of deletion via a custom API call, giving you control over how objects are deleted. Now that you know a little more about how deletions work in Kubernetes, we recommend you try it out on your own, using a test cluster.
267+
268+
{{< youtube class="youtube-quote-sm" id="F7-ZxWwf4sY" title="Clean Up Your Room! What Does It Mean to Delete Something in K8s">}}

content/en/community/_index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
<a href="#videos">Videos</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
2525
<a href="#discuss">Discussions</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
2626
<a href="#events">Events and meetups</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
27-
<a href="#news">News</a>
27+
<a href="#news">News</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
28+
<a href="/releases">Releases</a>
2829

2930
</div>
3031
<br class="mobile"><br class="mobile">

content/en/docs/concepts/cluster-administration/addons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This page lists some of the available add-ons and links to their respective inst
2323
* [CNI-Genie](https://github.com/Huawei-PaaS/CNI-Genie) enables Kubernetes to seamlessly connect to a choice of CNI plugins, such as Calico, Canal, Flannel, Romana, or Weave.
2424
* [Contiv](https://contiv.github.io) provides configurable networking (native L3 using BGP, overlay using vxlan, classic L2, and Cisco-SDN/ACI) for various use cases and a rich policy framework. Contiv project is fully [open sourced](https://github.com/contiv). The [installer](https://github.com/contiv/install) provides both kubeadm and non-kubeadm based installation options.
2525
* [Contrail](https://www.juniper.net/us/en/products-services/sdn/contrail/contrail-networking/), based on [Tungsten Fabric](https://tungsten.io), is an open source, multi-cloud network virtualization and policy management platform. Contrail and Tungsten Fabric are integrated with orchestration systems such as Kubernetes, OpenShift, OpenStack and Mesos, and provide isolation modes for virtual machines, containers/pods and bare metal workloads.
26-
* [Flannel](https://github.com/coreos/flannel/blob/master/Documentation/kubernetes.md) is an overlay network provider that can be used with Kubernetes.
26+
* [Flannel](https://github.com/flannel-io/flannel#deploying-flannel-manually) is an overlay network provider that can be used with Kubernetes.
2727
* [Knitter](https://github.com/ZTE/Knitter/) is a plugin to support multiple network interfaces in a Kubernetes pod.
2828
* [Multus](https://github.com/Intel-Corp/multus-cni) is a Multi plugin for multiple network support in Kubernetes to support all CNI plugins (e.g. Calico, Cilium, Contiv, Flannel), in addition to SRIOV, DPDK, OVS-DPDK and VPP based workloads in Kubernetes.
2929
* [OVN-Kubernetes](https://github.com/ovn-org/ovn-kubernetes/) is a networking provider for Kubernetes based on [OVN (Open Virtual Network)](https://github.com/ovn-org/ovn/), a virtual networking implementation that came out of the Open vSwitch (OVS) project. OVN-Kubernetes provides an overlay based networking implementation for Kubernetes, including an OVS based implementation of load balancing and network policy.

0 commit comments

Comments
 (0)