Public | Automated Build

Last pushed: 6 months ago
Short Description
init-container for registering services on a kubernetes cluster
Full Description

init-register-service

This container is meant to be used as an init container to automatically cluster couchdb nodes when used as an init container in a kubernetes couchdb pod. Init containers are processed before the actual container and any failures prevent the containers from being started until they complete successfully.

In this case I've leaveraged this ability to execute commands using the network space of the container to be. In the case of couchdb here, I've used it to send a http request to the master adding this hostname as a new node to the /_nodes db.

Usage:

Add a pod spec as an inline list json string at metadata.annotations.pod.beta.kubernetes.io/init-containers. Be sure to remember to include any credentials necessary in the environment and make any necessary volume mounts.

Example:

CouchDB

apiVersion: v1
kind: Pod
metadata:
  name: couchdb
  annotations:
    pod.beta.kubernetes.io/init-containers: |
      [
        {
          "name": "register-service",
          "image": "callforamerica/init-register-service",
          "imagePullPolicy": "Always",
          "args": ["couchdb"],
          "volumeMounts": [
            {
              "name": "couchdb-data",
              "mountPath": "/volumes/couchdb"
            }
          ],
          "env": [
            {
              "name": "COUCHDB_ADMIN_USER",
              "valueFrom": {
                "secretKeyRef": {
                  "name": "couchdb-creds",
                  "key": "couchdb.user"
                }
              }
            },
            {
              "name": "COUCHDB_ADMIN_PASS",
              "valueFrom": {
                "secretKeyRef": {
                  "name": "couchdb-creds",
                  "key": "couchdb.pass"
                }
              }
            }
          ]
        }
      ]
spec:
    containers:
    - name: couchdb
      image: callforamerica/couchdb

Bigcouch

apiVersion: v1
kind: Pod
metadata:
  name: bigcouch
  annotations:
    pod.beta.kubernetes.io/init-containers: |
      [
        {
          "name": "register-service",
          "image": "callforamerica/init-register-service",
          "imagePullPolicy": "Always",
          "args": ["bigcouch"],
          "volumeMounts": [
            {
              "name": "bigcouch-data",
              "mountPath": "/volumes/bigcouch"
            }
          ],
          "env": [
            {
              "name": "BIGCOUCH_ADMIN_USER",
              "valueFrom": {
                "secretKeyRef": {
                  "name": "bigcouch-creds",
                  "key": "bigcouch.user"
                }
              }
            },
            {
              "name": "BIGCOUCH_ADMIN_PASS",
              "valueFrom": {
                "secretKeyRef": {
                  "name": "bigcouch-creds",
                  "key": "bigcouch.pass"
                }
              }
            }
          ]
        }
      ]
spec:
    containers:
    - name: bigcouch
      image: callforamerica/bigcouch

Issues

Docker.hub automated builds don't tolerate COPY or ADD to root /

I've added a comment to the Dockerfile noting this and for now am copying to
/tmp and then copying to / in the next statement.

ref: https://forums.docker.com/t/automated-docker-build-fails/22831/28

Docker Pull Command
Owner
callforamerica
Source Repository

Comments (0)