Skip to content

StemboltEU/solidus_bare_docker

Repository files navigation

Solidus with docker, circleCI 2.0 and kubernetes

This is a sample setup for running Solidus on Kubernetes and using CircleCI 2.0 to deploy.

Uses:

Google cloud setup

Setup the following either using the gcloud sdk cli or on cloud.google.com in your console:

Install Kubernetes CLI

Install the kubectl command, which you will use to see your Kubernetes Dashboard: https://kubernetes.io/docs/tasks/tools/install-kubectl/

kubectl proxy

As it says, visit http://localhost:8001/ui to view the Kubernetes Dashboard.

Create secrets

Google Container Engine has its own secrets management (https://kubernetes.io/docs/concepts/configuration/secret/). We'll use the 'kubectl' to create the secrets manually from the command line. These commands then store them in the Google Container Engine.

We need:

  • Secret Key Base to run Rails in production
  • Postgres database password
  • Basic auth user and password for the traefik admin

Create a secret key base secret (for SECRET_KEY_BASE):

kubectl create secret generic production --from-literal=secretkeybase=<secret_key>

Postgres password secret (for POSTGRES_ROOT_PASSWORD and DB_PASSWORD):

kubectl create secret generic postgres --from-literal=password=<root-user-password>

The values are then specified in the kubernetes_config files using the 'valueFrom' key.

Create a secret for the basic-auth:

First create a basic auth file with username and password. Can use htpasswd (https://httpd.apache.org/docs/2.2/programs/htpasswd.html) to create the encoded file.

kubectl --namespace=kube-system create secret generic basic-auth-name --from-file=<path-to-basic-auth-file>

The basic auth file is specified in the traefik-ingress with the line:

ingress.kubernetes.io/auth-secret: basic-auth-name

Configure CircleCI

Setup Service accounts

In order to give CircleCI proper permissions to do stuff to our google cloud services, we need the following Google Cloud Service accounts:

  1. Allow CircleCI to pull/push from the Google Container Registry (e.g., "circleci-container-upload")
  2. Allow CircleCI to apply a deployment to the Google Container Engine (e.g., "circleci-kubernetes-deploy")

Create the accounts: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount

Grant correct permissions:

  • For the Google Container Registry service account, grant 'Storage Admin' permissions
  • For the Google Container Engine service account, grant 'Container Engine Developer' permissions

For each service account, we will use a JSON key file for authentification (https://cloud.google.com/container-registry/docs/advanced-authentication).

Create the JSON key: https://support.google.com/cloud/answer/6158849#serviceaccounts.

In your CircleCI Project Settings, add the following variables to 'Environment Variables':

About

A bare Solidus Shop to check out how Docker plays out

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages