|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * microshift/using-config-tools.adoc |
| 4 | + |
| 5 | +:_content-type: CONCEPT |
| 6 | +[id="microshift-auto-apply-manifests_{context}"] |
| 7 | += Automatically applying manifests with `kustomize` |
| 8 | + |
| 9 | + 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. |
| 10 | + |
| 11 | +[IMPORTANT] |
| 12 | +==== |
| 13 | +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. |
| 14 | +==== |
| 15 | + |
| 16 | +[cols="2",options="header"] |
| 17 | +|=== |
| 18 | +|Location |
| 19 | +|Intent |
| 20 | + |
| 21 | +|`/etc/microshift/manifests` |
| 22 | +|Read-write location for configuration management systems or development. |
| 23 | + |
| 24 | +|`/usr/lib/microshift/manifests` |
| 25 | +|Read-only location for embedding configuration manifests on OSTree-based systems. |
| 26 | +|=== |
| 27 | + |
| 28 | +[id="microshift-manifests-example_{context}"] |
| 29 | +== Manifest example |
| 30 | +This example demonstrates automatic deployment of a BusyBox container using `kustomize` manifests in the `/etc/microshift/manifests` directory. |
| 31 | + |
| 32 | +.Procedure |
| 33 | +. Create the BusyBox manifest files by running the following commands: |
| 34 | ++ |
| 35 | +* Define the directory location. |
| 36 | ++ |
| 37 | +[source,terminal] |
| 38 | +---- |
| 39 | +$ MANIFEST_DIR=/etc/microshift/manifests |
| 40 | +---- |
| 41 | ++ |
| 42 | +* Make the directory by running the following command: |
| 43 | ++ |
| 44 | +[source,terminal] |
| 45 | +---- |
| 46 | +$ sudo mkdir -p ${MANIFEST_DIR} |
| 47 | +---- |
| 48 | ++ |
| 49 | +* Place the `yaml` file in the directory. |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +$ sudo tee ${MANIFEST_DIR}/busybox.yaml &>/dev/null <<EOF |
| 54 | +
|
| 55 | +apiVersion: v1 |
| 56 | +kind: Namespace |
| 57 | +metadata: |
| 58 | + name: busybox |
| 59 | +--- |
| 60 | +apiVersion: apps/v1 |
| 61 | +kind: Deployment |
| 62 | +metadata: |
| 63 | + name: busybox-deployment |
| 64 | +spec: |
| 65 | + selector: |
| 66 | + matchLabels: |
| 67 | + app: busybox |
| 68 | + template: |
| 69 | + metadata: |
| 70 | + labels: |
| 71 | + app: busybox |
| 72 | + spec: |
| 73 | + containers: |
| 74 | + - name: busybox |
| 75 | + image: BUSYBOX_IMAGE |
| 76 | + command: |
| 77 | + - sleep |
| 78 | + - "3600" |
| 79 | +---- |
| 80 | +// what are the "---" after name: busybox? |
| 81 | +.Procedure |
| 82 | +. Create the `kustomize` manifest files by running the following commands: |
| 83 | ++ |
| 84 | +* Run the command to read and write the standard inputs. |
| 85 | +[source,terminal] |
| 86 | ++ |
| 87 | +---- |
| 88 | +$ sudo tee |
| 89 | +---- |
| 90 | +* Apply the `yaml` configuration. |
| 91 | ++ |
| 92 | +[source,terminal] |
| 93 | +---- |
| 94 | +$ {MANIFEST_DIR}/kustomization.yaml &>/dev/null |
| 95 | +
|
| 96 | +apiVersion: kustomize.config.k8s.io/v1beta1 |
| 97 | +kind: Kustomization |
| 98 | +namespace: busybox |
| 99 | +resources: |
| 100 | + - busybox.yaml |
| 101 | +images: |
| 102 | + - name: BUSYBOX_IMAGE |
| 103 | + newName: registry.k8s.io/busybox |
| 104 | +---- |
| 105 | + |
| 106 | +. Restart {product-title} to apply the manifests and verify that the BusyBox pod is running by running the following commands: |
| 107 | ++ |
| 108 | +* Restart {product-title}. |
| 109 | ++ |
| 110 | +[source,terminal] |
| 111 | +---- |
| 112 | +$ sudo systemctl restart microshift |
| 113 | +---- |
| 114 | ++ |
| 115 | +* Apply the manifests and start the BusyBox pod. |
| 116 | ++ |
| 117 | +[source,terminal] |
| 118 | +---- |
| 119 | +$ oc get pods -n busybox |
| 120 | +---- |
| 121 | + |
| 122 | +// what's the verification look like? |
0 commit comments