Automate capsule delivery in Kubernetes


Do you often need to synchronize the implementation of a new design document or an API update with the related application code? This article serves as an inspiration for DevOps teams who want to automate pod dependencies in Kubernetes.


To get the most out of this article, you need to have a general understanding of Kubernetes, containers, implementation and continuous integration, as well as Cloudant design documents.

Estimated time

Reading this article should take about 15 minutes to complete.

How far can we go to automate the “Ops” part of DevOps?
As a developer, I want to be in complete control of everything. I want to define changes to external dependencies directly in my application code. I want to implement updates to my Node.js or Java application and see it running with its previous version. I want to avoid downtime and conflicts between the database views that my web service needed before and the views it needs now.

After all, the automation trend in the cloud allows DevOps teams to be in control of end-to-end implementations.

Luckily, Kubernetes has been making updates in progress a very simple process. Along with the constant implementation and continuous integration tools, such as Travis CI or the Toolchain development tool for the IBM Cloud, the process has become increasingly easy to configure. Multiple deployments per day are now routine. However, it is not always that easy to synchronize custom databases or API updates with the application code. It is often necessary to orchestrate implementations.

This article describes one of the ways to synchronize pod dependencies using Kubernetes Init Containers.

Applications such as microservices often need a limited set of dependencies, such as their own storage and API definition. API-related storage or updates often evolve into a routine – and they demand automation. Updating the Cloudant design document is a great example of this. The critical part of the continuous implementation of high availability applications is to ensure that the updated view is available at the same time that the service is updated.

See Also
What are container orchestration and Kubernetes?

An automated deployment process is appropriate when you have the following types of dependencies:

Databases (Cloudant, object storage)

Database design documents (indexes, views)

Seed documents

APIs (swaggers)

API Changelogs

Automated integration tests

The settings for all these dependencies can be stored in the application’s code repository and packaged in the docker image.

Note: by configuration, I mean code, not credentials. Credentials must be entered as environment variables or provided by configuration services.

Here is the structure of an example config directory:


¦ cloudant

¦ ¦ {databaseSuffixOrFullName}

¦ ¦ ¦ designs

¦ ¦ ¦ ¦ {designName} .json

¦ ¦ ¦ seeds

¦ ¦ ¦ ¦ {seedName} .json

¦ ¦ parameters.json (optional)

¦ apis

¦ ¦ {apiName}

¦ ¦ ¦ {version} .yaml

¦ ¦ ¦ {version} .md

¦ ¦ ¦ {version} .test.json

¦ ¦ ¦ {version} .test.js

Is it really necessary to store all this information with the application code? No, but having complete control over all parts is extremely liberating for developers. Fully autonomous services give us the peace of mind that none of the facilities will create conflicts between different versions of services.

Init containers: Kubernetes’ response to application dependencies
The recommended method for installing application dependencies on Kubernetes is through Init Containers. Init Containers are defined in the pod implementation and block the application from starting until they are successfully executed.

The following is a very basic example in which the Init Container creates a new Cloudant database:

apiVersion: v1

kind: Pod


name: app



– name: app



– containerPort: 8080


– name: deploy

image: appropriate / curl

command: [“sh”]

args: [“-c”, “curl -X PUT $ URL / dbname”]


– name: URL



name: config

key: cloudantApiKeyUrl

Want to read more specialized programming content? Discover the IBM Blue Profile and access exclusive materials, new knowledge journeys and personalized tests. Check it out right now, get the badges and upgrade your career!


Please enter your comment!
Please enter your name here