Skip to content

Commit

Permalink
Adding Callouts and Fixing Links (#64)
Browse files Browse the repository at this point in the history
* Adding callouts and small edits for consistancy

* fixing links

* Updates per Ahmet

Changed `Replicas` to replica field
Gave excerpt highlighted syntax

* Update README.md
  • Loading branch information
cody-clark authored and ahmetb committed Aug 14, 2017
1 parent d1cab52 commit 1fe5df1
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 119 deletions.
204 changes: 91 additions & 113 deletions cassandra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Deploying stateful distributed applications, like Cassandra, within a clustered

**Cassandra Docker**

The pods use the [```gcr.io/google-samples/cassandra:v12```](https://github.com/kubernetes/examples/blob/master/cassandra/image/Dockerfile)
The Pods use the [`gcr.io/google-samples/cassandra:v12`](https://github.com/kubernetes/examples/blob/master/cassandra/image/Dockerfile)
image from Google's [container registry](https://cloud.google.com/container-registry/docs/).
The docker is based on `debian:jessie` and includes OpenJDK 8. This image includes a standard Cassandra installation from the Apache Debian repo. By using environment variables you can change values that are inserted into `cassandra.yaml`.

Expand Down Expand Up @@ -43,195 +43,173 @@ To complete this tutorial, you should already have a basic familiarity with [Pod

* Have a supported Kubernetes Cluster running

**Note:** Please read the [getting started guides](https://kubernetes.io/docs/setup/pick-right-solution/) if you do not already have a cluster.
**Note:** Please read the [getting started guides](https://kubernetes.io/docs/setup/pick-right-solution/) if you do not already have a cluster.
{: .note}

### Additional Minikube Setup Instructions

**Warning:** [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube/) defaults to 1024MB of memory and 1 CPU which results in an insufficient resource errors.
**Caution:** [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube/) defaults to 1024MB of memory and 1 CPU which results in an insufficient resource errors during this tutorial.
{: .caution}

To avoid these errors, run minikube with:

```
minikube start --memory 5120 --cpus=4
```
minikube start --memory 5120 --cpus=4

{% endcapture %}

{% capture lessoncontent %}
## Creating a Cassandra Headless Service
A Kubernetes [Service](https://kubernetes.io/docs/concepts/services-networking/service/) describes a set of [Pods](https://kubernetes.io/docs/concepts/workloads/pods/pod/) that perform the same task.

The following `Service` is used for DNS lookups between Cassandra pods and clients within the Kubernetes Cluster.
The following `Service` is used for DNS lookups between Cassandra Pods and clients within the Kubernetes Cluster.

1. `cd` to the folder you saved the .yaml files.
2. Create a `Service` to track all Cassandra StatefulSet Nodes from the following `.yaml` file:
1. Launch a terminal window in the directory you downloaded the manifest files.
2. Create a `Service` to track all Cassandra StatefulSet Nodes from the `cassandra-service.yaml` file:

```shell
kubectl create -f cassandra-service.yaml
```
kubectl create -f cassandra-service.yaml

{% include code.html language="yaml" file="cassandra-service.yaml" ghlink="/docs/tutorials/stateful-application/cassandra-service.yaml" %}

### Validating (optional)

Get the Cassandra `Service`.

```shell
kubectl get svc cassandra
```
kubectl get svc cassandra

The response should be

```console
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cassandra None <none> 9042/TCP 45s
```
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cassandra None <none> 9042/TCP 45s

If anything else returns, the service was not successfully created. Read [Debug Services](https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/) for common issues.

## Using a StatefulSet to Create a Cassandra Ring

The StatefulSet manifest, included below, creates a Cassandra ring that consists of three pods.
The StatefulSet manifest, included below, creates a Cassandra ring that consists of three Pods.

**Note:** This example uses the default provisioner for Minikube. Please update the following StatefulSet for the cloud you are working with.
**Note:** This example uses the default provisioner for Minikube. Please update the following StatefulSet for the cloud you are working with.
{: .note}

1. Update the StatefulSet if necessary.
2. Create the Cassandra StatefulSet from the following `.yaml` file:
2. Create the Cassandra StatefulSet from the `cassandra-statefulset.yaml` file:

```shell
kubectl create -f cassandra-statefulset.yaml
```
kubectl create -f cassandra-statefulset.yaml

{% include code.html language="yaml" file="cassandra-statefulset.yaml" ghlink="/docs/tutorials/stateful-application/cassandra-statefulset.yaml" %}

## Validating The Cassandra StatefulSet

1. Get the Cassandra StatefulSet:

```shell
kubectl get statefulset cassandra
```
kubectl get statefulset cassandra

The response should be

```console
NAME DESIRED CURRENT AGE
cassandra 3 0 13s
```
NAME DESIRED CURRENT AGE
cassandra 3 0 13s

The StatefulSet resource deploys pods sequentially.
The StatefulSet resource deploys Pods sequentially.

{:start="2"}
2. Get the Pods to see the ordered creation status:

```shell
kubectl get pods -l="app=cassandra"
NAME READY STATUS RESTARTS AGE
cassandra-0 1/1 Running 0 1m
cassandra-1 0/1 ContainerCreating 0 8s
```
kubectl get pods -l="app=cassandra"
The response should be

NAME READY STATUS RESTARTS AGE
cassandra-0 1/1 Running 0 1m
cassandra-1 0/1 ContainerCreating 0 8s

**Note:** It can take up to ten minutes for all three pods to deploy.
**Note:** It can take up to ten minutes for all three Pods to deploy.
{: .note}

Once all pods are deployed, the same command returns:
Once all Pods are deployed, the same command returns:

```shell
kubectl get pods -l="app=cassandra"
NAME READY STATUS RESTARTS AGE
cassandra-0 1/1 Running 0 10m
cassandra-1 1/1 Running 0 9m
cassandra-2 1/1 Running 0 8m
```
NAME READY STATUS RESTARTS AGE
cassandra-0 1/1 Running 0 10m
cassandra-1 1/1 Running 0 9m
cassandra-2 1/1 Running 0 8m

{:start="3"}
3. Run the Cassandra utility nodetool to display the status of the ring.

```
kubectl exec cassandra-0 -- nodetool status
```

```console
Datacenter: DC1-K8Demo
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 10.4.2.4 65.26 KiB 32 63.7% a9d27f81-6783-461d-8583-87de2589133e Rack1-K8Demo
UN 10.4.0.4 102.04 KiB 32 66.7% 5559a58c-8b03-47ad-bc32-c621708dc2e4 Rack1-K8Demo
UN 10.4.1.4 83.06 KiB 32 69.6% 9dce943c-581d-4c0e-9543-f519969cc805 Rack1-K8Demo
```
kubectl exec cassandra-0 -- nodetool status

The response is:

Datacenter: DC1-K8Demo
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.17.0.5 83.57 KiB 32 74.0% e2dd09e6-d9d3-477e-96c5-45094c08db0f Rack1-K8Demo
UN 172.17.0.4 101.04 KiB 32 58.8% f89d6835-3a42-4419-92b3-0e62cae1479c Rack1-K8Demo
UN 172.17.0.6 84.74 KiB 32 67.1% a6a1e8c2-3dc5-4417-b1a0-26507af2aaad Rack1-K8Demo

## Modifying the Cassandra StatefulSet
Use `kubectl edit` to modify the size of of a Cassandra StatefulSet.

1. Run the following command:

```shell
kubectl edit statefulset cassandra
```
This command opens an editor in your terminal. The line you need to change is `Replicas`.
kubectl edit statefulset cassandra

This command opens an editor in your terminal. The line you need to change is the `replicas` field.

**Note:** The following sample is an excerpt of the StatefulSet file.

```console
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
creationTimestamp: 2016-08-13T18:40:58Z
generation: 1
labels:
app: cassandra
name: cassandra
namespace: default
resourceVersion: "323"
selfLink: /apis/apps/v1beta1/namespaces/default/statefulsets/cassandra
uid: 7a219483-6185-11e6-a910-42010a8a0fc0
spec:
replicas: 3
```

{:start="2"}
2. Increase the number of replicas to 4, and then save the manifest.

The StatefulSet now contains 4 pods.
{: .note}

```yaml
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
creationTimestamp: 2016-08-13T18:40:58Z
generation: 1
labels:
app: cassandra
name: cassandra
namespace: default
resourceVersion: "323"
selfLink: /apis/apps/v1beta1/namespaces/default/statefulsets/cassandra
uid: 7a219483-6185-11e6-a910-42010a8a0fc0
spec:
replicas: 3
```
2. Change the number of replicas to 4, and then save the manifest.
The StatefulSet now contains 4 Pods.
3. Get the Cassandra StatefulSet to verify:
```shell
kubectl get statefulset cassandra
```
kubectl get statefulset cassandra
The response should be
The response should be
```console
NAME DESIRED CURRENT AGE
cassandra 4 4 36m
```
NAME DESIRED CURRENT AGE
cassandra 4 4 36m
{% endcapture %}
{% capture cleanup %}
Deleting or scaling a StatefulSet down does not delete the volumes associated with the StatefulSet. This ensures safety first: your data is more valuable than an auto purge of all related StatefulSet resources.
**Warning:** Depending on the storage class and reclaim policy, deleting the Persistent Volume Claims may cause the associated volumes to also be deleted. Never assume you’ll be able to access data if its volume claims are deleted.
**Warning:** Depending on the storage class and reclaim policy, deleting the Persistent Volume Claims may cause the associated volumes to also be deleted. Never assume you’ll be able to access data if its volume claims are deleted.
{: .warning}
1. Run the following commands to delete everything in a `StatefulSet`:

```shell
grace=$(kubectl get po cassandra-0 -o=jsonpath='{.spec.terminationGracePeriodSeconds}') \
&& kubectl delete statefulset -l app=cassandra \
&& echo "Sleeping $grace" \
&& sleep $grace \
&& kubectl delete pvc -l app=cassandra
```
grace=$(kubectl get po cassandra-0 -o=jsonpath='{.spec.terminationGracePeriodSeconds}') \
&& kubectl delete statefulset -l app=cassandra \
&& echo "Sleeping $grace" \
&& sleep $grace \
&& kubectl delete pvc -l app=cassandra

2. Run the following command to delete the Cassandra `Service`.

```shell
kubectl delete service -l app=cassandra
```
kubectl delete service -l app=cassandra

{% endcapture %}

Expand Down
12 changes: 6 additions & 6 deletions guestbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ This tutorial shows you how to build and deploy a simple, multi-tier web applica
{% include task-tutorial-prereqs.md %}
Download the following configuration files:

1. [redis-master-deployment.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/guestbook/redis-master-deployment.yaml)
1. [redis-master-service.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/guestbook/redis-master-service.yaml)
1. [redis-slave-deployment.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/guestbook/redis-slave-deployment.yaml)
1. [redis-slave-service.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/guestbook/redis-slave-service.yaml)
1. [frontend-deployment.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/guestbook/frontend-deployment.yaml)
1. [frontend-service.yaml](https://kubernetes.io/docs/tutorials/docs/tutorials/stateless-application/guestbook/frontend-service.yaml)
1. [redis-master-deployment.yaml](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/redis-master-deployment.yaml)
1. [redis-master-service.yaml](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/redis-master-service.yaml)
1. [redis-slave-deployment.yaml](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/redis-slave-deployment.yaml)
1. [redis-slave-service.yaml](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/redis-slave-service.yaml)
1. [frontend-deployment.yaml](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/frontend-deployment.yaml)
1. [frontend-service.yaml](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/frontend-service.yaml)

{% endcapture %}

Expand Down

0 comments on commit 1fe5df1

Please sign in to comment.