diff --git a/README.md b/README.md index 79b8cb0..10e85c6 100644 --- a/README.md +++ b/README.md @@ -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 8088:32517/TCP 30s -kubernetes 10.0.0.1 443/TCP 14d -redis-master 10.0.0.67 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: diff --git a/k8s/gorush-aws-ingress.yaml b/k8s/gorush-aws-ingress.yaml new file mode 100644 index 0000000..ba3a47a --- /dev/null +++ b/k8s/gorush-aws-ingress.yaml @@ -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 diff --git a/k8s/gorush-deployment.yaml b/k8s/gorush-deployment.yaml index 4c3e082..1f6cd22 100644 --- a/k8s/gorush-deployment.yaml +++ b/k8s/gorush-deployment.yaml @@ -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 diff --git a/k8s/gorush-namespace.yaml b/k8s/gorush-namespace.yaml new file mode 100644 index 0000000..9bac3da --- /dev/null +++ b/k8s/gorush-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: gorush diff --git a/k8s/redis-master-deployment.yaml b/k8s/gorush-redis-deployment.yaml similarity index 93% rename from k8s/redis-master-deployment.yaml rename to k8s/gorush-redis-deployment.yaml index f1bd60d..2f9a8e5 100644 --- a/k8s/redis-master-deployment.yaml +++ b/k8s/gorush-redis-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: name: redis + namespace: gorush spec: replicas: 1 template: diff --git a/k8s/redis-master-service.yaml b/k8s/gorush-redis-service.yaml similarity index 91% rename from k8s/redis-master-service.yaml rename to k8s/gorush-redis-service.yaml index da1e0ee..5dd361a 100644 --- a/k8s/redis-master-service.yaml +++ b/k8s/gorush-redis-service.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: redis + namespace: gorush labels: app: redis role: master diff --git a/k8s/gorush-service.yaml b/k8s/gorush-service.yaml index 27b0cc6..d210f09 100644 --- a/k8s/gorush-service.yaml +++ b/k8s/gorush-service.yaml @@ -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: diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml deleted file mode 100644 index 184929b..0000000 --- a/k8s/ingress.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: gorush - annotations: - http.port: "8089" -spec: - backend: - serviceName: gorush - servicePort: 8088