From 396764fc9f8d4ab47b107e504872929a2850a706 Mon Sep 17 00:00:00 2001 From: Rick Rainey Date: Thu, 27 May 2021 13:46:39 -0500 Subject: [PATCH] Updates to kustomize per review --- Kustomize/README.md | 47 +++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/Kustomize/README.md b/Kustomize/README.md index 5e3ed7e..329b7ea 100644 --- a/Kustomize/README.md +++ b/Kustomize/README.md @@ -3,7 +3,7 @@ ## Introduction -Kubernetes relies on YAML for deployment definitions. As you applications grow and more services, application and namespaces are added, these YAML definitions can become hard to manage. Add several different environments such as UAT and Production and DevOps, mistakes to your cluster are inevitable. +Kubernetes relies on YAML for deployment definitions. As your applications grow and more services, applications, and namespaces are added, these YAML definitions can become hard to manage. Add several different environments such as UAT and Production and DevOps, mistakes to your cluster are inevitable. [kustomize](https://kustomize.io/#overview) is built-in to kubectl and assists in managing templates. @@ -24,7 +24,7 @@ Execute the commands below from a bash command shell. Assure you are in the dire ```bash # Apply deployment to the cluster -kubectl apply -f 01-pod-storage.yaml +kubectl apply -f ./storage/01-pod-storage.yaml # List the pod that was created kubectl get pods @@ -39,7 +39,7 @@ kubectl port-forward [pod-name] 8080:80 # Press Ctrl-c to terminate the port forwarding. # Delete the deployment -kubectl delete -f 01-pod-storage.yaml +kubectl delete -f ./storage/01-pod-storage.yaml ``` @@ -63,22 +63,26 @@ The basics steps include: ```bash # View your current namespaces -# You should see defaults +# You should see a few namespaces, such as default, kube-system, and others. kubectl get ns # Create a new namespace for UAT kubectl create ns uat # View your current namespaces -# You should now see UAT in the list +# You should now see "uat" in the list kubectl get ns -# Create a directory to hold your base image -MD UAT +# Create a directory to hold your base configuration +md UAT + +# Navigate to the UAT directory +cd UAT # Copy the 01-pod-storage.yaml to this directory. This will be our "base" +cp ../storage/01-pod-storage.yaml 01-pod-storage.yaml -# Create a new yaml file named kustomization.yaml and add the below +# Create a new yaml file named kustomization.yaml and add the content below apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization @@ -91,6 +95,8 @@ resources: # Confirm you are in the root of your project (one directory above the UAT folder) +cd .. + # Test/Debug you customization, you should see UAT as the namespace kubectl kustomize uat @@ -111,7 +117,7 @@ kubectl get pods -n uat ``` ### Summary -In this step you learned about isolating deployments in their own namespaces with Kustomize. We also show a few ways to display the customized templates, screen and to file. We also deployed the customizations directly to the cluster. +In this step you learned about isolating deployments in their own namespaces with Kustomize. We also observed a few ways to display the customized templates, screen and to file. Finally, we deployed the customizations directly to the cluster. @@ -131,7 +137,7 @@ The basics steps include: # View your current namespaces kubectl get ns -# Create a new namespace for UAT +# Create a new namespace for production kubectl create ns production # View your current namespaces @@ -139,13 +145,16 @@ kubectl create ns production kubectl get ns # Create a directory to hold overlays -MD overlays +md overlays # Navigate to the overlays directory -CD overlays +cd overlays + +# Create a production folder +md production -# Create a Production folder -MD Production +# Navigate to the Production directory +cd production # Create a new yaml named kustomization.yaml bases: @@ -171,8 +180,7 @@ spec: # Navigate back to root -cd.. -cd.. +cd ../.. # Write customizations to screen kubectl kustomize overlays/production @@ -180,13 +188,10 @@ kubectl kustomize overlays/production # Deploy to cluster kubectl apply -k overlays/production -# Look for pods in the Production namespace +# Look for pods in the production namespace # Pods are now visable and scaled to 10 in the production namespace kubectl get pods -n production ``` ### Summary -In this tutorial, we created a new production overlay and merged in a scale.yaml to scale our cluster. UAT and Production are usually similar but different in scale. kustomize helps keep the namespaces and yamls manageable. - - - +In this tutorial, we created a new production overlay and merged in a `scale.yaml` to scale our cluster. UAT and Production are usually similar but different in scale. kustomize helps keep the namespaces and yamls manageable.