update k8s document and yml (#284)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2017-09-22 11:22:10 +08:00 committed by GitHub
parent 8e98e0b6fe
commit 411b6efc4a
8 changed files with 46 additions and 42 deletions

View File

@ -751,40 +751,32 @@ $ http -v --verify=no --json GET http://your.docker.host/api/stat/go
## 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:
Create name space `gorush`:
```sh
$ kubectl create -f k8s
deployment "frontend" created
service "frontend" created
deployment "redis-master" created
service "redis-master" created
$ kubectl create -f k8s/gorush-namespace.yaml
```
Then, list all your Services:
Create redis service:
```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
$ kubectl create -f k8s/gorush-redis-deployment.yaml
$ kubectl create -f k8s/gorush-redis-service.yaml
```
### view the gorush home page
Create gorush service:
```sh
$ minikube service frontend
$ kubectl create -f k8s/gorush-deployment.yaml
$ kubectl create -f k8s/gorush-service.yaml
```
### Ingress Controller for AWS ALB
```
$ kubectl create -f k8s/gorush-aws-ingress.yaml
```
### Clean up the gorush:

View File

@ -0,0 +1,20 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gorush
namespace: gorush
annotations:
# Kubernetes Ingress Controller for AWS ALB
# https://github.com/coreos/alb-ingress-controller
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/subnets: "subnet-3cd22c75,subnet-4aff342d"
alb.ingress.kubernetes.io/security-groups: sg-329c2b54
spec:
rules:
- host: gorush.example.com
http:
paths:
- path: /
backend:
serviceName: gorush
servicePort: 8088

View File

@ -2,6 +2,7 @@ apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gorush
namespace: gorush
spec:
replicas: 3
template:
@ -11,17 +12,10 @@ spec:
tier: frontend
spec:
containers:
- name: gorush
image: appleboy/gorush
- image: appleboy/gorush
name: gorush
imagePullPolicy: Always
command: ["/gorush"]
args: ["-c", "config.yml", "-e", "redis", "--redis-addr", "redis: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

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: gorush

View File

@ -2,6 +2,7 @@ apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis
namespace: gorush
spec:
replicas: 1
template:

View File

@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: redis
namespace: gorush
labels:
app: redis
role: master

View File

@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: gorush
namespace: gorush
labels:
app: gorush
tier: frontend
@ -9,6 +10,7 @@ spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
# type: LoadBalancer
type: NodePort
ports:
- port: 8088
selector:

View File

@ -1,10 +0,0 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gorush
annotations:
http.port: "8089"
spec:
backend:
serviceName: gorush
servicePort: 8088