Skip to content

Commit 3dd65e4

Browse files
tengqmk8s-ci-robot
authored andcommitted
Consolidate YAML files [part-14] (kubernetes#9379)
This PR deals with the getting started guides (windows) and tutorials sections. Since the YAML files in the windows directory currently are not referenced at all, this PR refactored the markdown file to correct this problem. When appropriate, we use the YAML content from the markdown in the extracted version.
1 parent ea6004b commit 3dd65e4

22 files changed

+182
-296
lines changed

content/en/docs/getting-started-guides/windows/_index.md

Lines changed: 18 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -261,112 +261,24 @@ The examples listed below assume running Windows nodes on Windows Server 1709. I
261261
### Scheduling Pods on Windows
262262
Because your cluster has both Linux and Windows nodes, you must explicitly set the `nodeSelector` constraint to be able to schedule pods to Windows nodes. You must set nodeSelector with the label `beta.kubernetes.io/os` to the value `windows`; see the following example:
263263

264-
```yaml
265-
{
266-
"apiVersion": "v1",
267-
"kind": "Pod",
268-
"metadata": {
269-
"name": "iis",
270-
"labels": {
271-
"name": "iis"
272-
}
273-
},
274-
"spec": {
275-
"containers": [
276-
{
277-
"name": "iis",
278-
"image": "microsoft/iis:windowsservercore-1709",
279-
"ports": [
280-
{
281-
"containerPort": 80
282-
}
283-
]
284-
}
285-
],
286-
"nodeSelector": {
287-
"beta.kubernetes.io/os": "windows"
288-
}
289-
}
290-
}
291-
```
264+
{{< codenew file="windows/simple-pod.yaml" >}}
265+
266+
{{< note >}}
292267
**Note:** This example assumes you are running on Windows Server 1709, so uses the image tag to support that. If you are on a different version, you will need to update the tag. For example, if on Windows Server 2016, update to use `"image": "microsoft/iis"` which will default to that OS version.
268+
{{< /note >}}
293269

294270
### Secrets and ConfigMaps
295271
Secrets and ConfigMaps can be utilized in Windows Server Containers, but must be used as environment variables. See limitations section below for additional details.
296272

297273
**Examples:**
298274

299-
Windows pod with secrets mapped to environment variables
300-
```yaml
301-
apiVersion: v1
302-
kind: Secret
303-
metadata:
304-
name: mysecret
305-
type: Opaque
306-
data:
307-
username: YWRtaW4=
308-
password: MWYyZDFlMmU2N2Rm
309-
310-
---
311-
312-
apiVersion: v1
313-
kind: Pod
314-
metadata:
315-
name: my-secret-pod
316-
spec:
317-
containers:
318-
- name: my-secret-pod
319-
image: microsoft/windowsservercore:1709
320-
env:
321-
- name: USERNAME
322-
valueFrom:
323-
secretKeyRef:
324-
name: mysecret
325-
key: username
326-
- name: PASSWORD
327-
valueFrom:
328-
secretKeyRef:
329-
name: mysecret
330-
key: password
331-
nodeSelector:
332-
beta.kubernetes.io/os: windows
333-
```
334-
335-
Windows pod with configMap values mapped to environment variables
275+
Windows pod with secrets mapped to environment variables
336276

337-
```yaml
338-
kind: ConfigMap
339-
apiVersion: v1
340-
metadata:
341-
name: example-config
342-
data:
343-
example.property.1: hello
344-
example.property.2: world
277+
{{< codenew file="windows/secret-pod.yaml" >}}
345278

346-
---
279+
Windows Pod with configMap values mapped to environment variables
347280

348-
apiVersion: v1
349-
kind: Pod
350-
metadata:
351-
name: my-configmap-pod
352-
spec:
353-
containers:
354-
- name: my-configmap-pod
355-
image: microsoft/windowsservercore:1709
356-
env:
357-
- name: EXAMPLE_PROPERTY_1
358-
valueFrom:
359-
configMapKeyRef:
360-
name: example-config
361-
key: example.property.1
362-
- name: EXAMPLE_PROPERTY_2
363-
valueFrom:
364-
configMapKeyRef:
365-
name: example-config
366-
key: example.property.2
367-
nodeSelector:
368-
beta.kubernetes.io/os: windows
369-
```
281+
{{< codenew file="windows/configmap-pod.yaml" >}}
370282

371283
### Volumes
372284
Some supported Volume Mounts are local, emptyDir, hostPath. One thing to remember is that paths must either be escaped, or use forward slashes, for example `mountPath: "C:\\etc\\foo"` or `mountPath: "C:/etc/foo"`.
@@ -375,76 +287,19 @@ Persistent Volume Claims are supported for supported volume types.
375287

376288
**Examples:**
377289

378-
Windows pod with a hostPath volume
379-
```yaml
380-
apiVersion: v1
381-
kind: Pod
382-
metadata:
383-
name: my-hostpath-volume-pod
384-
spec:
385-
containers:
386-
- name: my-hostpath-volume-pod
387-
image: microsoft/windowsservercore:1709
388-
volumeMounts:
389-
- name: foo
390-
mountPath: "C:\\etc\\foo"
391-
readOnly: true
392-
nodeSelector:
393-
beta.kubernetes.io/os: windows
394-
volumes:
395-
- name: foo
396-
hostPath:
397-
path: "C:\\etc\\foo"
398-
```
399-
400-
Windows pod with multiple emptyDir volumes
401-
402-
```yaml
403-
apiVersion: v1
404-
kind: Pod
405-
metadata:
406-
name: my-empty-dir-pod
407-
spec:
408-
containers:
409-
- image: microsoft/windowsservercore:1709
410-
name: my-empty-dir-pod
411-
volumeMounts:
412-
- mountPath: /cache
413-
name: cache-volume
414-
- mountPath: C:/scratch
415-
name: scratch-volume
416-
volumes:
417-
- name: cache-volume
418-
emptyDir: {}
419-
- name: scratch-volume
420-
emptyDir: {}
421-
nodeSelector:
422-
beta.kubernetes.io/os: windows
423-
```
290+
Windows pod with a hostPath volume
291+
292+
{{< codenew file="windows/hostpath-volume-pod.yaml" >}}
293+
294+
Windows pod with multiple emptyDir volumes
295+
296+
{{< codenew file="windows/emptydir-pod.yaml" >}}
424297

425298
### DaemonSets
426299

427300
DaemonSets are supported
428301

429-
```yaml
430-
apiVersion: extensions/v1beta1
431-
kind: DaemonSet
432-
metadata:
433-
name: my-DaemonSet
434-
labels:
435-
app: foo
436-
spec:
437-
template:
438-
metadata:
439-
labels:
440-
app: foo
441-
spec:
442-
containers:
443-
- name: foo
444-
image: microsoft/windowsservercore:1709
445-
nodeSelector:
446-
beta.kubernetes.io/os: windows
447-
```
302+
{{< codenew file="windows/daemonset.yaml" >}}
448303

449304
### Metrics
450305

@@ -454,53 +309,13 @@ Windows Stats use a hybrid model: pod and container level stats come from CRI (v
454309

455310
Container resources (CPU and memory) could be set now for windows containers in v1.10.
456311

457-
```yaml
458-
apiVersion: apps/v1
459-
kind: Deployment
460-
metadata:
461-
name: iis
462-
spec:
463-
replicas: 3
464-
template:
465-
metadata:
466-
labels:
467-
app: iis
468-
spec:
469-
containers:
470-
- name: iis
471-
image: microsoft/iis
472-
resources:
473-
limits:
474-
memory: "128Mi"
475-
cpu: 2
476-
ports:
477-
- containerPort: 80
478-
```
312+
{{< codenew file="windows/deploy-resource.yaml" >}}
479313

480314
### Hyper-V Containers
481315

482316
Hyper-V containers are supported as experimental in v1.10. To create a Hyper-V container, kubelet should be started with feature gates `HyperVContainer=true` and Pod should include annotation `experimental.windows.kubernetes.io/isolation-type=hyperv`.
483317

484-
```yaml
485-
apiVersion: apps/v1
486-
kind: Deployment
487-
metadata:
488-
name: iis
489-
spec:
490-
replicas: 3
491-
template:
492-
metadata:
493-
labels:
494-
app: iis
495-
annotations:
496-
experimental.windows.kubernetes.io/isolation-type: hyperv
497-
spec:
498-
containers:
499-
- name: iis
500-
image: microsoft/iis
501-
ports:
502-
- containerPort: 80
503-
```
318+
{{< codenew file="windows/deploy-hyperv.yaml" >}}
504319

505320
### Kubelet and kube-proxy can now run as Windows services
506321

content/en/docs/getting-started-guides/windows/emptydir-pod.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

content/en/docs/tutorials/hello-minikube.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ minikube dashboard
148148
The next step is to write the application. Save this code in a folder named `hellonode`
149149
with the filename `server.js`:
150150

151-
{{< code language="js" file="server.js" >}}
151+
{{< codenew language="js" file="minikube/server.js" >}}
152152

153153
Run your application:
154154

@@ -168,7 +168,7 @@ Create a file, also in the `hellonode` folder, named `Dockerfile`. A Dockerfile
168168
the image that you want to build. You can build a Docker container image by extending an
169169
existing image. The image in this tutorial extends an existing Node.js image.
170170

171-
{{< code language="conf" file="Dockerfile" >}}
171+
{{< codenew language="conf" file="minikube/Dockerfile" >}}
172172

173173
This recipe for the Docker image starts from the official Node.js LTS image
174174
found in the Docker registry, exposes port 8080, copies your `server.js` file

content/en/docs/tutorials/k8s101.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ For more information, see [Pods](/docs/concepts/workloads/pods/pod/).
3535

3636
The simplest Pod definition describes the deployment of a single container. For example, an nginx web server Pod might be defined as:
3737

38-
{{< code file="pod-nginx.yaml" >}}
38+
{{< codenew file="pods/simple-pod.yaml" >}}
3939

4040
A Pod definition is a declaration of a _desired state_. Desired state is a very important concept in the Kubernetes model. Many things present a desired state to the system, and Kubernetes' ensures that the current state matches the desired state. For example, when you create a Pod and declare that the containers in it to be running. If the containers happen not to be running because of a program failure, Kubernetes continues to (re-)create the Pod in order to drive the pod to the desired state. This process continues until you delete the Pod.
4141

@@ -44,10 +44,10 @@ For more information, see [Kubernetes Design Documents and Proposals](https://gi
4444

4545
#### Pod Management
4646

47-
Create a Pod containing an nginx server ([pod-nginx.yaml](/docs/tutorials/pod-nginx.yaml)):
47+
Create a Pod containing an nginx server ([simple-pod.yaml](/examples/pods/simple-pod.yaml)):
4848

4949
```shell
50-
$ kubectl create -f docs/tutorials/pod-nginx.yaml
50+
$ kubectl create -f https://k8s.io/examples/pods/simple-pod.yaml
5151
```
5252

5353
List all Pods:
@@ -85,27 +85,25 @@ In this example you can create a Redis Pod with a named volume, and a volume mou
8585

8686
1. Define a Volume:
8787

88-
```yaml
89-
volumes:
90-
- name: redis-persistent-storage
91-
emptyDir: {}
92-
```
93-
94-
2. Define a Volume mount within a container definition:
95-
96-
```yaml
97-
volumeMounts:
98-
   # name must match the volume name defined in volumes
99-
   - name: redis-persistent-storage
100-
# mount path within the container
101-
mountPath: /data/redis
102-
```
88+
```yaml
89+
volumes:
90+
- name: redis-storage
91+
emptyDir: {}
92+
```
10393
94+
1. Define a Volume mount within a container definition:
10495
105-
Here is an example of Redis Pod definition with a persistent storage volume ([pod-redis.yaml](/docs/tutorials/pod-redis.yaml)):
96+
```yaml
97+
volumeMounts:
98+
 # name must match the volume name defined in volumes
99+
 - name: redis-storage
100+
# mount path within the container
101+
mountPath: /data/redis
102+
```
106103
104+
Here is an example of Redis Pod definition with a persistent storage volume ([redis.yaml](/examples/pods/storage/redis.yaml)):
107105
108-
{{< code file="pod-redis.yaml" >}}
106+
{{< codenew file="pods/storage/redis.yaml" >}}
109107
110108
Where:
111109

0 commit comments

Comments
 (0)