From e682c933ea8939543f248b843ec89940f9b8ec87 Mon Sep 17 00:00:00 2001 From: Subin M Date: Tue, 24 Feb 2015 19:45:11 +0530 Subject: [PATCH 1/2] v1beta3 api yaml files --- examples/cassandra/v1beta3/README.md | 64 +++++++++++++++++++ .../v1beta3/cassandra-controller.yaml | 43 +++++++++++++ .../cassandra/v1beta3/cassandra-service.yaml | 11 ++++ examples/hazelcast/v1beta3/README.md | 2 - .../v1beta3/hazelcast-controller.yaml | 4 +- 5 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 examples/cassandra/v1beta3/README.md create mode 100644 examples/cassandra/v1beta3/cassandra-controller.yaml create mode 100644 examples/cassandra/v1beta3/cassandra-service.yaml diff --git a/examples/cassandra/v1beta3/README.md b/examples/cassandra/v1beta3/README.md new file mode 100644 index 0000000000000..a62d1c30f2c9b --- /dev/null +++ b/examples/cassandra/v1beta3/README.md @@ -0,0 +1,64 @@ +## Cloud Native Deployments of Cassandra using Kubernetes v1beta3 api + +The following document describes the development of a _cloud native_ [Cassandra](http://cassandra.apache.org/) deployment on Kubernetes. When we say _cloud native_ we mean an application which understands that it is running within a cluster manager, and uses this cluster management infrastructure to help implement the application. In particular, in this instance, a custom Cassandra ```SeedProvider``` is used to enable Cassandra to dynamically discover new Cassandra nodes as they join the cluster. + +This document also attempts to describe the core components of Kubernetes, _Pods_, _Services_ and _Replication Controllers_. + +### Prerequisites +This example assumes that you have a Kubernetes cluster installed and running, and that you have installed the ```kubectl``` command line tool somewhere in your path. Please see the [getting started](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/getting-started-guides) for installation instructions for your platform. + + +The v1beta3 API is not enabled by default. The kube-apiserver process needs to run with the --runtime_config=api/v1beta3 argument. Use the following command to enable it: +```sh +$sudo sed -i 's|KUBE_API_ARGS="|KUBE_API_ARGS="--runtime_config=api/v1beta3|' /etc/kubernetes/apiserver + + +``` + + +### quickstart +For those of you who are impatient, here is the summary of the commands we ran in this tutorial. + +```sh +# create a single cassandra node +kubectl create -f cassandra-controller.yaml + +# create a service to track all cassandra nodes +kubectl create -f cassandra-service.yaml + +$ docker exec nodetool status +Datacenter: datacenter1 +======================= +Status=Up/Down +|/ State=Normal/Leaving/Joining/Moving +-- Address Load Tokens Owns (effective) Host ID Rack +UN 10.244.3.29 72.07 KB 256 100.0% f736f0b5-bd1f-46f1-9b9d-7e8f22f37c9e rack1 + +# scale up to 2 nodes +kubectl resize rc cassandra --replicas=2 + +# validate the cluster +$ docker exec nodetool status +Datacenter: datacenter1 +======================= +Status=Up/Down +|/ State=Normal/Leaving/Joining/Moving +-- Address Load Tokens Owns (effective) Host ID Rack +UN 10.244.3.29 72.07 KB 256 100.0% f736f0b5-bd1f-46f1-9b9d-7e8f22f37c9e rack1 +UN 10.244.1.10 41.14 KB 256 100.0% 42617acd-b16e-4ee3-9486-68a6743657b1 rack1 + +# scale up to 4 nodes +kubectl resize rc cassandra --replicas=4 + +# validate the cluster +$ docker exec nodetool status +Datacenter: datacenter1 +======================= +Status=Up/Down +|/ State=Normal/Leaving/Joining/Moving +-- Address Load Tokens Owns (effective) Host ID Rack +UN 10.244.3.29 72.07 KB 256 49.5% f736f0b5-bd1f-46f1-9b9d-7e8f22f37c9e rack1 +UN 10.244.2.14 61.62 KB 256 52.6% 3e9981a6-6919-42c4-b2b8-af50f23a68f2 rack1 +UN 10.244.1.10 41.14 KB 256 49.5% 42617acd-b16e-4ee3-9486-68a6743657b1 rack1 +UN 10.244.4.8 63.83 KB 256 48.3% eeb73967-d1e6-43c1-bb54-512f8117d372 rack1 +``` diff --git a/examples/cassandra/v1beta3/cassandra-controller.yaml b/examples/cassandra/v1beta3/cassandra-controller.yaml new file mode 100644 index 0000000000000..78b2891043717 --- /dev/null +++ b/examples/cassandra/v1beta3/cassandra-controller.yaml @@ -0,0 +1,43 @@ +apiVersion: v1beta3 +kind: ReplicationController +metadata: + labels: + name: cassandra + name: cassandra +spec: + replicas: 1 + selector: + name: cassandra + template: + metadata: + labels: + name: cassandra + spec: + containers: + - command: + - /run.sh + resources: + limits: + cpu: 1000m + env: + - name: MAX_HEAP_SIZE + key: MAX_HEAP_SIZE + value: 512M + - name: HEAP_NEWSIZE + key: HEAP_NEWSIZE + value: 100M + image: "kubernetes/cassandra:v1" + name: cassandra + ports: + - containerPort: 9042 + name: cql + - containerPort: 9160 + name: thrift + volumeMounts: + - mountPath: /cassandra_data + name: data + volumes: + - name: data + source: + emptyDir: {} + diff --git a/examples/cassandra/v1beta3/cassandra-service.yaml b/examples/cassandra/v1beta3/cassandra-service.yaml new file mode 100644 index 0000000000000..09a886818e99b --- /dev/null +++ b/examples/cassandra/v1beta3/cassandra-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1beta3 +kind: Service +metadata: + labels: + name: cassandra + name: cassandra +spec: + containerPort: 9042 + port: 9042 + selector: + name: cassandra diff --git a/examples/hazelcast/v1beta3/README.md b/examples/hazelcast/v1beta3/README.md index 77387d1a62a33..f633b79b710e8 100644 --- a/examples/hazelcast/v1beta3/README.md +++ b/examples/hazelcast/v1beta3/README.md @@ -58,5 +58,3 @@ $ kubectl log 16b2beab-94a1-11e4-8a8b-42010af0e23e hazelcast 2014-12-24T01:21:23.036227250Z Member [10.160.2.3]:5701 2014-12-24T01:21:23.036227250Z } ``` - - diff --git a/examples/hazelcast/v1beta3/hazelcast-controller.yaml b/examples/hazelcast/v1beta3/hazelcast-controller.yaml index ed7679d119066..ddeeb67dbba2f 100644 --- a/examples/hazelcast/v1beta3/hazelcast-controller.yaml +++ b/examples/hazelcast/v1beta3/hazelcast-controller.yaml @@ -14,7 +14,9 @@ spec: name: hazelcast spec: containers: - - cpu: 1000 + - resources: + limits: + cpu: 1000m image: pires/hazelcast-k8s name: hazelcast ports: From 97ea7065fc8f639d89086ecb7fc0f238432d9518 Mon Sep 17 00:00:00 2001 From: Subin M Date: Thu, 26 Feb 2015 13:51:06 +0530 Subject: [PATCH 2/2] modify resource limits --- examples/cassandra/v1beta3/cassandra-controller.yaml | 2 +- examples/hazelcast/v1beta3/hazelcast-controller.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cassandra/v1beta3/cassandra-controller.yaml b/examples/cassandra/v1beta3/cassandra-controller.yaml index 78b2891043717..66af9a13eb8c0 100644 --- a/examples/cassandra/v1beta3/cassandra-controller.yaml +++ b/examples/cassandra/v1beta3/cassandra-controller.yaml @@ -18,7 +18,7 @@ spec: - /run.sh resources: limits: - cpu: 1000m + cpu: 1 env: - name: MAX_HEAP_SIZE key: MAX_HEAP_SIZE diff --git a/examples/hazelcast/v1beta3/hazelcast-controller.yaml b/examples/hazelcast/v1beta3/hazelcast-controller.yaml index ddeeb67dbba2f..795e0de0df8a7 100644 --- a/examples/hazelcast/v1beta3/hazelcast-controller.yaml +++ b/examples/hazelcast/v1beta3/hazelcast-controller.yaml @@ -16,7 +16,7 @@ spec: containers: - resources: limits: - cpu: 1000m + cpu: 1 image: pires/hazelcast-k8s name: hazelcast ports: