Managing Directories - Solution
Managing Directories - Solution
- Example
kustomization.yamlfile:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# kubernetes resources to be managed by kustomize
resources:
- db/db-config.yaml
- db/db-depl.yaml
- db/db-service.yaml
- message-broker/rabbitmq-config.yaml
- message-broker/rabbitmq-depl.yaml
- message-broker/rabbitmq-service.yaml
- nginx/nginx-depl.yaml
- nginx/nginx-service.yaml
- An example of creating a
kustomization.yamlfile per directory:controlplane ~/code ➜ tree . └── k8s ├── db │ └── kustomization.yaml ├── kustomization.yaml ├── message-broker │ └── kustomization.yaml └── nginx └── kustomization.yaml 4 directories, 12 files - What the
kustomization.yamlfile would look like fork8s/dbfor example: ``` resources:- db-depl.yaml
- db-service.yaml
- db-config.yaml ```
- In the root
k8sdirectory, what thekustomization.yamlfile would also look like: ``` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization
kubernetes resources to be managed by kustomize
resources:
- db/
- message-broker/
-
nginx/ #Customizations that need to be made ```
- How you would then apply the customisations:
controlplane ~/code ➜ kubectl apply -k /root/code/k8s/ --------------OR--------------- controlplane ~/code ➜ kustomize build /root/code/k8s/ | kubectl apply -f -