// Module included in the following assemblies:
//
// * microshift/using-config-tools.adoc

:_content-type: CONCEPT
[id="microshift-auto-apply-manifests_{context}"]
= Automatically applying manifests with the kustomize tool

Providing multiple directories allows a flexible method of managing {product-title} workloads. When you run the `kustomize` configuration management tool, {product-title} searches the `/etc/microshift/manifests` and `/usr/lib/microshift/` manifest directories for a `kustomization.yaml` file. If it finds one, {product-title} automatically runs the `kubectl apply -k` command to apply the manifests to the cluster.

[IMPORTANT]
====
The `kustomize` tool must be either running as a separate step in the boot process, or it must be part of the {product-title} image.
====

[cols="2",options="header"]
|===
|Location
|Intent

|`/etc/microshift/manifests`
|Read-write location for configuration management systems or development.

|`/usr/lib/microshift/manifests`
|Read-only location for embedding configuration manifests on OSTree-based systems.
|===

[id="microshift-manifests-example_{context}"]
== Manifest example
This example demonstrates automatic deployment of a BusyBox container using `kustomize` manifests in the `/etc/microshift/manifests` directory.

.Procedure
. Create the BusyBox manifest files by running the following commands:
+
.. Define the directory location:
+
[source,terminal]
----
$ MANIFEST_DIR=/etc/microshift/manifests
----
+
.. Make the directory:
+
[source,terminal]
----
$ sudo mkdir -p ${MANIFEST_DIR}
----
+
.. Place the YAML file in the directory:
+
[source,terminal]
----
$ sudo cat << EOF > ${MANIFEST_DIR}/busybox.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: busybox
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox-deployment
spec:
  selector:
    matchLabels:
      app: busybox
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
      - name: busybox
        image: BUSYBOX_IMAGE
        command:
          - sleep
          - "3600"
EOF
----
.Procedure
. Create the `kustomize` manifest files by running the following commands:
+
.. Place the YAML file in the directory:
+
[source,terminal]
----
$ sudo cat << EOF > ${MANIFEST_DIR}/kustomization.yaml
----
.. Apply the YAML configuration:
+
[source,terminal]
----
$ {MANIFEST_DIR}/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: busybox
---
resources:
  - busybox.yaml
images:
  - name: BUSYBOX_IMAGE
    newName: registry.k8s.io/busybox
EOF
----

. Restart {product-title} to apply the manifests by running the following command:
+
[source,terminal]
----
$ sudo systemctl restart microshift
----
+
. Apply the manifests and start the BusyBox pod by running the following command:
+
[source,terminal]
----
$ oc get pods -n busybox
----
