Consolidate YAML files [part-14] (#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.
This commit is contained in:
Qiming
2018-07-04 14:58:20 +08:00
committed by k8s-ci-robot
parent ea6004bd4f
commit 3dd65e4e95
22 changed files with 180 additions and 294 deletions
-4
View File
@@ -1,4 +0,0 @@
FROM node:6.9.2
EXPOSE 8080
COPY server.js .
CMD node server.js
+2 -2
View File
@@ -148,7 +148,7 @@ minikube dashboard
The next step is to write the application. Save this code in a folder named `hellonode`
with the filename `server.js`:
{{< code language="js" file="server.js" >}}
{{< codenew language="js" file="minikube/server.js" >}}
Run your application:
@@ -168,7 +168,7 @@ Create a file, also in the `hellonode` folder, named `Dockerfile`. A Dockerfile
the image that you want to build. You can build a Docker container image by extending an
existing image. The image in this tutorial extends an existing Node.js image.
{{< code language="conf" file="Dockerfile" >}}
{{< codenew language="conf" file="minikube/Dockerfile" >}}
This recipe for the Docker image starts from the official Node.js LTS image
found in the Docker registry, exposes port 8080, copies your `server.js` file
+18 -20
View File
@@ -35,7 +35,7 @@ For more information, see [Pods](/docs/concepts/workloads/pods/pod/).
The simplest Pod definition describes the deployment of a single container. For example, an nginx web server Pod might be defined as:
{{< code file="pod-nginx.yaml" >}}
{{< codenew file="pods/simple-pod.yaml" >}}
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.
@@ -44,10 +44,10 @@ For more information, see [Kubernetes Design Documents and Proposals](https://gi
#### Pod Management
Create a Pod containing an nginx server ([pod-nginx.yaml](/docs/tutorials/pod-nginx.yaml)):
Create a Pod containing an nginx server ([simple-pod.yaml](/examples/pods/simple-pod.yaml)):
```shell
$ kubectl create -f docs/tutorials/pod-nginx.yaml
$ kubectl create -f https://k8s.io/examples/pods/simple-pod.yaml
```
List all Pods:
@@ -85,27 +85,25 @@ In this example you can create a Redis Pod with a named volume, and a volume mou
1. Define a Volume:
```yaml
volumes:
- name: redis-persistent-storage
emptyDir: {}
```
```yaml
volumes:
- name: redis-storage
emptyDir: {}
```
2. Define a Volume mount within a container definition:
1. Define a Volume mount within a container definition:
```yaml
volumeMounts:
   # name must match the volume name defined in volumes
   - name: redis-persistent-storage
# mount path within the container
mountPath: /data/redis
```
```yaml
volumeMounts:
 # name must match the volume name defined in volumes
 - name: redis-storage
# mount path within the container
mountPath: /data/redis
```
Here is an example of Redis Pod definition with a persistent storage volume ([redis.yaml](/examples/pods/storage/redis.yaml)):
Here is an example of Redis Pod definition with a persistent storage volume ([pod-redis.yaml](/docs/tutorials/pod-redis.yaml)):
{{< code file="pod-redis.yaml" >}}
{{< codenew file="pods/storage/redis.yaml" >}}
Where:
+18 -16
View File
@@ -26,29 +26,29 @@ To add a label, add a labels section under metadata in the Pod definition:
```yaml
labels:
app: nginx
env: test
```
For example, here is the nginx Pod definition with labels ([pod-nginx-with-label.yaml](/docs/tutorials/pod-nginx-with-label.yaml)):
For example, here is the nginx Pod definition with labels ([pod-nginx.yaml](/examples/pods/pod-nginx.yaml)):
{{< code file="pod-nginx-with-label.yaml" >}}
{{< codenew file="pods/pod-nginx.yaml" >}}
Create the labeled Pod ([pod-nginx-with-label.yaml](/docs/tutorials/pod-nginx-with-label.yaml)):
Create the labeled Pod:
```shell
kubectl create -f https://k8s.io/docs/tutorials/pod-nginx-with-label.yaml
kubectl create -f https://k8s.io/examples/pods/pod-nginx.yaml
```
List all Pods with the label `app=nginx`:
List all Pods with the label `env=test`:
```shell
kubectl get pods -l app=nginx
kubectl get pods -l env=test
```
Delete the Pod by label:
```shell
kubectl delete pod -l app=nginx
kubectl delete pod -l env=test
```
For more information, see [Labels](/docs/concepts/overview/working-with-objects/labels/).
@@ -116,17 +116,17 @@ For more information, such as how to rollback Deployment changes to a previous v
Once you have a replicated set of Pods, you need an abstraction that enables connectivity between the layers of your application. For example, if you have a Deployment managing your backend jobs, you don't want to have to reconfigure your front-ends whenever you re-scale your backends. Likewise, if the Pods in your backends are scheduled (or rescheduled) onto different machines, you can't be required to re-configure your front-ends. In Kubernetes, the service abstraction achieves these goals. A service provides a way to refer to a set of Pods (selected by labels) with a single static IP address. It may also provide load balancing, if supported by the provider.
For example, here is a service that balances across the Pods created in the previous nginx Deployment example ([service.yaml](/docs/tutorials/service.yaml)):
For example, here is a service that balances across the Pods created in the previous nginx Deployment example ([service.yaml](/examples/service/nginx-service.yaml)):
{{< code file="service.yaml" >}}
{{< codenew file="service/nginx-service.yaml" >}}
### Service Management
Create an nginx service ([service.yaml](/docs/tutorials/service.yaml)):
Create an nginx Service:
```shell
kubectl create -f https://k8s.io/docs/tutorials/service.yaml
kubectl create -f https://k8s.io/examples/service/nginx-service.yaml
```
List all services:
@@ -221,13 +221,15 @@ In all cases, if the Kubelet discovers a failure the container is restarted.
The container health checks are configured in the `livenessProbe` section of your container config. There you can also specify an `initialDelaySeconds` that is a grace period from when the container is started to when health checks are performed, to enable your container to perform any necessary initialization.
Here is an example config for a Pod with an HTTP health check ([pod-with-http-healthcheck.yaml](/docs/tutorials/pod-with-http-healthcheck.yaml)):
Here is an example config for a Pod with an HTTP health check
([pod-with-http-healthcheck.yaml](/examples/pods/probe/pod-with-http-healthcheck.yaml)):
{{< code file="pod-with-http-healthcheck.yaml" >}}
{{< codenew file="pods/probe/pod-with-http-healthcheck.yaml" >}}
And here is an example config for a Pod with a TCP Socket health check ([pod-with-tcp-socket-healthcheck.yaml](/docs/tutorials/pod-with-tcp-socket-healthcheck.yaml)):
And here is an example config for a Pod with a TCP Socket health check
([pod-with-tcp-socket-healthcheck.yaml](/examples/pods/probe/pod-with-tcp-socket-healthcheck.yaml)):
{{< code file="pod-with-tcp-socket-healthcheck.yaml" >}}
{{< codenew file="pods/probe/pod-with-tcp-socket-healthcheck.yaml" >}}
For more information about health checking, see [Container Probes](/docs/user-guide/pod-states/#container-probes).
@@ -1,12 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
-10
View File
@@ -1,10 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
-14
View File
@@ -1,14 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: redis
spec:
containers:
- name: redis
image: redis
volumeMounts:
- name: redis-persistent-storage
mountPath: /data/redis
volumes:
- name: redis-persistent-storage
emptyDir: {}
@@ -1,20 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-http-healthcheck
spec:
containers:
- name: nginx
image: nginx
# defines the health checking
livenessProbe:
# an http probe
httpGet:
path: /_status/healthz
port: 80
# length of time to wait for a pod to initialize
# after pod startup, before applying health checking
initialDelaySeconds: 30
timeoutSeconds: 1
ports:
- containerPort: 80
@@ -1,19 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-tcp-socket-healthcheck
spec:
containers:
- name: redis
image: redis
# defines the health checking
livenessProbe:
# a TCP socket probe
tcpSocket:
port: 6379
# length of time to wait for a pod to initialize
# after pod startup, before applying health checking
initialDelaySeconds: 30
timeoutSeconds: 1
ports:
- containerPort: 6379
-9
View File
@@ -1,9 +0,0 @@
var http = require('http');
var handleRequest = function(request, response) {
console.log('Received request for URL: ' + request.url);
response.writeHead(200);
response.end('Hello World!');
};
var www = http.createServer(handleRequest);
www.listen(8080);
-16
View File
@@ -1,16 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
ports:
- port: 8000 # the port that this service should serve on
# the container on each pod to connect to, can be a name
# (e.g. 'www') or a number (e.g. 80)
targetPort: 80
protocol: TCP
# just like the selector in the deployment,
# but this time it identifies the set of pods to load balance
# traffic to.
selector:
app: nginx