Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 775b9d0

Browse files
Merge branch 'master' into redirect-production-pods
2 parents 416ab39 + 2a62918 commit 775b9d0

9 files changed

Lines changed: 135 additions & 6 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: go
22
go:
3-
- 1.6.2
3+
- 1.7.3
44

55
# Don't want default ./... here:
66
install:

_data/tasks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ toc:
1313
- docs/tasks/configure-pod-container/pull-image-private-registry.md
1414
- docs/tasks/configure-pod-container/configure-liveness-readiness-probes.md
1515
- docs/tasks/configure-pod-container/communicate-containers-same-pod.md
16-
- docs/tasks/configure-pod-container/configure-pod-initialization.md
16+
- docs/tasks/configure-pod-container/configure-pod-initialization.md
17+
- docs/tasks/configure-pod-container/attach-handler-lifecycle-event.md
1718

1819
- title: Accessing Applications in a Cluster
1920
section:

docs/admin/salt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Configuring Kubernetes with Salt
66

77
The Kubernetes cluster can be configured using Salt.
88

9-
The Salt scripts are shared across multiple hosting providers, so it's important to understand some background information prior to making a modification to ensure your changes do not break hosting Kubernetes across multiple environments. Depending on where you host your Kubernetes cluster, you may be using different operating systems and different networking configurations. As a result, it's important to understand some background information before making Salt changes in order to minimize introducing failures for other hosting providers.
9+
The Salt scripts are shared across multiple hosting providers and depending on where you host your Kubernetes cluster, you may be using different operating systems and different networking configurations. As a result, it's important to understand some background information before making Salt changes in order to minimize introducing failures for other hosting providers.
1010

1111
## Salt cluster setup
1212

docs/getting-started-guides/minikube.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Any services of type `NodePort` can be accessed over that IP address, on the Nod
225225

226226
To determine the NodePort for your service, you can use a `kubectl` command like this:
227227

228-
`kubectl get service $SERVICE --output='jsonpath="{.spec.ports[0].NodePort}"'`
228+
`kubectl get service $SERVICE --output='jsonpath="{.spec.ports[0].nodePort}"'`
229229

230230
## Persistent Volumes
231231
Minikube supports [PersistentVolumes](http://kubernetes.io/docs/user-guide/persistent-volumes/) of type `hostPath`.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: Attaching Handlers to Container Lifecycle Events
3+
---
4+
5+
{% capture overview %}
6+
7+
This page shows how to attach handlers to Container lifecycle events. Kubernetes supports
8+
the postStart and preStop events. Kubernetes sends the postStart event immediately
9+
after a Container is started, and it sends the preStop event immediately before the
10+
Container is terminated.
11+
12+
{% endcapture %}
13+
14+
15+
{% capture prerequisites %}
16+
17+
{% include task-tutorial-prereqs.md %}
18+
19+
{% endcapture %}
20+
21+
22+
{% capture steps %}
23+
24+
### Defining postStart and preStop handlers
25+
26+
In this exercise, you create a Pod that has one Container. The Container has handlers
27+
for the postStart and preStop events.
28+
29+
Here is the configuration file for the Pod:
30+
31+
{% include code.html language="yaml" file="lifecycle-events.yaml" ghlink="/docs/tasks/configure-pod-container/lifecycle-events.yaml" %}
32+
33+
In the configuration file, you can see that the postStart command writes a `message`
34+
file to the Container's `/usr/share` directory. The preStop command shuts down
35+
nginx gracefully. This is helpful if the Container is being terminated because of a failure.
36+
37+
Create the Pod:
38+
39+
kubectl create -f http://k8s.io/docs/tasks/configure-pod-container/lifecycle-events.yaml
40+
41+
Verify that the Container in the Pod is running:
42+
43+
kubectl get pod lifecycle-demo
44+
45+
Get a shell into the Container running in your Pod:
46+
47+
kubectl exec -it lifecycle-demo -- /bin/bash
48+
49+
In your shell, verify that the `postStart` handler created the `message` file:
50+
51+
root@lifecycle-demo:/# cat /usr/share/message
52+
53+
The output shows the text written by the postStart handler:
54+
55+
Hello from the postStart handler
56+
57+
{% endcapture %}
58+
59+
60+
61+
{% capture discussion %}
62+
63+
### Discussion
64+
65+
Kubernetes sends the postStart event immediately after the Container is created.
66+
There is no guarantee, however, that the postStart handler is called before
67+
the Container's entrypoint is called. The postStart handler runs asynchronously
68+
relative to the Container's code, but Kubernetes' management of the container
69+
blocks until the postStart handler completes. The Container's status is not
70+
set to RUNNING until the postStart handler completes.
71+
72+
Kubernetes sends the preStop event immediately before the Container is terminated.
73+
Kubernetes' management of the Container blocks until the preStop handler completes,
74+
unless the Pod's grace period expires. For more details, see
75+
[Termination of Pods](/docs/user-guide/pods/#termination-of-pods).
76+
77+
{% endcapture %}
78+
79+
80+
{% capture whatsnext %}
81+
82+
* Learn more about [Container lifecycle hooks](/docs/user-guide/container-environment/.)
83+
* Learn more about the [lifecycle of a Pod](https://kubernetes.io/docs/user-guide/pod-states/).
84+
85+
86+
#### Reference
87+
88+
* [Lifecycle](https://kubernetes.io/docs/resources-reference/1_5/#lifecycle-v1)
89+
* [Container](https://kubernetes.io/docs/resources-reference/1_5/#container-v1)
90+
* See `terminationGracePeriodSeconds` in [PodSpec](/docs/resources-reference/v1.5/#podspec-v1)
91+
92+
{% endcapture %}
93+
94+
{% include templates/task.md %}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: lifecycle-demo
5+
spec:
6+
containers:
7+
- name: lifecycle-demo-container
8+
image: nginx
9+
10+
lifecycle:
11+
postStart:
12+
exec:
13+
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
14+
preStop:
15+
exec:
16+
command: ["/usr/sbin/nginx","-s","quit"]
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+

docs/tasks/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ single thing, typically by giving a short sequence of steps.
2020
* [Configuring Liveness and Readiness Probes](/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/)
2121
* [Communicating Between Pods Running in the Same Container](/docs/tasks/configure-pod-container/communicate-containers-same-pod/)
2222
* [Configuring Pod Initialization](/docs/tasks/configure-pod-container/configure-pod-initialization/)
23+
* [Attaching Handlers to Container Lifecycle Events](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)
2324

2425
#### Accessing Applications in a Cluster
2526

docs/tutorials/kubernetes-basics/explore-intro.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h3>Objectives</h3>
2828

2929
<div class="col-md-8">
3030
<h2>Kubernetes Pods</h2>
31-
<p>When you created a Deployment in Module <a href="/docs/tutorials/kubernetes-basics/deploy-intro/">2</a>, Kubernetes created a <b>Pod</b> to host your application instance. A Pod is Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers. Those resources include:</p>
31+
<p>When you created a Deployment in Module <a href="/docs/tutorials/kubernetes-basics/deploy-intro/">2</a>, Kubernetes created a <b>Pod</b> to host your application instance. A Pod is a Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers. Those resources include:</p>
3232
<ul>
3333
<li>Shared storage, as Volumes</li>
3434
<li>Networking, as a unique cluster IP address</li>

docs/user-guide/kubeconfig-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ So in order to easily switch between multiple clusters, for multiple users, a ku
1616

1717
This file contains a series of authentication mechanisms and cluster connection information associated with nicknames. It also introduces the concept of a tuple of authentication information (user) and cluster connection information called a context that is also associated with a nickname.
1818

19-
Multiple kubeconfig files are allowed, if specified explicitly. At runtime they are loaded and merged along with override options specified from the command line (see [rules](#loading-and-merging) below).
19+
Multiple kubeconfig files are allowed, if specified explicitly. At runtime they are loaded and merged along with override options specified from the command line (see [rules](#loading-and-merging-rules) below).
2020

2121
## Related discussion
2222

0 commit comments

Comments
 (0)