kubectl get pods, kubectl get deployments, or kubectl get services, you’ll notice that no resources have been created yet.
Kustomize focuses on building configurations. To deploy these configurations, you must combine it with the
kubectl apply command.Deploying Generated Configurations
To deploy your configurations, you can chain the Kustomize build command with thekubectl apply command using the Linux pipe (|). The command below demonstrates how to build and immediately apply the configurations from the k8s/ directory:
kustomize build k8s/ and supplies it as the input to kubectl apply -f -. This method leverages the familiar kubectl apply command to create resources like the nginx deployment and the nginx service.
Alternatively, the kubectl command includes native support for Kustomize. By using the -k flag, you can apply configurations directly from the directory containing your kustomization.yaml file:
Deleting Resources Using Kustomize
Removing resources works in a similar way to deploying them. You simply replace the wordapply with delete. This section demonstrates how to delete resources with both methods.
Using the Pipe Method
The following command uses the pipe utility to delete the previously created resources:Using the Native kubectl Command
You can also use thekubectl command with the -k flag to delete the resources:
kubectl. For more details on using Kubernetes tools and best practices, refer to the Kubernetes Documentation.