Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to kustomize per review #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions Kustomize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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
```


Expand All @@ -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

Expand All @@ -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

Expand All @@ -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.



Expand All @@ -131,21 +137,24 @@ 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
# You should now see production in the list
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:
Expand All @@ -171,22 +180,18 @@ spec:


# Navigate back to root
cd..
cd..
cd ../..

# Write customizations to screen
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.