Kubernetes deployment
Kubernetes deployment with vault integration
Kubernetes, an open source container management system, has been widely adopted in the last years and has been shown to be battle proven. Thousands of companies are already using it in production and this is only the beginning. Besides it solves a lot of problems, it also brings new ones on the board. One example is the complexity of the setup from Kubernetes. The pure configuration management part of YAML/JSON files has been a struggle for a while for many people.
Gaia is the perfect tool to automate deployments, coordinate maintenance tasks for your cluster, automatic cleanup of resources from your cluster and much more. In this guide we will setup a small local test environment including Kubernetes and hashicorp vault. We will create a powerful pipeline in Go which deploys an application to this Kubernetes cluster (with namespace and service). All relevant information about the deployment will be safely stored and retrieved from hashicorp vault.
We will also write tests for our pipeline which we can execute locally to test our jobs and make sure they are actually working. Let us start with the requirements and the setup of the test environment!
Requirements
We assume the following components are already installed on your computer:
- Docker for Mac or Docker for Windows on edge version for Kubernetes support.
- External Kubernetes Cluster: This is not needed if Docker Kubernetes Cluster is available (line above).
- Golang 1.10.3 or later (to run the tests locally).
If not’s already installed, please do it now.
Setup test environment: Docker with Kubernetes support
This is probably the easiest way to get a local Kubernetes Cluster running. If you are on the latest Edge version you should be able to activate your local Kubernetes Cluster in the Preferences.

After some setup time, your local Kubernetes Cluster should be available and your kubectl should be already configured. You can verify that by typing kubectl cluster-info which should print something like this:
Kubernetes master is running at https://localhost:6443
KubeDNS is running at https://localhost:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
That’s it for now. Continue with the next chapter:
0 - Setup
Setup test environment: External Kubernetes Cluster
The API-Server must be reachable from your computer and you need to have a valid Kube-Config. Additionally, we assume that all required certificates are contained in the Kube-Config file. If this is not the case, please copy the certificates plain into the Kube-Conf file. Example:
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://localhost:6443
name: docker-for-desktop-cluster
contexts:
- context:
cluster: ""
namespace: default
user: ""
name: default-context
- context:
cluster: docker-for-desktop-cluster
user: docker-for-desktop
name: docker-for-desktop
current-context: docker-for-desktop
kind: Config
preferences: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