feat: add k8s config. (#237)

This commit is contained in:
Bo-Yi Wu 2017-06-07 09:11:05 -05:00 committed by GitHub
parent 276cb49ae4
commit eb05be95f0
5 changed files with 122 additions and 0 deletions

View File

@ -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
@ -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).

View File

@ -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
k8s/gorush-service.yaml Normal file
View File

@ -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

View File

@ -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

View File

@ -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