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

feat: add k8s config. #237

Merged
merged 1 commit into from
Jun 7, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ A push notification micro server using [Gin](https://github.com/gin-gonic/gin) f
- [Android Example](#android-example)
- [Response body](#response-body)
- [Run gorush in Docker](#run-gorush-in-docker)
- [Run gorush in Kubernetes](#run-gorush-in-kubernetes)
- [License](#license)

## Support Platform
Expand Down Expand Up @@ -673,6 +674,50 @@ $ http -v --verify=no --json GET http://your.docker.host/api/stat/go

![statue screenshot](screenshot/status.png)

## Run gorush in Kubernetes

Please make sure you are install [Minikube](https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/) first.

### Create a Minikube cluster

```sh
$ minikube start --vm-driver=xhyve
```

### Quick Start

Start the gorush with one command:

```sh
$ kubectl create -f k8s
deployment "frontend" created
service "frontend" created
deployment "redis-master" created
service "redis-master" created
```

Then, list all your Services:

```sh
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
frontend 10.0.0.156 <pending> 8088:32517/TCP 30s
kubernetes 10.0.0.1 <none> 443/TCP 14d
redis-master 10.0.0.67 <none> 6379/TCP 30s
```

### view the gorush home page

```sh
$ minikube service frontend
```

### Clean up the gorush:

```sh
$ kubectl delete -f k8s
```

## License

Copyright 2016 Bo-Yi Wu [@appleboy](https://twitter.com/appleboy).
Expand Down
27 changes: 27 additions & 0 deletions k8s/gorush-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: frontend
spec:
replicas: 3
template:
metadata:
labels:
app: gorush
tier: frontend
spec:
containers:
- name: gorush
image: appleboy/gorush
command: ["/gorush"]
args: ["-c", "config.yml", "-e", "redis", "--redis-addr", "redis-master:6379"]
env:
- name: GET_HOSTS_FROM
# value: dns
# If your cluster config does not include a dns service, then to
# instead access environment variables to find service host
# info, comment out the 'value: dns' line above, and uncomment the
# line below:
value: env
ports:
- containerPort: 8088
16 changes: 16 additions & 0 deletions k8s/gorush-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
app: gorush
tier: frontend
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
type: LoadBalancer
ports:
- port: 8088
selector:
app: gorush
tier: frontend
18 changes: 18 additions & 0 deletions k8s/redis-master-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis-master
spec:
replicas: 1
template:
metadata:
labels:
app: redis
role: master
tier: backend
spec:
containers:
- name: master
image: redis
ports:
- containerPort: 6379
16 changes: 16 additions & 0 deletions k8s/redis-master-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: redis-master
labels:
app: redis
role: master
tier: backend
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
role: master
tier: backend