Consolidate YAML files [part-12] (#9364)

* Consolidate YAML files [part-12]

Relocate YAML files referenced by the accessing application topic
and the rest of cluster administration.

* Adjust json shortcodes.
This commit is contained in:
Qiming
2018-07-04 14:19:23 +08:00
committed by k8s-ci-robot
parent aed6732b4e
commit ea6004bd4f
29 changed files with 118 additions and 251 deletions
@@ -27,7 +27,7 @@ In this exercise, you create a Pod that runs two Containers. The two containers
share a Volume that they can use to communicate. Here is the configuration file
for the Pod:
{{< code file="two-container-pod.yaml" >}}
{{< codenew file="pods/two-container-pod.yaml" >}}
In the configuration file, you can see that the Pod has a Volume named
`shared-data`.
@@ -44,7 +44,7 @@ directory of the nginx server.
Create the Pod and the two Containers:
kubectl create -f https://k8s.io/docs/tasks/access-application-cluster/two-container-pod.yaml
kubectl create -f https://k8s.io/examples/pods/two-container-pod.yaml
View information about the Pod and the Containers:
@@ -43,12 +43,12 @@ frontend and backend are connected using a Kubernetes Service object.
The backend is a simple hello greeter microservice. Here is the configuration
file for the backend Deployment:
{{< code file="hello.yaml" >}}
{{< codenew file="service/access/hello.yaml" >}}
Create the backend Deployment:
```
kubectl create -f https://k8s.io/docs/tasks/access-application-cluster/hello.yaml
kubectl create -f https://k8s.io/examples/service/access/hello.yaml
```
View information about the backend Deployment:
@@ -103,7 +103,7 @@ selector labels to find the Pods that it routes traffic to.
First, explore the Service configuration file:
{{< code file="hello-service.yaml" >}}
{{< codenew file="service/access/hello-service.yaml" >}}
In the configuration file, you can see that the Service routes traffic to Pods
that have the labels `app: hello` and `tier: backend`.
@@ -111,7 +111,7 @@ that have the labels `app: hello` and `tier: backend`.
Create the `hello` Service:
```
kubectl create -f https://k8s.io/docs/tasks/access-application-cluster/hello-service.yaml
kubectl create -f https://k8s.io/examples/service/access/hello-service.yaml
```
At this point, you have a backend Deployment running, and you have a
@@ -127,18 +127,18 @@ of the `name` field in the preceding Service configuration file.
The Pods in the frontend Deployment run an nginx image that is configured
to find the hello backend Service. Here is the nginx configuration file:
{{< code file="frontend/frontend.conf" >}}
{{< codenew file="service/access/frontend.conf" >}}
Similar to the backend, the frontend has a Deployment and a Service. The
configuration for the Service has `type: LoadBalancer`, which means that
the Service uses the default load balancer of your cloud provider.
{{< code file="frontend.yaml" >}}
{{< codenew file="service/access/frontend.yaml" >}}
Create the frontend Deployment and Service:
```
kubectl create -f https://k8s.io/docs/tasks/access-application-cluster/frontend.yaml
kubectl create -f https://k8s.io/examples/service/access/frontend.yaml
```
The output verifies that both resources were created:
@@ -149,7 +149,7 @@ service "frontend" created
```
**Note**: The nginx configuration is baked into the
[container image](/docs/tasks/access-application-cluster/frontend/Dockerfile).
[container image](/examples/service/access/Dockerfile).
A better way to do this would be to use a
[ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/), so
that you can change the configuration more easily.
@@ -1,39 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
selector:
app: hello
tier: frontend
ports:
- protocol: "TCP"
port: 80
targetPort: 80
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
selector:
matchLabels:
app: hello
tier: frontend
track: stable
replicas: 1
template:
metadata:
labels:
app: hello
tier: frontend
track: stable
spec:
containers:
- name: nginx
image: "gcr.io/google-samples/hello-frontend:1.0"
lifecycle:
preStop:
exec:
command: ["/usr/sbin/nginx","-s","quit"]
@@ -1,4 +0,0 @@
FROM nginx:1.9.14
RUN rm /etc/nginx/conf.d/default.conf
COPY frontend.conf /etc/nginx/conf.d
@@ -1,11 +0,0 @@
upstream hello {
server hello;
}
server {
listen 80;
location / {
proxy_pass http://hello;
}
}
@@ -1,12 +0,0 @@
kind: Service
apiVersion: v1
metadata:
name: hello
spec:
selector:
app: hello
tier: backend
ports:
- protocol: TCP
port: 80
targetPort: http
@@ -1,24 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
spec:
selector:
matchLabels:
app: hello
tier: backend
track: stable
replicas: 7
template:
metadata:
labels:
app: hello
tier: backend
track: stable
spec:
containers:
- name: hello
image: "gcr.io/google-samples/hello-go-gke:1.0"
ports:
- name: http
containerPort: 80
@@ -1,4 +0,0 @@
FROM alpine:3.1
MAINTAINER Carter Morgan <askcarter@google.com>
COPY hello /usr/bin/
CMD ["/usr/bin/hello"]
@@ -1,7 +0,0 @@
Build hello go binary first
go build -tags netgo -ldflags "-extldflags '-lm -lstdc++ -static'" .
Then build docker image
docker build -t hello .
@@ -1,74 +0,0 @@
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/braintree/manners"
"github.com/GoogleCloudPlatform/kubernetes-workshops/bundles/kubernetes-101/workshop/app/handlers"
"github.com/GoogleCloudPlatform/kubernetes-workshops/bundles/kubernetes-101/workshop/app/health"
)
const version = "1.0.0"
func main() {
var (
httpAddr = flag.String("http", "0.0.0.0:80", "HTTP service address.")
healthAddr = flag.String("health", "0.0.0.0:81", "Health service address.")
)
flag.Parse()
log.Println("Starting server...")
log.Printf("Health service listening on %s", *healthAddr)
log.Printf("HTTP service listening on %s", *httpAddr)
errChan := make(chan error, 10)
hmux := http.NewServeMux()
hmux.HandleFunc("/healthz", health.HealthzHandler)
hmux.HandleFunc("/readiness", health.ReadinessHandler)
hmux.HandleFunc("/healthz/status", health.HealthzStatusHandler)
hmux.HandleFunc("/readiness/status", health.ReadinessStatusHandler)
healthServer := manners.NewServer()
healthServer.Addr = *healthAddr
healthServer.Handler = handlers.LoggingHandler(hmux)
go func() {
errChan <- healthServer.ListenAndServe()
}()
mux := http.NewServeMux()
mux.HandleFunc("/", handlers.HelloHandler)
mux.Handle("/secure", handlers.JWTAuthHandler(handlers.HelloHandler))
mux.Handle("/version", handlers.VersionHandler(version))
httpServer := manners.NewServer()
httpServer.Addr = *httpAddr
httpServer.Handler = handlers.LoggingHandler(mux)
go func() {
errChan <- httpServer.ListenAndServe()
}()
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
for {
select {
case err := <-errChan:
if err != nil {
log.Fatal(err)
}
case s := <-signalChan:
log.Println(fmt.Sprintf("Captured %v. Exiting...", s))
health.SetReadinessStatus(http.StatusServiceUnavailable)
httpServer.BlockingClose()
os.Exit(0)
}
}
}
@@ -1,33 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
labels:
name: redis
redis-sentinel: "true"
role: master
name: redis-master
spec:
containers:
- name: master
image: k8s.gcr.io/redis:v1
env:
- name: MASTER
value: "true"
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.1"
volumeMounts:
- mountPath: /redis-master-data
name: data
- name: sentinel
image: kubernetes/redis:v1
env:
- name: SENTINEL
value: "true"
ports:
- containerPort: 26379
volumes:
- name: data
emptyDir: {}
@@ -1,27 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: two-containers
spec:
restartPolicy: Never
volumes:
- name: shared-data
emptyDir: {}
containers:
- name: nginx-container
image: nginx
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html
- name: debian-container
image: debian
volumeMounts:
- name: shared-data
mountPath: /pod-data
command: ["/bin/sh"]
args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]