Skip to content

Commit 180798c

Browse files
committed
Use example syncer tags instead of hard-coded examples in doc
1 parent 2bd5311 commit 180798c

File tree

22 files changed

+306
-104
lines changed

22 files changed

+306
-104
lines changed

cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ spec:
1212
cpu: 100m
1313
memory: 200Mi
1414
env:
15-
- name: "FLUENTD_ARGS"
16-
value: "-qq"
15+
- name: FLUENTD_ARGS
16+
value: -qq
1717
volumeMounts:
1818
- name: varlog
1919
mountPath: /varlog

cmd/mungedocs/example_syncer.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ func exampleContent(filePath, linkPath, fileType string) (content string, err er
6363
if err != nil {
6464
return content, err
6565
}
66-
content = fmt.Sprintf("\n```%s\n%s\n```\n\n[Download example](%s)", fileType, string(dat), linkPath)
66+
// remove leading and trailing spaces and newlines
67+
trimmedFileContent := strings.TrimSpace(string(dat))
68+
content = fmt.Sprintf("\n```%s\n%s\n```\n\n[Download example](%s)", fileType, trimmedFileContent, linkPath)
6769
return
6870
}
6971

docs/admin/namespaces/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Let's create two new namespaces to hold our work.
8383

8484
Use the file [`namespace-dev.json`](namespace-dev.json) which describes a development namespace:
8585

86+
<!-- BEGIN MUNGE: EXAMPLE namespace-dev.json -->
87+
8688
```json
8789
{
8890
"kind": "Namespace",
@@ -96,6 +98,9 @@ Use the file [`namespace-dev.json`](namespace-dev.json) which describes a develo
9698
}
9799
```
98100

101+
[Download example](namespace-dev.json)
102+
<!-- END MUNGE: EXAMPLE -->
103+
99104
Create the development namespace using kubectl.
100105

101106
```console

docs/getting-started-guides/logging.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,24 @@ This diagram shows four nodes created on a Google Compute Engine cluster with th
5858

5959
To help explain how cluster level logging works let’s start off with a synthetic log generator pod specification [counter-pod.yaml](../../examples/blog-logging/counter-pod.yaml):
6060

61+
<!-- BEGIN MUNGE: EXAMPLE ../../examples/blog-logging/counter-pod.yaml -->
62+
6163
```yaml
62-
apiVersion: v1
63-
kind: Pod
64-
metadata:
65-
name: counter
66-
namespace: default
67-
spec:
68-
containers:
69-
- name: count
70-
image: ubuntu:14.04
71-
args: [bash, -c,
72-
'for ((i = 0; ; i++)); do echo "$i: $(date)"; sleep 1; done']
64+
apiVersion: v1
65+
kind: Pod
66+
metadata:
67+
name: counter
68+
spec:
69+
containers:
70+
- name: count
71+
image: ubuntu:14.04
72+
args: [bash, -c,
73+
'for ((i = 0; ; i++)); do echo "$i: $(date)"; sleep 1; done']
7374
```
7475

76+
[Download example](../../examples/blog-logging/counter-pod.yaml)
77+
<!-- END MUNGE: EXAMPLE -->
78+
7579
This pod specification has one container which runs a bash script when the container is born. This script simply writes out the value of a counter and the date once per second and runs indefinitely. Let’s create the pod in the default
7680
namespace.
7781

@@ -152,7 +156,9 @@ We’ve lost the log lines from the first invocation of the container in this po
152156

153157
When a Kubernetes cluster is created with logging to Google Cloud Logging enabled, the system creates a pod called `fluentd-cloud-logging` on each node of the cluster to collect Docker container logs. These pods were shown at the start of this blog article in the response to the first get pods command.
154158

155-
This log collection pod has a specification which looks something like this [fluentd-gcp.yaml](http://releases.k8s.io/HEAD/cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml):
159+
This log collection pod has a specification which looks something like this:
160+
161+
<!-- BEGIN MUNGE: EXAMPLE ../../cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml -->
156162

157163
```yaml
158164
apiVersion: v1
@@ -163,19 +169,31 @@ metadata:
163169
spec:
164170
containers:
165171
- name: fluentd-cloud-logging
166-
image: gcr.io/google_containers/fluentd-gcp:1.6
172+
image: gcr.io/google_containers/fluentd-gcp:1.9
173+
resources:
174+
limits:
175+
cpu: 100m
176+
memory: 200Mi
167177
env:
168178
- name: FLUENTD_ARGS
169179
value: -qq
170180
volumeMounts:
181+
- name: varlog
182+
mountPath: /varlog
171183
- name: containers
172184
mountPath: /var/lib/docker/containers
173185
volumes:
186+
- name: varlog
187+
hostPath:
188+
path: /var/log
174189
- name: containers
175190
hostPath:
176191
path: /var/lib/docker/containers
177192
```
178193
194+
[Download example](../../cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml)
195+
<!-- END MUNGE: EXAMPLE -->
196+
179197
This pod specification maps the directory on the host containing the Docker log files, `/var/lib/docker/containers`, to a directory inside the container which has the same path. The pod runs one image, `gcr.io/google_containers/fluentd-gcp:1.6`, which is configured to collect the Docker log files from the logs directory and ingest them into Google Cloud Logging. One instance of this pod runs on each node of the cluster. Kubernetes will notice if this pod fails and automatically restart it.
180198

181199
We can click on the Logs item under the Monitoring section of the Google Developer Console and select the logs for the counter container, which will be called kubernetes.counter_default_count. This identifies the name of the pod (counter), the namespace (default) and the name of the container (count) for which the log collection occurred. Using this name we can select just the logs for our counter container from the drop down menu:

docs/user-guide/downward-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ environment variable they want.
8080
This is an example of a pod that consumes its name and namespace via the
8181
downward API:
8282

83+
<!-- BEGIN MUNGE: EXAMPLE downward-api/dapi-pod.yaml -->
84+
8385
```yaml
8486
apiVersion: v1
8587
kind: Pod
@@ -102,6 +104,9 @@ spec:
102104
restartPolicy: Never
103105
```
104106
107+
[Download example](downward-api/dapi-pod.yaml)
108+
<!-- END MUNGE: EXAMPLE -->
109+
105110
Some more thorough examples:
106111
* [environment variables](environment-guide/)
107112
* [downward API](downward-api/)

docs/user-guide/downward-api/dapi-pod.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ spec:
88
image: gcr.io/google_containers/busybox
99
command: [ "/bin/sh", "-c", "env" ]
1010
env:
11-
- name: POD_NAME
11+
- name: MY_POD_NAME
1212
valueFrom:
1313
fieldRef:
1414
fieldPath: metadata.name
15-
- name: POD_NAMESPACE
15+
- name: MY_POD_NAMESPACE
1616
valueFrom:
1717
fieldRef:
1818
fieldPath: metadata.namespace

docs/user-guide/logging.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,24 @@ The logs of a running container may be fetched using the command `kubectl logs`.
4343
this pod specification [counter-pod.yaml](../../examples/blog-logging/counter-pod.yaml), which has a container which writes out some text to standard
4444
output every second. (You can find different pod specifications [here](logging-demo/).)
4545

46+
<!-- BEGIN MUNGE: EXAMPLE ../../examples/blog-logging/counter-pod.yaml -->
47+
4648
```yaml
47-
apiVersion: v1
48-
kind: Pod
49-
metadata:
50-
name: counter
51-
spec:
52-
containers:
53-
- name: count
54-
image: ubuntu:14.04
55-
args: [bash, -c,
56-
'for ((i = 0; ; i++)); do echo "$i: $(date)"; sleep 1; done']
49+
apiVersion: v1
50+
kind: Pod
51+
metadata:
52+
name: counter
53+
spec:
54+
containers:
55+
- name: count
56+
image: ubuntu:14.04
57+
args: [bash, -c,
58+
'for ((i = 0; ; i++)); do echo "$i: $(date)"; sleep 1; done']
5759
```
5860

61+
[Download example](../../examples/blog-logging/counter-pod.yaml)
62+
<!-- END MUNGE: EXAMPLE -->
63+
5964
we can run the pod:
6065

6166
```console

docs/user-guide/pod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Pod
33
metadata:
44
name: nginx
55
labels:
6-
name: nginx
6+
app: nginx
77
spec:
88
containers:
99
- name: nginx

docs/user-guide/simple-yaml.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ $ kubectl create -f ./pod.yaml
4747

4848
Where pod.yaml contains something like:
4949

50+
<!-- BEGIN MUNGE: EXAMPLE pod.yaml -->
51+
5052
```yaml
5153
apiVersion: v1
5254
kind: Pod
@@ -62,6 +64,9 @@ spec:
6264
- containerPort: 80
6365
```
6466
67+
[Download example](pod.yaml)
68+
<!-- END MUNGE: EXAMPLE -->
69+
6570
You can see your cluster's pods:
6671
6772
```console
@@ -87,6 +92,8 @@ $ kubectl create -f ./replication.yaml
8792

8893
Where `replication.yaml` contains:
8994

95+
<!-- BEGIN MUNGE: EXAMPLE replication.yaml -->
96+
9097
```yaml
9198
apiVersion: v1
9299
kind: ReplicationController
@@ -109,6 +116,9 @@ spec:
109116
- containerPort: 80
110117
```
111118
119+
[Download example](replication.yaml)
120+
<!-- END MUNGE: EXAMPLE -->
121+
112122
To delete the replication controller (and the pods it created):
113123
114124
```console

docs/user-guide/walkthrough/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ For this example we'll be creating a Redis pod with a named volume and volume mo
146146
147147
Example Redis pod definition with a persistent storage volume ([pod-redis.yaml](pod-redis.yaml)):
148148
149+
<!-- BEGIN MUNGE: EXAMPLE pod-redis.yaml -->
150+
149151
```yaml
150152
apiVersion: v1
151153
kind: Pod
@@ -163,6 +165,9 @@ spec:
163165
emptyDir: {}
164166
```
165167
168+
[Download example](pod-redis.yaml)
169+
<!-- END MUNGE: EXAMPLE -->
170+
166171
Notes:
167172
- The volume mount name is a reference to a specific empty dir volume.
168173
- The volume mount path is the path to mount the empty dir volume within the container.

0 commit comments

Comments
 (0)