kubectl get pods, kubectl get deployments, or kubectl get services right after the build will not show any new resources.
Even though Kustomize outputs the final configuration, you must still deploy it to activate the resources on your cluster.
Deploying Configurations Using Pipes
To deploy the generated configurations, you can use the Linux pipe utility. This allows you to feed the output of the Kustomize build directly into the Kubernetes API using thekubectl apply command. Here’s an example:
|) directs the output from kustomize build k8s/ into kubectl apply -f -, thus creating the nginx deployment and its corresponding service.
Deploying Configurations Natively with kubectl
Alternatively, you can accomplish the same deployment natively with kubectl using the-k flag. This flag tells kubectl to locate and process the kustomization.yaml file in the specified directory:
Deleting Configurations
Removing resources deployed via Kustomize is almost identical to applying them. You simply replace the wordapply with delete.
Using the Pipe Method
Delete the resources using the pipe method by running:Using kubectl with the -k Flag
Or, delete the resources natively with kubectl:Both methods are effective, so you can choose the one that best fits your workflow. The native kubectl approach with the
-k flag simplifies the process by eliminating the need to use a pipe.