Skip to content

Latest commit

 

History

History

kubeapply-test-cluster

kubeapply-test-cluster

This directory contains examples of different kinds of kubeapply configs. The sections below describe how to run through a typical kubeapply workflow and provision the associated resources in a small, local cluster.

Prerequisites

Make sure you've installed kubeapply and all of the dependencies described in the main README.

Then, install kind, which we'll use to run a local cluster. It's also possible to run this example against something like minikube or a real, remote cluster, but you'll need to alter some of the steps below.

Directory layout

The following are included at the top-level:

Path Description
cluster-local1.yaml Cluster config for first version of our test cluster. Contains basic information about the cluster as well as parameters for template expansion and/or starlark evaluation.
cluster-local2.yaml Cluster config for alternative version of the test cluster. Uses same profile as first version, but has different expansion parameters. Not used in sample workflow below, but left as an example of how different cluster instances in different environments and/or regions might be configured.
charts Contains an example envoy chart that's referred to in the profile. kubeapply can also source charts from git, http, or s3.
expanded Expanded Kubernetes configs generated by running kubeapply expand. These can be applied in the cluster by running kubeapply apply or directly via kubectl apply.
profile Source templates and starlark files for our cluster, used by kubeapply expand to fill out the expanded directory.

The profile directory contains configs for three "services", each of which demonstrates a different way of specifying configs for expansion:

Service Description
echoserver Uses plain Kubernetes YAML and go-templated YAML.
envoy Uses the envoy Helm chart to generate configs for an Envoy deployment.
redis Uses skycfg, which evaluates starlark to generate configs.

Workflow

The steps below use the provided Makefile for convenience, but you can also just run the associated kubeapply commands directly.

(1) make start-kind

Starts up a local cluster via kind and dumps a kubeconfig in .kube/kubeapply-test-cluster.yaml.

(2) make expand

Expands configs from profile into the expanded directory for cluster-local1. It should be a no-op from the git perspective unless you've made changes in the cluster config or profile files.

(3) make validate

Runs kubeconform over the expanded configs to validate that they are legitimate Kubernetes configs before continuing.

(4) make diff

Runs kubectl diff against the local cluster and shows the results in a pretty format in the terminal.

(5) make apply

Runs kubectl apply against the local cluster and outputs a table that summarizes the changes that were made.

(6) kubectl ...

Run kubectl --kubeconfig=.kube/kubeapply-test-cluster.yaml get pods --all-namespaces, etc. to verify that the apply worked correctly!

(7) make stop-kind

Stops local cluster created in first step and deletes the kubeconfig.