Chapter 1. Using Kustomize manifests to deploy applications
You can use the kustomize configuration management tool with application manifests to deploy applications on MicroShift.
Read through the following procedures for an example of how Kustomize works in MicroShift.
1.1. How Kustomize works with manifests to deploy applications Copy linkLink copied to clipboard!
The kustomize configuration management tool is integrated with MicroShift. You can use Kustomize and the OpenShift CLI (oc) together to apply customizations to your application manifests and deploy those applications to a MicroShift node.
-
A
kustomization.yamlfile is a specification of resources plus customizations. -
Kustomize uses a
kustomization.yamlfile to load a resource, such as an application, then applies any changes you want to that application manifest and produces a copy of the manifest with the changes overlaid. - Using a manifest copy with an overlay keeps the original configuration file for your application intact, while enabling you to deploy iterations and customizations of your applications efficiently.
-
You can then deploy the application in your MicroShift node with an
occommand.
At each system start, MicroShift deletes the manifests found in the delete subdirectories and then applies the manifest files found in the manifest directories to the node.
1.1.1. How MicroShift uses manifests Copy linkLink copied to clipboard!
At every start, MicroShift searches the following manifest directories for Kustomize manifest files:
-
/etc/microshift/manifests -
/etc/microshift/manifests.d/* -
/usr/lib/microshift/ -
/usr/lib/microshift/manifests.d/*
MicroShift automatically runs the equivalent of the kubectl apply -k command to apply the manifests to the node if any of the following file types exists in the searched directories:
-
kustomization.yaml -
kustomization.yml -
Kustomization
This automatic loading from multiple directories means you can manage MicroShift workloads with the flexibility of having different workloads run independently of each other.
| Location | Intent |
|---|---|
|
| Read-write location for configuration management systems or development. |
|
| Read-write location for configuration management systems or development. |
|
| Read-only location for embedding configuration manifests on OSTree-based systems. |
|
| Read-only location for embedding configuration manifests on OSTree-based systems. |
1.2. Override the list of manifest paths Copy linkLink copied to clipboard!
You can override the list of default manifest paths by using a new single path, or by using a new glob pattern for multiple files.
Use the following procedure to customize your manifest paths.
Procedure
Override the list of default paths by inserting your own values and running one of the following commands:
-
Set
manifests.kustomizePathsto<"/opt/alternate/path">in the configuration file for a single path. Set
kustomizePathsto,"/opt/alternative/path.d/*".in the configuration file for a glob pattern.manifests: kustomizePaths: - <location>Replace
<location>with the path to the manifest directory. Set each location entry to an exact path by using"/opt/alternate/path"or a glob pattern by using"/opt/alternative/path.d/*".
-
Set
To disable loading manifests, set the configuration option to an empty list.
manifests: kustomizePaths: []NoteThe configuration file overrides the defaults entirely. If the
kustomizePathsvalue is set, only the values in the configuration file are used. Setting the value to an empty list disables manifest loading.
1.3. Using manifests example Copy linkLink copied to clipboard!
You can automatically deploy a BusyBox container on MicroShift by using kustomize manifests in the /etc/microshift/manifests directory.
Procedure
Create the BusyBox manifest files by running the following commands:
Define the directory location:
$ MANIFEST_DIR=/etc/microshift/manifestsMake the directory:
$ sudo mkdir -p ${MANIFEST_DIR}Place the YAML file in the directory:
sudo tee ${MANIFEST_DIR}/busybox.yaml &>/dev/null <<EOF apiVersion: v1 kind: Namespace metadata: name: busybox --- apiVersion: apps/v1 kind: Deployment metadata: name: busybox namespace: busybox-deployment spec: selector: matchLabels: app: busybox template: metadata: labels: app: busybox spec: containers: - name: busybox image: BUSYBOX_IMAGE command: [ "/bin/sh", "-c", "while true ; do date; sleep 3600; done;" ] EOF
Next, create the
kustomizemanifest files by running the following commands:Place the YAML file in the directory:
sudo tee ${MANIFEST_DIR}/kustomization.yaml &>/dev/null <<EOF apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: busybox resources: - busybox.yaml images: - name: BUSYBOX_IMAGE newName: busybox:1.35 EOF
Restart MicroShift to apply the manifests by running the following command:
$ sudo systemctl restart microshiftApply the manifests and start the
busyboxpod by running the following command:$ oc get pods -n busybox