This repository has been archived by the owner on Apr 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CommercialTribe/develop
Develop
- Loading branch information
Showing
17 changed files
with
307 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
FROM ruby:2.4 | ||
FROM redis:3.2 | ||
MAINTAINER Jason Waldrip <jwaldrip@commercialtribe.com> | ||
|
||
RUN gem install redis | ||
ADD http://download.redis.io/redis-stable/src/redis-trib.rb /usr/local/bin/redis-trib | ||
RUN chmod +x /usr/local/bin/redis-trib | ||
ADD https://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/linux/amd64/kubectl /usr/local/bin/kubectl | ||
RUN chmod +x /usr/local/bin/kubectl | ||
|
||
WORKDIR app | ||
ADD runner.sh ./runner.sh | ||
RUN chmod +x ./runner.sh | ||
CMD ./runner.sh | ||
WORKDIR /app | ||
ADD sidecar.sh /app/sidecar.sh | ||
RUN chmod +x /app/sidecar.sh | ||
CMD /app/sidecar.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 CommercialTribe, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
# kube-redis | ||
Resources for running Redis on Kubernetes | ||
# Redis on Kubernetes as StatefulSet | ||
|
||
The following document describes the deployment of a self-bootstrapping, reliable, | ||
multi-node Redis on Kubernetes. It deploys a master with replicated slaves, as | ||
well as replicated redis sentinels which are use for health checking and failover. | ||
|
||
## 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 for installation instructions for your platform. | ||
|
||
### Storage Class | ||
|
||
This makes use of a StorageClass, either create a storage class with the name of | ||
"ssd" or update the StatefulSet to point to to the correct StorageClass. | ||
|
||
## Running | ||
|
||
To get your cluster up and running simple run: | ||
|
||
`kubectl apply -Rf k8s` | ||
|
||
The cluster will automatically bootstrap itself. | ||
|
||
### Caveats | ||
|
||
Your pods may not show up in the dashboard. This is because we automatically add | ||
additional labels to the pods to recognize the master. To see the pods within the | ||
dashboard you should look at the redis-nodes service instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
#!/usr/bin/env bash | ||
image=commercialtribe/redis-sidecar | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | ||
docker build -t $image . | ||
docker push $image | ||
image="commercialtribe/redis-sentinel-sidecar" | ||
|
||
login(){ | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | ||
} | ||
|
||
push(){ | ||
docker push $image | ||
} | ||
|
||
build() { | ||
docker build -t $image . | ||
} | ||
|
||
build && (push || (login && push)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#!/usr/bin/env bash | ||
kubectl --namespace="$1" --context="$2" apply -Rf=./k8s/shared | ||
kubectl --namespace="$1" --context="$2" apply -Rf=./k8s/$3 | ||
kubectl --namespace="$1" --context="$2" ${ACTION-"apply"} -Rf=./k8s |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: redis-sentinel | ||
data: | ||
# Use the following file for reference http://download.redis.io/redis-stable/redis.conf | ||
node.conf: | | ||
protected-mode no | ||
port 6379 | ||
tcp-backlog 511 | ||
loglevel notice | ||
logfile "" | ||
dir /data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis | ||
labels: | ||
service: redis | ||
spec: | ||
ports: | ||
- port: 6379 | ||
name: redis | ||
selector: | ||
name: redis-sentinel-node | ||
role: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: StatefulSet | ||
metadata: | ||
name: redis | ||
annotations: | ||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" | ||
spec: | ||
serviceName: redis-nodes | ||
replicas: 3 | ||
template: | ||
metadata: | ||
labels: | ||
name: redis-node | ||
spec: | ||
terminationGracePeriodSeconds: 10 | ||
containers: | ||
# Redis | ||
- name: redis | ||
image: redis:3.2 | ||
command: | ||
- redis-server | ||
args: | ||
- /config/node.conf | ||
ports: | ||
- name: redis | ||
containerPort: 6379 | ||
volumeMounts: | ||
- name: data | ||
mountPath: /data | ||
- name: redis-config | ||
mountPath: /config | ||
livenessProbe: &healthcheck | ||
exec: | ||
command: [ "redis-cli", "ping" ] | ||
readinessProbe: | ||
<<: *healthcheck | ||
|
||
# Sentinel | ||
- name: sentinel | ||
image: redis:3.2 | ||
command: [ "bash", "-c", "touch sentinel.conf && redis-sentinel sentinel.conf" ] | ||
ports: | ||
- name: sentinel | ||
containerPort: 26379 | ||
livenessProbe: &healthcheck | ||
exec: | ||
command: [ "redis-cli", "-p", "26379", "ping" ] | ||
readinessProbe: | ||
<<: *healthcheck | ||
|
||
# Sidecar | ||
- name: sidecar | ||
image: commercialtribe/redis-sentinel-sidecar:latest | ||
imagePullPolicy: Always | ||
env: | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
volumeMounts: | ||
- name: pod-info | ||
mountPath: /etc/pod-info | ||
readinessProbe: | ||
exec: | ||
command: [ "cat", "booted" ] | ||
|
||
volumes: | ||
- name: pod-info | ||
downwardAPI: | ||
items: | ||
- path: labels | ||
fieldRef: | ||
fieldPath: metadata.labels | ||
- name: redis-config | ||
configMap: | ||
name: redis-sentinel | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: data | ||
annotations: | ||
volume.beta.kubernetes.io/storage-class: "ssd" | ||
spec: | ||
accessModes: [ "ReadWriteOnce" ] | ||
resources: | ||
requests: | ||
storage: 20Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis | ||
name: redis-nodes | ||
labels: | ||
name: redis | ||
service: redis | ||
spec: | ||
clusterIP: None | ||
ports: | ||
- port: 6379 | ||
name: redis | ||
selector: | ||
service: redis | ||
name: redis-node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-readonly | ||
labels: | ||
service: redis | ||
spec: | ||
ports: | ||
- port: 6379 | ||
name: redis | ||
selector: | ||
name: redis-sentinel-node | ||
role: slave |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.