From 9714d1e4c51fb34991847fe145197afbf2a2a7e1 Mon Sep 17 00:00:00 2001 From: Kevin Stock Date: Tue, 4 Oct 2016 00:41:26 -0700 Subject: [PATCH] Adds Kubernetes deployment --- README.md | 9 ++++++++ kubernetes/.gitignore | 1 + kubernetes/apply.sh | 8 +++++++ kubernetes/deployment.yaml | 38 +++++++++++++++++++++++++++++++++ kubernetes/namespace.yaml | 4 ++++ kubernetes/secrets.example.yaml | 21 ++++++++++++++++++ kubernetes/service.yaml | 18 ++++++++++++++++ 7 files changed, 99 insertions(+) create mode 100644 kubernetes/.gitignore create mode 100755 kubernetes/apply.sh create mode 100644 kubernetes/deployment.yaml create mode 100644 kubernetes/namespace.yaml create mode 100644 kubernetes/secrets.example.yaml create mode 100644 kubernetes/service.yaml diff --git a/README.md b/README.md index 67b3d83..99e6403 100644 --- a/README.md +++ b/README.md @@ -53,5 +53,14 @@ docker run \ tantalic/bellinghamcodes-website:latest ``` +## Running in Production +The production site runs on a [Kubernetes][k8s] cluster. To deploy on Kubernetes copy the `kubernetes/secrets.example.yaml` to `kubernetes/secrets.yaml` and complete the required values. Then run: + +```sh +cd kubernetes/ +./apply.sh +``` + [go]: http://www.golang.org [glide]: https://glide.sh +[k8s]: http://kubernetes.io \ No newline at end of file diff --git a/kubernetes/.gitignore b/kubernetes/.gitignore new file mode 100644 index 0000000..03cdeec --- /dev/null +++ b/kubernetes/.gitignore @@ -0,0 +1 @@ +secrets.yaml diff --git a/kubernetes/apply.sh b/kubernetes/apply.sh new file mode 100755 index 0000000..c4e446b --- /dev/null +++ b/kubernetes/apply.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +NAMESACE=bellinghamcodes + +kubectl apply -f namespace.yaml +kubectl --namespace=${NAMESACE} apply -f ./secrets.yaml +kubectl --namespace=${NAMESACE} apply -f ./service.yaml +kubectl --namespace=${NAMESACE} apply -f ./deployment.yaml diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yaml new file mode 100644 index 0000000..54d1143 --- /dev/null +++ b/kubernetes/deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: website +spec: + replicas: 1 + template: + metadata: + labels: + app: website + spec: + containers: + - image: tantalic/bellinghamcodes-website:latest + name: api + ports: + - containerPort: 80 + protocol: TCP + env: + - name: SLACK_TEAM + valueFrom: + secretKeyRef: + name: slack + key: team + - name: SLACK_TOKEN + valueFrom: + secretKeyRef: + name: slack + key: token + - name: MAILCHIMP_TOKEN + valueFrom: + secretKeyRef: + name: mailchimp + key: token + - name: MAILCHIMP_LIST + valueFrom: + secretKeyRef: + name: mailchimp + key: list diff --git a/kubernetes/namespace.yaml b/kubernetes/namespace.yaml new file mode 100644 index 0000000..d7882ff --- /dev/null +++ b/kubernetes/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: bellinghamcodes diff --git a/kubernetes/secrets.example.yaml b/kubernetes/secrets.example.yaml new file mode 100644 index 0000000..5ce7e95 --- /dev/null +++ b/kubernetes/secrets.example.yaml @@ -0,0 +1,21 @@ +# The following example shows the secrets that should be defined for a +# kubernetes deployment + +apiVersion: v1 +kind: Secret +metadata: + name: slack +type: Opaque +data: + team: + token: +--- +apiVersion: v1 +kind: Secret +metadata: + name: mailchimp +type: Opaque +data: + token: + list: +--- diff --git a/kubernetes/service.yaml b/kubernetes/service.yaml new file mode 100644 index 0000000..0c59b56 --- /dev/null +++ b/kubernetes/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: website + labels: + name: website + router.deis.io/routable: "true" + annotations: + router.deis.io/domains: bellingham.codes,www.bellingham.codes +spec: + type: ClusterIP + selector: + app: website + + ports: + - name: http + port: 80 + protocol: TCP