
kubectl apply command as shown below:
-f flags:
Using multiple
-f flags simplifies bulk deployment and deletion. However, as your infrastructure grows, managing these commands can become cumbersome.Simplifying Resource Management with Kustomize
Kustomize makes it easier to manage and customize your application configurations. Begin by creating akustomization.yaml file in the root of your K8s directory. This file specifies the API version and kind required by Kustomize:
kustomization.yaml file’s location. For example:
kustomize build displays the resulting configuration, it does not apply it to your cluster. To deploy these resources, pipe the output to kubectl apply:
-k flag:
For quick troubleshooting, always verify your pods’ status with
kubectl get pods after deploying configurations.Advanced Directory Structuring with Kustomize
While maintaining a singlekustomization.yaml in the root directory works for simple projects, a more scalable practice is to include a kustomization.yaml file in each subdirectory. In this method, each directory imports only the YAML files specific to its component, while a root kustomization.yaml aggregates these directories.
API Directory Configuration
In the API folder, create akustomization.yaml that lists the API deployment and service manifests:
Cache Directory Configuration
In the cache directory, set up the followingkustomization.yaml:
Database Directory Configuration
Similarly, for the database directory, create akustomization.yaml:
Root Directory Aggregation
Finally, update the rootkustomization.yaml to reference these subdirectories. When a directory is specified as a resource, Kustomize automatically searches for a kustomization.yaml file inside: