Note that we omit the labels and the selector fields of the replication controller, because they will be populated from the labels field of the pod template by default.
Note that we omit the labels and the selector fields of the replication controller, because they will be populated from the labels field of the pod template by default.
This will spin up 24 instances of the test. They will run to completion, then exit, and the kubelet will restart them, accumulating more and more runs of the test.
This will spin up 24 instances of the test. They will run to completion, then exit, and the kubelet will restart them, accumulating more and more runs of the test.
You can examine the recent runs of the test by calling ```docker ps -a``` and looking for tasks that exited with non-zero exit codes. Unfortunately, docker ps -a only keeps around the exit status of the last 15-20 containers with the same image, so you have to check them frequently.
You can examine the recent runs of the test by calling ```docker ps -a``` and looking for tasks that exited with non-zero exit codes. Unfortunately, docker ps -a only keeps around the exit status of the last 15-20 containers with the same image, so you have to check them frequently.
...
@@ -52,7 +54,7 @@ grep "Exited ([^0])" output.txt
...
@@ -52,7 +54,7 @@ grep "Exited ([^0])" output.txt
Eventually you will have sufficient runs for your purposes. At that point you can stop and delete the replication controller by running:
Eventually you will have sufficient runs for your purposes. At that point you can stop and delete the replication controller by running:
If you do a final check for flakes with ```docker ps -a```, ignore tasks that exited -1, since that's what happens when you stop the replication controller.
If you do a final check for flakes with ```docker ps -a```, ignore tasks that exited -1, since that's what happens when you stop the replication controller.
@@ -7,7 +7,7 @@ Kubernetes has an extensible user interface with default functionality that desc
...
@@ -7,7 +7,7 @@ Kubernetes has an extensible user interface with default functionality that desc
Assuming that you have a cluster running locally at `localhost:8080`, as described [here](getting-started-guides/locally.md), you can run the UI against it with kubectl:
Assuming that you have a cluster running locally at `localhost:8080`, as described [here](getting-started-guides/locally.md), you can run the UI against it with kubectl:
**NOTE**: If you're running Kubernetes from source, you can use `cluster/kubectl.sh` instead of `kubectl`.
This service allows other pods to connect to the rabbitmq. To them, it will be seen as available on port 5672, although the service is routing the traffic to the container (also via port 5672).
This service allows other pods to connect to the rabbitmq. To them, it will be seen as available on port 5672, although the service is routing the traffic to the container (also via port 5672).
Use the file [`examples/cluster-dns/dns-backend-rc.yaml`](dns-backend-rc.yaml) to create a backend server [replication controller](../../docs/replication-controller.md) in each namespace.
Use the file [`examples/cluster-dns/dns-backend-rc.yaml`](dns-backend-rc.yaml) to create a backend server [replication controller](../../docs/replication-controller.md) in each namespace.
Use the file [`examples/cluster-dns/dns-frontend-pod.yaml`](dns-frontend-pod.yaml) to create a client [pod](../../docs/pods.md) in dev namespace. The client pod will make a connection to backend and exit. Specifically, it tries to connect to address `http://dns-backend.development.kubernetes.local:8000`.
Use the file [`examples/cluster-dns/dns-frontend-pod.yaml`](dns-frontend-pod.yaml) to create a client [pod](../../docs/pods.md) in dev namespace. The client pod will make a connection to backend and exit. Specifically, it tries to connect to address `http://dns-backend.development.kubernetes.local:8000`.
Please refer to the [source code](./images/frontend/client.py) about the logs. First line prints out the ip address associated with the service in dev namespace; remaining lines print out our request and server response. If we switch to prod namespace with the same pod config, we'll see the same result, i.e. dns will resolve across namespace.
Please refer to the [source code](./images/frontend/client.py) about the logs. First line prints out the ip address associated with the service in dev namespace; remaining lines print out our request and server response. If we switch to prod namespace with the same pod config, we'll see the same result, i.e. dns will resolve across namespace.
List pods in cluster to verify the master is running. You'll see a single redis master pod. It will also display the machine that the pod is running on once it gets placed (may take up to thirty seconds).
List pods in cluster to verify the master is running. You'll see a single redis master pod. It will also display the machine that the pod is running on once it gets placed (may take up to thirty seconds).
```shell
```shell
$ cluster/kubectl.sh get pods
$ kubectl get pods
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED MESSAGE
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED MESSAGE
@@ -55,9 +55,9 @@ A Kubernetes '[service](../../docs/services.md)' is a named load balancer that p
...
@@ -55,9 +55,9 @@ A Kubernetes '[service](../../docs/services.md)' is a named load balancer that p
The pod that you created in Step One has the label `name=redis` and `role=master`. The selector field of the service determines which pods will receive the traffic sent to the service. Use the file `examples/guestbook-go/redis-master-service.json` to create the service in the `kubectl` cli:
The pod that you created in Step One has the label `name=redis` and `role=master`. The selector field of the service determines which pods will receive the traffic sent to the service. Use the file `examples/guestbook-go/redis-master-service.json` to create the service in the `kubectl` cli:
@@ -157,9 +157,9 @@ You will see a single redis master pod, two redis slaves, and three guestbook po
...
@@ -157,9 +157,9 @@ You will see a single redis master pod, two redis slaves, and three guestbook po
Just like the others, you want a service to group your guestbook pods. The service specification for the guestbook is in `examples/guestbook-go/guestbook-service.json`. There's a twist this time - because we want it to be externally visible, we set the `createExternalLoadBalancer` flag on the service.
Just like the others, you want a service to group your guestbook pods. The service specification for the guestbook is in `examples/guestbook-go/guestbook-service.json`. There's a twist this time - because we want it to be externally visible, we set the `createExternalLoadBalancer` flag on the service.
To play with the service itself, find the external IP of the load balancer:
To play with the service itself, find the external IP of the load balancer:
```shell
```shell
$ cluster/kubectl.sh get services guestbook -o template --template='{{(index .status.loadBalancer.ingress 0).ip}}'
$ kubectl get services guestbook -o template --template='{{(index .status.loadBalancer.ingress 0).ip}}'
104.154.63.66$
104.154.63.66$
```
```
and then visit port 3000 of that IP address e.g. `http://104.154.63.66:3000`.
and then visit port 3000 of that IP address e.g. `http://104.154.63.66:3000`.
...
@@ -190,7 +190,7 @@ For details about limiting traffic to specific sources, see the [GCE firewall do
...
@@ -190,7 +190,7 @@ For details about limiting traffic to specific sources, see the [GCE firewall do
You should delete the service which will remove any associated resources that were created e.g. load balancers, forwarding rules and target pools. All the resources (replication controllers and service) can be deleted with a single command:
You should delete the service which will remove any associated resources that were created e.g. load balancers, forwarding rules and target pools. All the resources (replication controllers and service) can be deleted with a single command:
@@ -12,8 +12,6 @@ The web front end interacts with the redis master via javascript redis API calls
...
@@ -12,8 +12,6 @@ The web front end interacts with the redis master via javascript redis API calls
This example requires a kubernetes cluster. See the [Getting Started guides](../../docs/getting-started-guides) for how to get started.
This example requires a kubernetes cluster. See the [Getting Started guides](../../docs/getting-started-guides) for how to get started.
If you are running from source, replace commands such as `kubectl` below with calls to `cluster/kubectl.sh`.
### Step One: Fire up the redis master
### Step One: Fire up the redis master
Note: This redis-master is *not* highly available. Making it highly available would be a very interesting, but intricate exercise - redis doesn't actually support multi-master deployments at the time of this writing, so high availability would be a somewhat tricky thing to implement, and might involve periodic serialization to disk, and so on.
Note: This redis-master is *not* highly available. Making it highly available would be a very interesting, but intricate exercise - redis doesn't actually support multi-master deployments at the time of this writing, so high availability would be a somewhat tricky thing to implement, and might involve periodic serialization to disk, and so on.
...
@@ -252,7 +250,7 @@ The service specification for the slaves is in `examples/guestbook/redis-slave-s
...
@@ -252,7 +250,7 @@ The service specification for the slaves is in `examples/guestbook/redis-slave-s
}
}
```
```
This time the selector for the service is `name=redis-slave`, because that identifies the pods running redis slaves. It may also be helpful to set labels on your service itself as we've done here to make it easy to locate them with the `cluster/kubectl.sh get services -l "label=value"` command.
This time the selector for the service is `name=redis-slave`, because that identifies the pods running redis slaves. It may also be helpful to set labels on your service itself as we've done here to make it easy to locate them with the `kubectl get services -l "label=value"` command.
Now that you have created the service specification, create it in your cluster by running:
Now that you have created the service specification, create it in your cluster by running:
To be sure things are right, let's list all of the namespaces in our cluster.
To be sure things are right, let's list all of the namespaces in our cluster.
```shell
```shell
$ cluster/kubectl.sh get namespaces
$ kubectl get namespaces
NAME LABELS STATUS
NAME LABELS STATUS
default <none> Active
default <none> Active
development name=development Active
development name=development Active
...
@@ -126,8 +126,8 @@ users:
...
@@ -126,8 +126,8 @@ users:
The next step is to define a context for the kubectl client to work in each namespace. The value of "cluster" and "user" fields are copied from the current context.
The next step is to define a context for the kubectl client to work in each namespace. The value of "cluster" and "user" fields are copied from the current context.
```shell
```shell
$ cluster/kubectl.sh config set-context dev --namespace=development --cluster=lithe-cocoa-92103_kubernetes --user=lithe-cocoa-92103_kubernetes
$ kubectl config set-context dev --namespace=development --cluster=lithe-cocoa-92103_kubernetes --user=lithe-cocoa-92103_kubernetes
The above commands provided two request contexts you can alternate against depending on what namespace you
The above commands provided two request contexts you can alternate against depending on what namespace you
...
@@ -136,13 +136,13 @@ wish to work against.
...
@@ -136,13 +136,13 @@ wish to work against.
Let's switch to operate in the development namespace.
Let's switch to operate in the development namespace.
```shell
```shell
$ cluster/kubectl.sh config use-context dev
$ kubectl config use-context dev
```
```
You can verify your current context by doing the following:
You can verify your current context by doing the following:
```shell
```shell
$ cluster/kubectl.sh config view
$ kubectl config view
apiVersion: v1
apiVersion: v1
clusters:
clusters:
- cluster:
- cluster:
...
@@ -184,17 +184,17 @@ At this point, all requests we make to the Kubernetes cluster from the command l
...
@@ -184,17 +184,17 @@ At this point, all requests we make to the Kubernetes cluster from the command l
Let's create some content.
Let's create some content.
```shell
```shell
$ cluster/kubectl.sh run snowflake --image=kubernetes/serve_hostname --replicas=2
$ kubectl run snowflake --image=kubernetes/serve_hostname --replicas=2
```
```
We have just created a replication controller whose replica size is 2 that is running the pod called snowflake with a basic container that just serves the hostname.
We have just created a replication controller whose replica size is 2 that is running the pod called snowflake with a basic container that just serves the hostname.
@@ -21,7 +21,7 @@ gcloud config set project <project-name>
...
@@ -21,7 +21,7 @@ gcloud config set project <project-name>
Next, grab the Kubernetes [release binary](https://github.com/GoogleCloudPlatform/kubernetes/releases) and start up a Kubernetes cluster:
Next, grab the Kubernetes [release binary](https://github.com/GoogleCloudPlatform/kubernetes/releases) and start up a Kubernetes cluster:
```
```
$ <kubernetes>/cluster/kube-up.sh
$ cluster/kube-up.sh
```
```
where `<kubernetes>` is the path to your Kubernetes installation.
where `<kubernetes>` is the path to your Kubernetes installation.
...
@@ -104,14 +104,14 @@ Note that we've defined a volume mount for `/var/lib/mysql`, and specified a vol
...
@@ -104,14 +104,14 @@ Note that we've defined a volume mount for `/var/lib/mysql`, and specified a vol
Once you've edited the file to set your database password, create the pod as follows, where `<kubernetes>` is the path to your Kubernetes installation:
Once you've edited the file to set your database password, create the pod as follows, where `<kubernetes>` is the path to your Kubernetes installation:
It may take a short period before the new pod reaches the `Running` state.
It may take a short period before the new pod reaches the `Running` state.
List all pods to see the status of this new pod and the cluster node that it is running on:
List all pods to see the status of this new pod and the cluster node that it is running on:
```shell
```shell
$ <kubernetes>/cluster/kubectl.sh get pods
$ kubectl get pods
```
```
...
@@ -120,7 +120,7 @@ $ <kubernetes>/cluster/kubectl.sh get pods
...
@@ -120,7 +120,7 @@ $ <kubernetes>/cluster/kubectl.sh get pods
You can take a look at the logs for a pod by using `kubectl.sh log`. For example:
You can take a look at the logs for a pod by using `kubectl.sh log`. For example:
```shell
```shell
$ <kubernetes>/cluster/kubectl.sh log mysql
$ kubectl log mysql
```
```
If you want to do deeper troubleshooting, e.g. if it seems a container is not staying up, you can also ssh in to the node that a pod is running on. There, you can run `sudo -s`, then `docker ps -a` to see all the containers. You can then inspect the logs of containers that have exited, via `docker logs <container_id>`. (You can also find some relevant logs under `/var/log`, e.g. `docker.log` and `kubelet.log`).
If you want to do deeper troubleshooting, e.g. if it seems a container is not staying up, you can also ssh in to the node that a pod is running on. There, you can run `sudo -s`, then `docker ps -a` to see all the containers. You can then inspect the logs of containers that have exited, via `docker logs <container_id>`. (You can also find some relevant logs under `/var/log`, e.g. `docker.log` and `kubelet.log`).
@@ -23,7 +23,7 @@ Once you have installed Ceph and new Kubernetes, you can create a pod based on m
...
@@ -23,7 +23,7 @@ Once you have installed Ceph and new Kubernetes, you can create a pod based on m
If Ceph authentication secret is provided, the secret should be first be base64 encoded, then encoded string is placed in a secret yaml. An example yaml is provided [here](secret/ceph-secret.yaml). Then post the secret through ```kubectl``` in the following command.
If Ceph authentication secret is provided, the secret should be first be base64 encoded, then encoded string is placed in a secret yaml. An example yaml is provided [here](secret/ceph-secret.yaml). Then post the secret through ```kubectl``` in the following command.
You can use bash job control to run this in the background (note that you must use the default port -- 8001 -- for the following demonstration to work properly). This can sometimes spew to the output so you could also run it in a different terminal.
You can use bash job control to run this in the background (note that you must use the default port -- 8001 -- for the following demonstration to work properly). This can sometimes spew to the output so you could also run it in a different terminal.
After pulling the image from the Docker Hub to your worker nodes (which may take a minute or so) you'll see a couple of squares in the UI detailing the pods that are running along with the image that they are serving up. A cute little nautilus.
After pulling the image from the Docker Hub to your worker nodes (which may take a minute or so) you'll see a couple of squares in the UI detailing the pods that are running along with the image that they are serving up. A cute little nautilus.
...
@@ -52,7 +52,7 @@ After pulling the image from the Docker Hub to your worker nodes (which may take
...
@@ -52,7 +52,7 @@ After pulling the image from the Docker Hub to your worker nodes (which may take
Now we will increase the number of replicas from two to four:
Now we will increase the number of replicas from two to four:
Having already learned about Pods and how to create them, you may be struck by an urge to create many, many pods. Please do! But eventually you will need a system to organize these pods into groups. The system for achieving this in Kubernetes is Labels. Labels are key-value pairs that are attached to each object in Kubernetes. Label selectors can be passed along with a RESTful ```list``` request to the apiserver to retrieve a list of objects which match that label selector. For example:
Having already learned about Pods and how to create them, you may be struck by an urge to create many, many pods. Please do! But eventually you will need a system to organize these pods into groups. The system for achieving this in Kubernetes is Labels. Labels are key-value pairs that are attached to each object in Kubernetes. Label selectors can be passed along with a RESTful ```list``` request to the apiserver to retrieve a list of objects which match that label selector. For example:
```sh
```sh
cluster/kubectl.sh get pods -lname=nginx
kubectl get pods -lname=nginx
```
```
Lists all pods who name label matches 'nginx'. Labels are discussed in detail [elsewhere](http://docs.k8s.io/labels.md), but they are a core concept for two additional building blocks for Kubernetes, Replication Controllers and Services
Lists all pods who name label matches 'nginx'. Labels are discussed in detail [elsewhere](http://docs.k8s.io/labels.md), but they are a core concept for two additional building blocks for Kubernetes, Replication Controllers and Services