Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated gce-pd and redis examples to use v1beta3 #5062

Merged
merged 1 commit into from
Mar 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions examples/gce-pd/v1beta3/testpd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1beta3
kind: Pod
metadata:
labels:
test: testpd
name: testpd
spec:
containers:
- name: testpd
image: kubernetes/pause
volumeMounts:
# name must match the volume name below
- name: testpd
# mount path within the container
mountPath: /testpd
volumes:
- name: testpd
persistentDisk:
# This GCE PD must already exist.
pdName: %insert_pd_name_here%
fsType: ext4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs newline

119 changes: 5 additions & 114 deletions examples/redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,8 @@ is a [_Pod_](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/

We will used the shared network namespace to bootstrap our Redis cluster. In particular, the very first sentinel needs to know how to find the master (subsequent sentinels just ask the first sentinel). Because all containers in a Pod share a network namespace, the sentinel can simply look at ```$(hostname -i):6379```.

Here is the config for the initial master and sentinel pod:
```yaml
id: redis-master
kind: Pod
apiVersion: v1beta1
desiredState:
manifest:
version: v1beta1
id: redis-master
containers:
- name: master
image: kubernetes/redis:v1
cpu: 1000
ports:
- name: api
containerPort: 6379
volumeMounts:
- name: data
mountPath: /redis-master-data
env:
- key: MASTER
value: "true"
- name: sentinel
image: kubernetes/redis:v1
ports:
- name: api
containerPort: 26379
env:
- key: SENTINEL
value: "true"
volumes:
- name: data
source:
emptyDir: {}
labels:
name: redis
role: master
redis-sentinel: "true"
```
Here is the config for the initial master and sentinel pod: [redis-master.yaml](redis-master.yaml)


Create this master as follows:
```sh
Expand All @@ -63,20 +26,7 @@ In Kubernetes a _Service_ describes a set of Pods that perform the same task. F

In Redis, we will use a Kubernetes Service to provide a discoverable endpoints for the Redis sentinels in the cluster. From the sentinels Redis clients can find the master, and then the slaves and other relevant info for the cluster. This enables new members to join the cluster when failures occur.

Here is the definition of the sentinel service:

```yaml
id: redis-sentinel
kind: Service
apiVersion: v1beta1
port: 26379
containerPort: 26379
selector:
redis-sentinel: "true"
labels:
name: sentinel
role: service
```
Here is the definition of the sentinel service:[redis-sentinel-service.yaml](redis-sentinel-service.yaml)

Create this service:
```sh
Expand All @@ -89,39 +39,7 @@ So far, what we have done is pretty manual, and not very fault-tolerant. If the
In Kubernetes a _Replication Controller_ is responsible for replicating sets of identical pods. Like a _Service_ it has a selector query which identifies the members of it's set. Unlike a _Service_ it also has a desired number of replicas, and it will create or delete _Pods_ to ensure that the number of _Pods_ matches up with it's desired state.

Replication Controllers will "adopt" existing pods that match their selector query, so let's create a Replication Controller with a single replica to adopt our existing Redis server.

```yaml
id: redis
kind: ReplicationController
apiVersion: v1beta1
desiredState:
replicas: 1
replicaSelector:
name: redis
# This template is basically identical to the single pod
# definition above
podTemplate:
desiredState:
manifest:
version: v1beta1
id: redis
containers:
- name: redis
image: kubernetes/redis:v1
cpu: 1000
ports:
- name: api
containerPort: 6379
volumeMounts:
- name: data
mountPath: /redis-master-data
volumes:
- name: data
source:
emptyDir: {}
labels:
name: redis
```
[redis-controller.yaml](redis-controller.yaml)

The bulk of this controller config is actually identical to the redis-master pod definition above. It forms the template or "cookie cutter" that defines what it means to be a member of this set.

Expand All @@ -131,34 +49,7 @@ Create this controller:
kubectl create -f examples/redis/redis-controller.yaml
```

We'll do the same thing for the sentinel. Here is the controller config:
```yaml
id: redis-sentinel
kind: ReplicationController
apiVersion: v1beta1
desiredState:
replicas: 1
replicaSelector:
redis-sentinel: "true"
podTemplate:
desiredState:
manifest:
version: v1beta1
id: redis-slave
containers:
- name: sentinel
image: kubernetes/redis:v1
ports:
- name: api
containerPort: 26379
env:
- key: SENTINEL
value: "true"
labels:
name: redis-sentinel
role: sentinel
redis-sentinel: "true"
```
We'll do the same thing for the sentinel. Here is the controller config:[redis-sentinel-controller.yaml](redis-sentinel-controller.yaml)

We create it as follows:
```sh
Expand Down
3 changes: 1 addition & 2 deletions examples/redis/redis-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ desiredState:
image: kubernetes/redis:v1
cpu: 1000
ports:
- name: api
containerPort: 6379
- containerPort: 6379
volumeMounts:
- name: data
mountPath: /redis-master-data
Expand Down
10 changes: 0 additions & 10 deletions examples/redis/redis-master-service.yaml

This file was deleted.

6 changes: 2 additions & 4 deletions examples/redis/redis-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ desiredState:
image: kubernetes/redis:v1
cpu: 1000
ports:
- name: api
containerPort: 6379
- containerPort: 6379
volumeMounts:
- name: data
mountPath: /redis-master-data
Expand All @@ -21,8 +20,7 @@ desiredState:
- name: sentinel
image: kubernetes/redis:v1
ports:
- name: api
containerPort: 26379
- containerPort: 26379
env:
- key: SENTINEL
value: "true"
Expand Down
2 changes: 1 addition & 1 deletion examples/redis/redis-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ labels:
role: proxy



3 changes: 1 addition & 2 deletions examples/redis/redis-sentinel-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ desiredState:
- name: sentinel
image: kubernetes/redis:v1
ports:
- name: api
containerPort: 26379
- containerPort: 26379
env:
- key: SENTINEL
value: "true"
Expand Down
22 changes: 0 additions & 22 deletions examples/redis/redis-sentinel.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions examples/redis/redis-service.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions examples/redis/redis-slave.yaml

This file was deleted.