diff --git a/guestbook-go/README.md b/guestbook-go/README.md index 299b93f3..801c4ac4 100644 --- a/guestbook-go/README.md +++ b/guestbook-go/README.md @@ -24,12 +24,12 @@ This example assumes that you have a working cluster. See the [Getting Started G ### Step One: Create the Redis master pod -Use the `examples/guestbook-go/redis-master-controller.json` file to create a [replication controller](https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/) and Redis master [pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/). The pod runs a Redis key-value server in a container. Using a replication controller is the preferred way to launch long-running pods, even for 1 replica, so that the pod benefits from the self-healing mechanism in Kubernetes (keeps the pods alive). +Use the `examples/guestbook-go/redis-master-controller.yaml` file to create a [replication controller](https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/) and Redis master [pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/). The pod runs a Redis key-value server in a container. Using a replication controller is the preferred way to launch long-running pods, even for 1 replica, so that the pod benefits from the self-healing mechanism in Kubernetes (keeps the pods alive). -1. Use the [redis-master-controller.json](redis-master-controller.json) file to create the Redis master replication controller in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command: +1. Use the [redis-master-controller.yaml](redis-master-controller.yaml) file to create the Redis master replication controller in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command: ```console - $ kubectl create -f examples/guestbook-go/redis-master-controller.json + $ kubectl create -f examples/guestbook-go/redis-master-controller.yaml ``` @@ -73,10 +73,10 @@ A Kubernetes [service](https://kubernetes.io/docs/concepts/services-networking/s Services find the pods to load balance based on pod labels. The pod that you created in Step One has the label `app=redis` and `role=master`. The selector field of the service determines which pods will receive the traffic sent to the service. -1. Use the [redis-master-service.json](redis-master-service.json) file to create the service in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command: +1. Use the [redis-master-service.yaml](redis-master-service.yaml) file to create the service in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command: ```console - $ kubectl create -f examples/guestbook-go/redis-master-service.json + $ kubectl create -f examples/guestbook-go/redis-master-service.yaml ``` @@ -96,10 +96,10 @@ Services find the pods to load balance based on pod labels. The pod that you cre The Redis master we created earlier is a single pod (REPLICAS = 1), while the Redis read replicas we are creating here are 'replicated' pods. In Kubernetes, a replication controller is responsible for managing the multiple instances of a replicated pod. -1. Use the file [redis-replica-controller.json](redis-replica-controller.json) to create the replication controller by running the `kubectl create -f` *`filename`* command: +1. Use the file [redis-replica-controller.yaml](redis-replica-controller.yaml) to create the replication controller by running the `kubectl create -f` *`filename`* command: ```console - $ kubectl create -f examples/guestbook-go/redis-replica-controller.json + $ kubectl create -f examples/guestbook-go/redis-replica-controller.yaml ``` @@ -139,10 +139,10 @@ The Redis master we created earlier is a single pod (REPLICAS = 1), while the Re Just like the master, we want to have a service to proxy connections to the read replicas. In this case, in addition to discovery, the Redis replica service provides transparent load balancing to clients. -1. Use the [redis-replica-service.json](redis-replica-service.json) file to create the Redis replica service by running the `kubectl create -f` *`filename`* command: +1. Use the [redis-replica-service.yaml](redis-replica-service.yaml) file to create the Redis replica service by running the `kubectl create -f` *`filename`* command: ```console - $ kubectl create -f examples/guestbook-go/redis-replica-service.json + $ kubectl create -f examples/guestbook-go/redis-replica-service.yaml ``` @@ -164,14 +164,14 @@ Tip: It is helpful to set labels on your services themselves--as we've done here This is a simple Go `net/http` ([negroni](https://github.com/codegangsta/negroni) based) server that is configured to talk to either the replica or master services depending on whether the request is a read or a write. The pods we are creating expose a simple JSON interface and serves a jQuery-Ajax based UI. Like the Redis replica pods, these pods are also managed by a replication controller. -1. Use the [guestbook-controller.json](guestbook-controller.json) file to create the guestbook replication controller by running the `kubectl create -f` *`filename`* command: +1. Use the [guestbook-controller.yaml](guestbook-controller.yaml) file to create the guestbook replication controller by running the `kubectl create -f` *`filename`* command: ```console - $ kubectl create -f examples/guestbook-go/guestbook-controller.json + $ kubectl create -f examples/guestbook-go/guestbook-controller.yaml ``` - Tip: If you want to modify the guestbook code open the `_src` of this example and read the README.md and the Makefile. If you have pushed your custom image be sure to update the `image` accordingly in the guestbook-controller.json. + Tip: If you want to modify the guestbook code open the `_src` of this example and read the README.md and the Makefile. If you have pushed your custom image be sure to update the `image` accordingly in the guestbook-controller.yaml. 2. To verify that the guestbook replication controller is running, run the `kubectl get rc` command: @@ -204,10 +204,10 @@ This is a simple Go `net/http` ([negroni](https://github.com/codegangsta/negroni Just like the others, we create a service to group the guestbook pods but this time, to make the guestbook front end externally visible, we specify `"type": "LoadBalancer"`. -1. Use the [guestbook-service.json](guestbook-service.json) file to create the guestbook service by running the `kubectl create -f` *`filename`* command: +1. Use the [guestbook-service.yaml](guestbook-service.yaml) file to create the guestbook service by running the `kubectl create -f` *`filename`* command: ```console - $ kubectl create -f examples/guestbook-go/guestbook-service.json + $ kubectl create -f examples/guestbook-go/guestbook-service.yaml ``` diff --git a/guestbook-go/guestbook-controller.json b/guestbook-go/guestbook-controller.json deleted file mode 100644 index 0e3553c8..00000000 --- a/guestbook-go/guestbook-controller.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "kind":"ReplicationController", - "apiVersion":"v1", - "metadata":{ - "name":"guestbook", - "labels":{ - "app":"guestbook" - } - }, - "spec":{ - "replicas":3, - "selector":{ - "app":"guestbook" - }, - "template":{ - "metadata":{ - "labels":{ - "app":"guestbook" - } - }, - "spec":{ - "containers":[ - { - "name":"guestbook", - "image":"k8s.gcr.io/guestbook:v3", - "ports":[ - { - "name":"http-server", - "containerPort":3000 - } - ] - } - ] - } - } - } -} diff --git a/guestbook-go/guestbook-controller.yaml b/guestbook-go/guestbook-controller.yaml new file mode 100644 index 00000000..ab81bbd3 --- /dev/null +++ b/guestbook-go/guestbook-controller.yaml @@ -0,0 +1,21 @@ +kind: ReplicationController +apiVersion: v1 +metadata: + name: guestbook + labels: + app: guestbook +spec: + replicas: 3 + selector: + app: guestbook + template: + metadata: + labels: + app: guestbook + spec: + containers: + - name: guestbook + image: k8s.gcr.io/guestbook:v3 + ports: + - name: http-server + containerPort: 3000 diff --git a/guestbook-go/guestbook-service.json b/guestbook-go/guestbook-service.json deleted file mode 100644 index cc7640e4..00000000 --- a/guestbook-go/guestbook-service.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "kind":"Service", - "apiVersion":"v1", - "metadata":{ - "name":"guestbook", - "labels":{ - "app":"guestbook" - } - }, - "spec":{ - "ports": [ - { - "port":3000, - "targetPort":"http-server" - } - ], - "selector":{ - "app":"guestbook" - }, - "type": "LoadBalancer" - } -} diff --git a/guestbook-go/guestbook-service.yaml b/guestbook-go/guestbook-service.yaml new file mode 100644 index 00000000..677bde4e --- /dev/null +++ b/guestbook-go/guestbook-service.yaml @@ -0,0 +1,13 @@ +kind: Service +apiVersion: v1 +metadata: + name: guestbook + labels: + app: guestbook +spec: + ports: + - port: 3000 + targetPort: http-server + selector: + app: guestbook + type: LoadBalancer diff --git a/guestbook-go/redis-master-controller.json b/guestbook-go/redis-master-controller.json deleted file mode 100644 index 17042a9e..00000000 --- a/guestbook-go/redis-master-controller.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "kind":"ReplicationController", - "apiVersion":"v1", - "metadata":{ - "name":"redis-master", - "labels":{ - "app":"redis", - "role":"master" - } - }, - "spec":{ - "replicas":1, - "selector":{ - "app":"redis", - "role":"master" - }, - "template":{ - "metadata":{ - "labels":{ - "app":"redis", - "role":"master" - } - }, - "spec":{ - "containers":[ - { - "name":"redis-master", - "image":"k8s.gcr.io/redis:e2e", - "ports":[ - { - "name":"redis-server", - "containerPort":6379 - } - ] - } - ] - } - } - } -} diff --git a/guestbook-go/redis-master-controller.yaml b/guestbook-go/redis-master-controller.yaml new file mode 100644 index 00000000..0dca0f37 --- /dev/null +++ b/guestbook-go/redis-master-controller.yaml @@ -0,0 +1,24 @@ +kind: ReplicationController +apiVersion: v1 +metadata: + name: redis-master + labels: + app: redis + role: master +spec: + replicas: 1 + selector: + app: redis + role: master + template: + metadata: + labels: + app: redis + role: master + spec: + containers: + - name: redis-master + image: k8s.gcr.io/redis:e2e + ports: + - name: redis-server + containerPort: 6379 diff --git a/guestbook-go/redis-master-service.json b/guestbook-go/redis-master-service.json deleted file mode 100644 index 3a7426ea..00000000 --- a/guestbook-go/redis-master-service.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "kind":"Service", - "apiVersion":"v1", - "metadata":{ - "name":"redis-master", - "labels":{ - "app":"redis", - "role":"master" - } - }, - "spec":{ - "ports": [ - { - "port":6379, - "targetPort":"redis-server" - } - ], - "selector":{ - "app":"redis", - "role":"master" - } - } -} diff --git a/guestbook-go/redis-master-service.yaml b/guestbook-go/redis-master-service.yaml new file mode 100644 index 00000000..c69456e3 --- /dev/null +++ b/guestbook-go/redis-master-service.yaml @@ -0,0 +1,14 @@ +kind: Service +apiVersion: v1 +metadata: + name: redis-master + labels: + app: redis + role: master +spec: + ports: + - port: 6379 + targetPort: redis-server + selector: + app: redis + role: master diff --git a/guestbook-go/redis-replica-controller.json b/guestbook-go/redis-replica-controller.json deleted file mode 100644 index c460173b..00000000 --- a/guestbook-go/redis-replica-controller.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "kind":"ReplicationController", - "apiVersion":"v1", - "metadata":{ - "name":"redis-replica", - "labels":{ - "app":"redis", - "role":"replica" - } - }, - "spec":{ - "replicas":2, - "selector":{ - "app":"redis", - "role":"replica" - }, - "template":{ - "metadata":{ - "labels":{ - "app":"redis", - "role":"replica" - } - }, - "spec":{ - "containers":[ - { - "name":"redis-replica", - "image":"k8s.gcr.io/redis-slave:v2", - "ports":[ - { - "name":"redis-server", - "containerPort":6379 - } - ] - } - ] - } - } - } -} diff --git a/guestbook-go/redis-replica-controller.yaml b/guestbook-go/redis-replica-controller.yaml new file mode 100644 index 00000000..96238c21 --- /dev/null +++ b/guestbook-go/redis-replica-controller.yaml @@ -0,0 +1,24 @@ +kind: ReplicationController +apiVersion: v1 +metadata: + name: redis-replica + labels: + app: redis + role: replica +spec: + replicas: 2 + selector: + app: redis + role: replica + template: + metadata: + labels: + app: redis + role: replica + spec: + containers: + - name: redis-replica + image: k8s.gcr.io/redis-slave:v2 + ports: + - name: redis-server + containerPort: 6379 diff --git a/guestbook-go/redis-replica-service.json b/guestbook-go/redis-replica-service.json deleted file mode 100644 index 80a0c44c..00000000 --- a/guestbook-go/redis-replica-service.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "kind":"Service", - "apiVersion":"v1", - "metadata":{ - "name":"redis-replica", - "labels":{ - "app":"redis", - "role":"replica" - } - }, - "spec":{ - "ports": [ - { - "port":6379, - "targetPort":"redis-server" - } - ], - "selector":{ - "app":"redis", - "role":"replica" - } - } -} diff --git a/guestbook-go/redis-replica-service.yaml b/guestbook-go/redis-replica-service.yaml new file mode 100644 index 00000000..191db0b2 --- /dev/null +++ b/guestbook-go/redis-replica-service.yaml @@ -0,0 +1,14 @@ +kind: Service +apiVersion: v1 +metadata: + name: redis-replica + labels: + app: redis + role: replica +spec: + ports: + - port: 6379 + targetPort: redis-server + selector: + app: redis + role: replica