Further Reading for A Survival Guide to Containerizing Your Infrastructure - adcooley/containerize-code-files GitHub Wiki

##Troubleshooting your Minikube Setup

On multiple occasions (both on OS X and linux) I ran into a problem where the docker daemon running in Minkube (running in a Virtualbox VM) had a lower API version than the client version contained in my local Docker installation. If you get the following error when you try switching to the minikube context with eval $(minikube docker-env):

Error response from daemon: client is newer than server (client API version: 1.23, server API version: 1.22)

…you’ll want to uninstall Docker locally and install an older version from the available releases (v1.11.2 worked for me). In this case, you’ll no longer have a docker engine running outside of your Minikube environment, so you may want to separately re-install the separate docker-machine. This will allow you to switch out of the minikube context with eval $(docker-machine env machine_name, isolating your GCP container images from your minikube container images.

##Script and Usage Info for Secrets and ConfigMaps Run the script (available here) as follows: python generate-vars.py path_to_file.json where your input file is formatted as follows:

# Your env variables
{
  "secrets": {
    "twitter-consumer-key": "my_twitter_secret",
    …
  },
  "vars": {
    "server-name": "myapp.com"
    …
  }
}

Two files will be output to the working directory.

# secrets.yaml 
apiVersion: v1
kind: Secret
metadata:
  name: secret.vars.config
type: Opaque
data:
  twitter-consumer-key: bXlfdHdpdHRlcl9zZWNyZXQ=

and

# config-map.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: env.vars.config
  namespace: default
data:
  server-name: myapp.com

You’ll need to create these two objects on Kubernetes. Make sure you are in the right kubernetes context by running kubectl config current-context (eg. minikube vs gke_project_us-east1-c_example)

kubectl create -f config-map.yaml
kubectl create -f secrets.yaml

Then of course in your Deployment files, you need to specify which vars you want to include. If you were to create the below sample deployment file:

# sample-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: config-secret-test
spec:
  replicas: 1
  template:
    metadata:
      labels:
        environment: test
    spec:
      containers:
        - name: config-secret-test
          image: gcr.io/google_containers/busybox
          command: [ "/bin/sh", "-c", "echo $(SERVER_NAME) $(TWITTER_CONSUMER_KEY)" ]
          env:
            - name: SERVER_NAME
              valueFrom:
                configMapKeyRef:
                  name: env.vars.config
                  key: server-name
            - name: TWITTER_CONSUMER_KEY
              valueFrom:
                secretKeyRef:
                  name: secret.vars.config
                  key: twitter-consumer-key

then run kubectl logs config-secret-test[TAB], the output would show that the container does indeed have the desired environment variables set!

# container logs
myapp.com my_twitter_secret