Syntax fixes for Cassandra doc

This commit is contained in:
lucperkins
2018-06-21 17:00:30 -07:00
parent f3fb826dc5
commit 8c95be965a
@@ -19,14 +19,14 @@ The docker image above is based on [debian-base](https://github.com/kubernetes/k
| ENV VAR | DEFAULT VALUE | | ENV VAR | DEFAULT VALUE |
| ------------- |:-------------: | | ------------- |:-------------: |
| CASSANDRA_CLUSTER_NAME | 'Test Cluster' | | `CASSANDRA_CLUSTER_NAME` | `'Test Cluster'` |
| CASSANDRA_NUM_TOKENS | 32 | | `CASSANDRA_NUM_TOKENS` | `32` |
| CASSANDRA_RPC_ADDRESS | 0.0.0.0 | | `CASSANDRA_RPC_ADDRESS` | `0.0.0.0` |
{{% /capture %}} {{% /capture %}}
{{% capture objectives %}} {{% capture objectives %}}
* Create and Validate a Cassandra headless [Services](/docs/concepts/services-networking/service/). * Create and validate a Cassandra headless [Service](/docs/concepts/services-networking/service/).
* Use a [StatefulSet](/docs/concepts/workloads/controllers/statefulset/) to create a Cassandra ring. * Use a [StatefulSet](/docs/concepts/workloads/controllers/statefulset/) to create a Cassandra ring.
* Validate the [StatefulSet](/docs/concepts/workloads/controllers/statefulset/). * Validate the [StatefulSet](/docs/concepts/workloads/controllers/statefulset/).
* Modify the [StatefulSet](/docs/concepts/workloads/controllers/statefulset/). * Modify the [StatefulSet](/docs/concepts/workloads/controllers/statefulset/).
@@ -49,17 +49,18 @@ To complete this tutorial, you should already have a basic familiarity with [Pod
### Additional Minikube Setup Instructions ### Additional Minikube Setup Instructions
{{< caution >}} {{< caution >}}
**Caution:** [Minikube](/docs/getting-started-guides/minikube/) defaults to 1024MB of memory and 1 CPU which results in an insufficient resource errors during this tutorial. **Caution:** [Minikube](/docs/getting-started-guides/minikube/) defaults to 1024MB of memory and 1 CPU. Running Minikube with the default resource configuration may result in insufficient resource errors during this tutorial. To avoid these errors, we recommend running Minikube with 5 GB of memory and 4 CPUs:
{{< /caution >}}
To avoid these errors, run minikube with:
```bash
minikube start --memory 5120 --cpus=4 minikube start --memory 5120 --cpus=4
```
{{< /caution >}}
{{% /capture %}} {{% /capture %}}
{{% capture lessoncontent %}} {{% capture lessoncontent %}}
## Creating a Cassandra Headless Service ## Creating a Cassandra Headless Service
A Kubernetes [Service](/docs/concepts/services-networking/service/) describes a set of [Pods](/docs/concepts/workloads/pods/pod/) that perform the same task. A Kubernetes [Service](/docs/concepts/services-networking/service/) describes a set of [Pods](/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.
@@ -67,7 +68,9 @@ The following `Service` is used for DNS lookups between Cassandra Pods and clien
1. Launch a terminal window in the directory you downloaded the manifest files. 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: 2. Create a `Service` to track all Cassandra StatefulSet Nodes from the `cassandra-service.yaml` file:
```bash
kubectl create -f cassandra-service.yaml kubectl create -f cassandra-service.yaml
```
{{< code file="cassandra/cassandra-service.yaml" >}} {{< code file="cassandra/cassandra-service.yaml" >}}
@@ -75,14 +78,18 @@ The following `Service` is used for DNS lookups between Cassandra Pods and clien
Get the Cassandra `Service`. Get the Cassandra `Service`.
```bash
kubectl get svc cassandra kubectl get svc cassandra
```
The response should be The response should be
```
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cassandra None <none> 9042/TCP 45s cassandra None <none> 9042/TCP 45s
```
If anything else returns, the service was not successfully created. Read [Debug Services](/docs/tasks/debug-application-cluster/debug-service/) for common issues. If anything else is returned, the Service was not successfully created. Read [Debug Services](/docs/tasks/debug-application-cluster/debug-service/) for common issues.
## Using a StatefulSet to Create a Cassandra Ring ## Using a StatefulSet to Create a Cassandra Ring
@@ -95,7 +102,9 @@ The StatefulSet manifest, included below, creates a Cassandra ring that consists
1. Update the StatefulSet if necessary. 1. Update the StatefulSet if necessary.
2. Create the Cassandra StatefulSet from the `cassandra-statefulset.yaml` file: 2. Create the Cassandra StatefulSet from the `cassandra-statefulset.yaml` file:
```bash
kubectl create -f cassandra-statefulset.yaml kubectl create -f cassandra-statefulset.yaml
```
{{< code file="cassandra/cassandra-statefulset.yaml" >}} {{< code file="cassandra/cassandra-statefulset.yaml" >}}
@@ -103,42 +112,51 @@ The StatefulSet manifest, included below, creates a Cassandra ring that consists
1. Get the Cassandra StatefulSet: 1. Get the Cassandra StatefulSet:
```bash
kubectl get statefulset cassandra kubectl get statefulset cassandra
```
The response should be The response should be:
```
NAME DESIRED CURRENT AGE NAME DESIRED CURRENT AGE
cassandra 3 0 13s cassandra 3 0 13s
```
The StatefulSet resource deploys Pods sequentially. The StatefulSet resource deploys Pods sequentially.
2. Get the Pods to see the ordered creation status: 2. Get the Pods to see the ordered creation status:
```bash
kubectl get pods -l="app=cassandra" kubectl get pods -l="app=cassandra"
```
The response should be The response should be:
```bash
NAME READY STATUS RESTARTS AGE NAME READY STATUS RESTARTS AGE
cassandra-0 1/1 Running 0 1m cassandra-0 1/1 Running 0 1m
cassandra-1 0/1 ContainerCreating 0 8s cassandra-1 0/1 ContainerCreating 0 8s
```
{{< note >}} Please note that it may take several minutes for all three Pods to deploy. Once they are deployed, the same command returns:
**Note:** It can take up to ten minutes for all three Pods to deploy.
{{< /note >}}
Once all Pods are deployed, the same command returns:
```
NAME READY STATUS RESTARTS AGE NAME READY STATUS RESTARTS AGE
cassandra-0 1/1 Running 0 10m cassandra-0 1/1 Running 0 10m
cassandra-1 1/1 Running 0 9m cassandra-1 1/1 Running 0 9m
cassandra-2 1/1 Running 0 8m cassandra-2 1/1 Running 0 8m
```
3. Run the Cassandra utility nodetool to display the status of the ring. 3. Run the Cassandra [nodetool](https://wiki.apache.org/cassandra/NodeTool) to display the status of the ring.
kubectl exec cassandra-0 -- nodetool status ```bash
kubectl exec -it cassandra-0 -- nodetool status
```
The response is: The response should look something like this:
```
Datacenter: DC1-K8Demo Datacenter: DC1-K8Demo
====================== ======================
Status=Up/Down Status=Up/Down
@@ -147,13 +165,17 @@ The StatefulSet manifest, included below, creates a Cassandra ring that consists
UN 172.17.0.5 83.57 KiB 32 74.0% e2dd09e6-d9d3-477e-96c5-45094c08db0f Rack1-K8Demo 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.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 UN 172.17.0.6 84.74 KiB 32 67.1% a6a1e8c2-3dc5-4417-b1a0-26507af2aaad Rack1-K8Demo
```
## Modifying the Cassandra StatefulSet ## Modifying the Cassandra StatefulSet
Use `kubectl edit` to modify the size of a Cassandra StatefulSet. Use `kubectl edit` to modify the size of a Cassandra StatefulSet.
1. Run the following command: 1. Run the following command:
```bash
kubectl edit statefulset cassandra kubectl edit statefulset cassandra
```
This command opens an editor in your terminal. The line you need to change is the `replicas` field. This command opens an editor in your terminal. The line you need to change is the `replicas` field.
@@ -186,12 +208,16 @@ Use `kubectl edit` to modify the size of a Cassandra StatefulSet.
3. Get the Cassandra StatefulSet to verify: 3. Get the Cassandra StatefulSet to verify:
```bash
kubectl get statefulset cassandra kubectl get statefulset cassandra
```
The response should be The response should be
```
NAME DESIRED CURRENT AGE NAME DESIRED CURRENT AGE
cassandra 4 4 36m cassandra 4 4 36m
```
{{% /capture %}} {{% /capture %}}
@@ -202,17 +228,21 @@ Deleting or scaling a StatefulSet down does not delete the volumes associated wi
**Warning:** Depending on the storage class and reclaim policy, deleting the PersistentVolumeClaims may cause the associated volumes to also be deleted. Never assume youll be able to access data if its volume claims are deleted. **Warning:** Depending on the storage class and reclaim policy, deleting the PersistentVolumeClaims may cause the associated volumes to also be deleted. Never assume youll be able to access data if its volume claims are deleted.
{{< /warning >}} {{< /warning >}}
1. Run the following commands to delete everything in a `StatefulSet`: 1. Run the following commands (chained together into a single command) to delete everything in the Cassandra StatefulSet:
```bash
grace=$(kubectl get po cassandra-0 -o=jsonpath='{.spec.terminationGracePeriodSeconds}') \ grace=$(kubectl get po cassandra-0 -o=jsonpath='{.spec.terminationGracePeriodSeconds}') \
&& kubectl delete statefulset -l app=cassandra \ && kubectl delete statefulset -l app=cassandra \
&& echo "Sleeping $grace" \ && echo "Sleeping $grace" \
&& sleep $grace \ && sleep $grace \
&& kubectl delete pvc -l app=cassandra && kubectl delete pvc -l app=cassandra
```
2. Run the following command to delete the Cassandra `Service`. 2. Run the following command to delete the Cassandra `Service`.
```bash
kubectl delete service -l app=cassandra kubectl delete service -l app=cassandra
```
{{% /capture %}} {{% /capture %}}