Skip to content

Latest commit

 

History

History
107 lines (71 loc) · 2.89 KB

KUBERNETES.md

File metadata and controls

107 lines (71 loc) · 2.89 KB

Dillinger + Kubernetes

Some tips on how to deploy Dillinger to a Kubernetes cluster....

NOTE: This document assumes you've successfully created a cluster on GCP and you have a GCP account with a project associated with the cluster.

Setup

Create the replication controller and the service running Dillinger. These are already in the root of the directory in your dillinger.k8s.all.yml file. Feel free to modify as you see fit.

We use N|Solid as the Node.js runtime as it is the most robust/enterprise-grade Node.js platform.

kubectl create -f dillinger.k8s.all.yml

If you get an error remove the section for secrets and volumeMounts.

Check the status of the pods

kubectl get pods

Get the IP address of your Dillinger app

gcloud compute forwarding-rules list

Should output something like....

$ gcloud compute forwarding-rules list
NAME     REGION        IP_ADDRESS       IP_PROTOCOL TARGET
abcdef   us-central1   104.197.XXX.XXX  TCP         us-xxxx
To update a running cluster...

Say you cloned the latest update. You want this to roll out to your production environment. Clone the repo then simply run:

kubectl replace -f dillinger.k8s.all.yml

Create Secrets to Expose Plugin Configs

We now want to be able to expose our plugins like Dropbox and Github. Instead of using environment variables we'll use the dropbox-config.json (and others) file which contains sensitive information. That's why we use Kubernetes Secrets to protect it.

In the root of the Dillinger project directory, run:

kubectl create secret generic dropbox-config --from-file=./configs/dropbox-config.json

Should output:

secret "dropbox-config" created

Check to see it was created

kubectl get secrets

Should output something like:

NAME                  TYPE                                  DATA      AGE
dropbox-config        Opaque                                1         1m

You'll need to add the secret and mount it in the virtual filesystem on your pods.

vim dillinger.k8s.all.yml

Make the changes there and repeat for each plugin.

TODO: Add option for environment variables, not hosted files.

Now update your Kubernetes cluster:

kubectl replace -f dillinger.k8s.all.yml

Once it is "updated" (replaced), delete current pods and the replication controller will automatically restart them with the version containing your secrets/configs.

kubectl delete pods --all

Now checkit out with the URL of the app and also see it running in the N|Solid console

kubectl get svc nsolid-secure-proxy --namespace=nsolid

Should output:

NAME                  CLUSTER-IP    EXTERNAL-IP     PORT(S)          AGE
nsolid-secure-proxy   10.3.244.90   104.198.XX.XX   80/TCP,443/TCP   16h