#Â Hands-on Lab: Helm Installation on Windows, macOS, and EC2 Linux2# Hands-on Lab: Helm Installation on Windows, macOS, and EC2 Linux2
In this hands-on lab, we will cover how to install and configure Helm on three different platforms: Windows, macOS, and EC2 (Amazon Linux 2).
## Overview of Helm
Helm is a package manager for Kubernetes that helps you define, install, and upgrade complex Kubernetes applications. It uses charts, which are packages of pre-configured Kubernetes resources.
### Prerequisites:
- Kubernetes cluster (e.g., Minikube, AKS, GKE, or EKS)
- `kubectl` installed and configured
- Administrative privileges on the machine
##Â 1. Helm Installation on Windows
### Step 1: Install Helm using Chocolatey (recommended)
#### Install Chocolatey (if not already installed):
1. Open as Administrator and run the following command to install Chocolatey:
   Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
#### Install Helm using Chocolatey:
2. After Chocolatey is installed, run the following command to install Helm:
choco install kubernetes-helm
#### Verify the Helm installation:
3. To verify the installation, run:
helm version
  Â
   This should display the version of Helm installed.
### Step 2: Install Helm manually (if Chocolatey is not available)
#### Download the Helm binary:
1. Go to the [official Helm releases page](https://github.com/helm/helm/releases) and download the latest Helm binary for Windows (`helm-v3.x.x-windows-amd64.zip`).
#### Extract the zip file:
2. Extract the contents of the downloaded zip file.
#### Move Helm to a directory in your PATH:
3. Move `helm.exe` to a folder that is in your system’s PATH, e.g., `C:\Program Files\Helm`.
#### Verify Helm Installation:
4. Open or Command Prompt and run:
helm version
##Â 2. Helm Installation on macOS
### Step 1: Install Helm using Homebrew (recommended)
#### Install Homebrew (if not already installed):
1. Open Terminal and run the following command to install Homebrew:
 /bin/1 -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#### Install Helm using Homebrew:
2. Run the following command to install Helm:
brew install helm
#### Verify Helm installation:
3. To verify the installation, run:
 helm version
### Step 2: Install Helm manually (if Homebrew is not available)
#### Download Helm binary for macOS:
1. Go to the [official Helm releases page](https://github.com/helm/helm/releases) and download the latest Helm binary for macOS (`helm-v3.x.x-darwin-amd64.tar.gz`).
#### Extract the tar.gz file:
2. Use the following command to extract the file:
 tar -zxvf helm-v3.x.x-darwin-amd64.tar.gz
#### Move Helm to a directory in your PATH:
3. Move the extracted Helm binary to `/usr/local/bin`:
sudo mv darwin-amd64/helm /usr/local/bin/helm
#### Verify Helm installation:
4. To verify the installation, run:
  helm version
##Â 3. Helm Installation on EC2 Amazon Linux 2
### Step 1: Install Helm using yum (if Helm is available in the package manager)
#### Update the system:
1. SSH into your EC2 instance and update the system:
sudo yum update -y
#### Install Helm using yum:
2. Run the following command to install Helm (note that the Helm package may not be available directly on Amazon Linux 2 in all cases):
sudo yum install helm -y
#### Verify Helm installation:
3. To verify the installation, run:
helm version
### Step 2: Install Helm manually (recommended for EC2)
#### Download Helm binary for Linux:
1. Use `curl` to download the latest Helm binary for Linux from the [official Helm GitHub releases page](https://github.com/helm/helm/releases):
curl -LO https://get.helm.sh/helm-v3.x.x-linux-amd64.tar.gz
#### Extract the tar.gz file:
2. Extract the Helm binary:
tar -zxvf helm-v3.x.x-linux-amd64.tar.gz
#### Move Helm to `/usr/local/bin`:
3. Move the Helm binary to a location in the system’s PATH:
sudo mv linux-amd64/helm /usr/local/bin/helm
#### Verify Helm installation:
4. To verify the installation, run:
helm version
## Step 4: Configure Helm
Once Helm is installed on your system, you need to initialize Helm and set up the Helm repositories.
### Initialize Helm:
For Helm v3, initialization is not required, but ensure you are connected to a Kubernetes cluster:
kubectl config use-context <your-cluster-context>
### Add the official Helm charts repository:
Run the following command to add the official Helm stable charts repository:
helm repo add stable https://charts.helm.sh/stable
### Update Helm repositories:
After adding the repository, update it:
helm repo update
### Search for available charts:
To verify the available charts, use the following command:
helm search repo stable
## Step 5: Install a Helm Chart (Example: Installing WordPress)
### Install WordPress with Helm:
Use Helm to install WordPress and its dependencies:
helm install my-wordpress stable/wordpress
### Check the status of the installation:
After installation, check the status:
helm status my-wordpress
### Verify the deployment:
Check the resources created by Helm:
kubectl get all
### Access the WordPress service:
Get the external IP to access the WordPress site:
kubectl get svc my-wordpress
Open the browser and go to the `EXTERNAL-IP` of the WordPress service.
## Step 6: Uninstall Helm Chart
### Uninstall WordPress:
To uninstall the WordPress release, use the following command:
helm uninstall my-wordpress
### Verify the removal:
Verify that the resources have been removed:
kubectl get all
## Conclusion
You have now successfully installed and configured Helm on Windows, macOS, and EC2 Linux 2. You also deployed and managed an application using Helm, specifically WordPress, to understand the full deployment process.
### Hands-on Lab: Deploying Kubernetes Dashboard Using Helm with NodePort Service and Helm Chart Verification
In this hands-on lab, we will deploy the Kubernetes Dashboard using Helm, expose it with a NodePort service, check the Helm installation with Helm commands, and modify the service type from ClusterIP to NodePort using `kubectl edit`.
### Prerequisites:
- A running Kubernetes cluster (e.g., Minikube, AKS, GKE, EKS, or on-prem).
- Helm installed and configured on your local machine.
- `kubectl` installed and configured.
### Step 1: Add the Kubernetes Dashboard Helm Chart Repository
1. Add the official Helm chart repository for the Kubernetes Dashboard:
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
2. Update Helm repositories to ensure you have the latest charts:
helm repo update
### Step 2: Check Helm Installation
Before proceeding with the installation, verify that Helm is installed and properly configured.
1. Check the version of Helm:
helm version
This will display the installed version of Helm.
2. List all Helm repositories:
helm repo list
This will show the list of repositories added, including the Kubernetes Dashboard repository.
3. Verify the available charts in the repository:
helm search repo kubernetes-dashboard
This will search the `kubernetes-dashboard` repository and show available charts.
4. Check if a release is already installed (optional):
helm ls --all-namespaces
This will list all releases installed in your cluster, including the Kubernetes Dashboard if it’s already installed.
### Step 3: Install Kubernetes Dashboard Using Helm
Install the Kubernetes Dashboard using Helm:
helm install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard
This command installs the dashboard with default settings. The release name is `kubernetes-dashboard` and the chart used is `kubernetes-dashboard/kubernetes-dashboard`.
### Step 4: Verify the Installation
1. Check the resources created by the Helm deployment:
kubectl get all -n kube-system
You should see pods, services, and deployments related to the `kubernetes-dashboard`.
2. Check the status of the deployed pods:
kubectl get pods -n kube-system
Ensure that the `kubernetes-dashboard` pod is running.
### Step 5: Change the Service Type to NodePort
By default, the Kubernetes Dashboard is exposed via a `ClusterIP` service, which is accessible only within the Kubernetes cluster. Change the service type to `NodePort` to access the dashboard externally.
1. Edit the service using `kubectl edit`:
kubectl edit svc kubernetes-dashboard -n kube-system
2. Modify the service type:
- Find the `type: ClusterIP` line under the `spec` section and change it to `type: NodePort`. The modified section should look like this:
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 32001 # You can set any available nodePort
3. Save and exit the editor. Kubernetes will automatically apply the changes.
4. Verify that the service type has been updated:
kubectl get svc kubernetes-dashboard -n kube-system
You should now see the `kubernetes-dashboard` service with `NodePort` as the type and a `nodePort` assigned.
### Step 6: Access the Dashboard
1. Access the Kubernetes Dashboard in your browser:
- Open your browser and navigate to the following URL:
http://<NodeIP>:32001
Replace `<NodeIP>` with the IP address of your node or the external IP of your Kubernetes cluster.
### Step 7: Authenticate to the Kubernetes Dashboard
You will need to authenticate to the Kubernetes Dashboard. This can be done using either a token or kubeconfig.
#### Method 1: Using a Token (Recommended)
1. Create a ServiceAccount with access to the Kubernetes Dashboard:
- Create a file named `admin-service-account.yaml`:
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
- Apply the file:
kubectl apply -f admin-service-account.yaml
2. Create a `ClusterRoleBinding` to grant the ServiceAccount `cluster-admin` privileges:
- Create a file named `admin-role-binding.yaml`:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
- Apply the file:
kubectl apply -f admin-role-binding.yaml
3. Get the authentication token for the `admin-user` ServiceAccount:
kubectl -n kube-system create token admin-user
Copy the token output from this command.
4. Authenticate using the token:
- Go to the Kubernetes Dashboard in your browser and choose Token as the authentication method.
- Paste the token you copied earlier and click Sign In.
#### Method 2: Using kubeconfig
Use the kubeconfig file during the dashboard login process.
### Step 8: Verify Dashboard Access and Functionality
After logging in, you should see the Kubernetes Dashboard with an overview of your cluster and resources. Explore sections such as:
- Workloads: Pods, Deployments, ReplicaSets, etc.
- Services and Discovery: View services running in the cluster.
- Storage: Persistent Volumes, Persistent Volume Claims, etc.
### Step 9: Clean Up (Optional)
1. Uninstall the Kubernetes Dashboard:
helm uninstall kubernetes-dashboard
2. Remove the ServiceAccount and ClusterRoleBinding:
kubectl delete -f admin-service-account.yaml
kubectl delete -f admin-role-binding.yaml
### Conclusion
You have successfully deployed the Kubernetes Dashboard using Helm, changed the service type to NodePort, and accessed it externally. You also learned how to check Helm chart installations, verify their status, and authenticate to the dashboard using a ServiceAccount token. This lab provides a complete overview of managing the Kubernetes Dashboard with Helm and securely exposing it.
### Hands-on Lab: Installing Prometheus with Helm
This lab will guide you through installing Prometheus on your Kubernetes cluster using Helm. We will configure the Helm chart, install Prometheus, and access both the Prometheus and Grafana dashboards for monitoring. Additionally, we will cover accessing logs and checking the configuration.
#### Prerequisites:
- A running Kubernetes cluster (e.g., Minikube, AKS, GKE, EKS, or on-prem).
- Helm installed and configured on your local machine.
- kubectl installed and configured.
### Step 1: Add the Prometheus Helm Chart Repository
Add the Prometheus Community Helm repository to your local Helm configuration:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
### Step 2: Search for Prometheus Charts
To check if the Prometheus Helm charts are available, run the following command:
helm search repo prometheus-community
This will list all available Prometheus-related charts from the repository.
### Step 3: Explore Default Values of the Prometheus Chart
You can view the default configuration values for the Prometheus Helm chart by running:
helm show values prometheus-community/kube-prometheus-stack
To save these values for modification:
helm show values prometheus-community/kube-prometheus-stack > prom-values.yml
### Step 4: Create a Namespace for Prometheus
Create a dedicated namespace for Prometheus to keep all related resources isolated:
kubectl create namespace prometheus
### Step 5: Install Prometheus Using Helm
Install Prometheus using the Helm chart in the `prometheus` namespace:
helm install prometheus prometheus-community/kube-prometheus-stack -n prometheus
### Step 6: Verify the Installation
Check the resources created by Helm:
kubectl get all -n prometheus
Check the pods running in the `prometheus` namespace:
kubectl get pods -n prometheus
Describe the Prometheus StatefulSet:
kubectl describe statefulsets prometheus-prometheus-prometheus-oper-prometheus -n prometheus > prom.yml
Check the ConfigMaps:
kubectl get configmap prometheus-prometheus-prometheus-oper-prometheus-rulefiles-0 -n prometheus
### Step 7: Modify Service Types
By default, some services might be exposed as `ClusterIP`. To access them externally, change the service type to `NodePort` or `LoadBalancer`.
#### Edit the Prometheus Service:
kubectl edit svc prometheus-prometheus-oper-prometheus -n prometheus
Change the service type to `NodePort` under the `spec` section:
spec:
type: NodePort
Verify the changes:
kubectl get svc -n prometheus
#### Edit the Grafana Service:
kubectl edit svc prometheus-grafana -n prometheus
Verify the changes:
kubectl get svc -n prometheus
### Step 8: Port-Forward to Access Grafana and Prometheus (for Minikube only)
#### Grafana:
To port-forward the Grafana service:
kubectl port-forward service/prometheus-grafana 31077:80 -n prometheus
Now, access Grafana at: [http://localhost:31077](http://localhost:31077)
#### Prometheus:
To port-forward the Prometheus service:
kubectl port-forward service/prometheus-kube-prometheus-prometheus 30469:9090 -n prometheus
Now, access Prometheus at: [http://localhost:30469](http://localhost:30469)
#### On macOS:
Retrieve the IP address:
ipconfig getifaddr en0
Forward traffic with the retrieved IP address:
kubectl port-forward --address <IP_ADDRESS> svc/prometheus-grafana 31077:80 -n prometheus
kubectl port-forward --address <IP_ADDRESS> svc/prometheus-kube-prometheus-prometheus 30469:9090 -n prometheus
Replace `<IP_ADDRESS>` with the actual IP address.
### Step 9: Check Logs of a Container Inside a Pod
#### Grafana Logs:
kubectl logs prometheus-grafana-<POD_NAME> -c grafana -n prometheus
Replace `<POD_NAME>` with the actual pod name.
#### Retrieve Grafana Credentials:
kubectl get secret --namespace prometheus prometheus-grafana -o yaml
Decode the base64-encoded secret:
echo "<base64-encoded-secret>" | base64 --decode
Replace `<base64-encoded-secret>` with the actual secret data.
### Step 10: Clean Up (Optional)
#### Uninstall Prometheus:
helm uninstall prometheus -n prometheus
#### Delete the Namespace:
kubectl delete namespace prometheus
### Conclusion
In this hands-on lab, you successfully:
- Installed Prometheus using Helm.
- Configured services to use `NodePort`.
- Port-forwarded to access both Grafana and Prometheus dashboards.
- Checked logs and retrieved secrets for Grafana.
You now have a fully functioning monitoring stack with Prometheus and Grafana in your Kubernetes cluster.
### Hands-on Lab: Creating, Validating, Deploying, and Managing a Helm Chart
This hands-on lab will guide you through creating a Helm chart for deploying a web application, validating its syntax, deploying it to a Kubernetes cluster, and managing its lifecycle. The lab includes steps for `helm lint` and `helm template` validation.
### Scenario
Create a Helm chart for deploying a web application, validate its syntax, deploy it, and manage its lifecycle effectively.
### Steps for the Hands-on Lab
#### 1. Prerequisites
- A running Kubernetes cluster.
- `kubectl` and `helm` CLI tools installed and configured.
#### 2. Create a Helm Chart
1. Generate the Helm Chart:
helm create web
2. Navigate to the Chart Directory:
cd web
3. Understand the Chart Directory:
tree
Key files:
- `Chart.yaml`: Metadata about the chart.
- `values.yaml`: Default configuration values.
- `templates/`: Kubernetes manifests with templating syntax.
#### 3. Customize the Helm Chart
1. Rename `values.yaml` to `nginx-values.yml` and modify the default configuration:
appName: nginx
appReplicas: 3
containerPort: 80
appImage: nginx
appVersion: latest
serviceType: NodePort
servicePort: 80
2. Edit the Deployment Template:
Update `templates/deployment.yaml`:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.appName }}
spec:
replicas: {{ .Values.appReplicas }}
selector:
matchLabels:
app: {{ .Values.appName }}
template:
metadata:
labels:
app: {{ .Values.appName }}
spec:
containers:
- name: {{ .Values.appName }}
image: "{{ .Values.appImage }}:{{ .Values.appVersion }}"
ports:
- containerPort: {{ .Values.containerPort }}
3. Edit the Service Template:
Update `templates/service.yaml`:
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appName }}
spec:
type: {{ .Values.serviceType }}
ports:
- port: {{ .Values.servicePort }}
targetPort: {{ .Values.containerPort }}
protocol: TCP
selector:
app: {{ .Values.appName }}
#### 4. Validate the Helm Chart
1. Run `helm lint`:
helm lint -f nginx-values.yaml ./web
2. Validate Templates Using `helm template`:
helm template -f web/nginx-values.yml nginx ./web
3. Test YAML with `kubectl dry-run`:
helm template nginx ./web | kubectl apply --dry-run=client -f -
#### 5. Pull the Image from a Private Registry
1. Login to Docker (Minikube):
docker login
2. Load Image into Minikube:
minikube image load devopstrainer/java-mvn-privaterepos:php
3. List Images in Minikube:
minikube image ls
#### 6. Deploy the Helm Chart
1. Install the Chart:
helm install -f ./web/nginx-values.yml nginx ./web
2. Verify Deployment:
kubectl get deployments
kubectl get svc
#### 7. Test the Application
1. Port Forward to Access the Service:
kubectl port-forward svc/nginx 8080:80
2. Access the Application:
Open your browser and visit:
#### 8. Upgrade the Helm Chart
1. Modify `values.yaml`:
Change the replica count:
replicaCount: 2
2. Apply the Update:
helm upgrade nginx ./web
3. Verify the Upgrade:
kubectl get pods
#### 9. Uninstall the Helm Chart
1. Uninstall the Release:
helm uninstall nginx
2. Verify Cleanup:
kubectl get all
### Lab Summary
This hands-on lab covered the following steps:
- Helm Chart Creation: `helm create nginx`
- Validation:
- Syntax check: `helm lint`.
- Template validation: `helm template`.
- Kubernetes dry-run: `kubectl apply --dry-run`.
- Deployment: `helm install`.
- Upgrade: `helm upgrade`.
- Cleanup: `helm uninstall`.
### Hands-on Lab Continuation: Deploying Another Microservice Using the Same Helm Chart
This continuation of the hands-on lab demonstrates how to reuse an existing Helm chart to deploy a second microservice (`php`). The chart will be updated to support configurable names, images, and other settings for multiple microservices.
### Scenario
Reuse the existing `web` Helm chart to deploy a second microservice (`php`) by enhancing the chart with configurable options.
#### 1. Update the Helm Chart for Reusability
appName: php
appReplicas: 2
containerPort: 80
appImage: devopstrainer/java-mvn-privaterepos
appVersion: php
serviceType: NodePort
servicePort: 80
1. Create `php-values.yml` with Configurable Values:
#### 2. Deploy the Second Microservice
1. Install the Chart for the New Microservice:
Deploy the `php` microservice using the new values file:
helm install php ./web -f php-values.yam
2. Verify the Deployment:
Check that both `nginx` and `php` services are deployed:
kubectl get deployments
kubectl get svc
You should see `nginx` and `php` deployments and services.
#### 3. Test the New Microservice
1. Port Forward the Service:
kubectl port-forward svc/php 8081:80
2. Access the New Microservice:
Open your browser or use `curl`:
curl http://localhost:8081
#### 4. Upgrade the Second Microservice
1. Modify `php-values.yaml`:
Update the replica count:
replicaCount: 3
2. Apply the Update:
Upgrade the second microservice:
helm upgrade php ./web -f php-values.yaml
3. Verify the Update:
kubectl get pods
Check that the number of pods for `php` matches the updated replica count.
#### 5. Validate Helm Chart Reusability
1. Run Helm Lint:
Ensure the chart is valid:
helm lint ./web
2. Simulate the Deployment for `php`:
Render templates locally:
helm template php ./web -f php-values.yaml
3. Test with Kubernetes Dry-Run:
Simulate the update:
helm upgrade php ./web -f php-values.yaml --dry-run
#### 6. Clean Up
1. Uninstall Both Releases:
helm uninstall php
helm uninstall nginx
2. Verify Cleanup:
kubectl get all
Confirm that all resources for `nginx` and `php` are deleted.
### Lab Summary
This continuation of the lab covered the following:
- Enhanced Helm Chart Reusability: Updated the chart to make it configurable for multiple microservices.
- Deployed a Second Microservice (`php`): Successfully deployed the new microservice.
- Validation and Testing: Ensured the Helm chart's flexibility and correctness through validation and dry-run testing.
- Managed Multiple Microservices: Used the same Helm chart to manage two microservices (`nginx` and `php`).
### Comprehensive Hands-on Lab: Creating, Validating, Deploying, and Managing a Helm Chart
This hands-on lab provides a step-by-step guide to creating a Helm chart for a database application, validating its syntax, deploying it, and managing its lifecycle.
### Scenario
You will create a Helm chart for deploying a database application, validate its syntax, deploy it to a Kubernetes cluster, and manage its lifecycle.
#### 1. Prerequisites
- A running Kubernetes cluster.
- `kubectl` and `helm` CLI tools installed and configured.
#### 2. Create a Helm Chart
1. Generate the Helm Chart:
helm create db
2. Navigate to the Chart Directory:
cd db
3. Understand the Chart Directory:
Use the `tree` command to view the directory structure. Key files include:
- `Chart.yaml`: Metadata about the chart.
- `values.yaml`: Default configuration values.
- `templates/`: Kubernetes manifests with templating syntax.
#### 3. Customize the Helm Chart
1. Rename `values.yaml` as `db-values.yml` and update it as follows:
appName: mysql
appReplicas: 1
appImage: devopstrainer/java-mvn-privaterepos
appVersion: mysql
containerPort: 3306
servicePort: 3306
serviceType: ClusterIP
volumeName: mysql-store
mountPath: /var/lib/mysql
pvName: mysql1
accessModes: ReadWriteOnce
storageClass: manual
pvStorage: 5Gi
hostPath: /mnt/data
claimName: mysql-pvc
pvcStorage: 1Gi
containerEnvVars:
- name: MYSQL_ROOT_PASSWORD
value: "password"
2. Edit the Deployment Template: Modify `templates/deployment.yaml`:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.appName }}
spec:
replicas: {{ .Values.appReplicas }}
selector:
matchLabels:
app: {{ .Values.appName }}
template:
metadata:
labels:
app: {{ .Values.appName }}
spec:
volumes:
- name: {{ .Values.volumeName }}
persistentVolumeClaim:
claimName: {{ .Values.claimName }}
containers:
- name: {{ .Values.appName }}
image: "{{ .Values.appImage }}:{{ .Values.appVersion }}"
ports:
- containerPort: {{ .Values.containerPort }}
volumeMounts:
- name: {{ .Values.volumeName }}
mountPath: {{ .Values.mountPath }}
env:
{{- range .Values.containerEnvVars }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
3. Edit the Service Template: Modify `templates/service.yaml`:
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appName }}
spec:
type: {{ .Values.serviceType }}
ports:
- port: {{ .Values.servicePort }}
targetPort: {{ .Values.containerPort }}
protocol: TCP
selector:
app: {{ .Values.appName }}
4. Edit the PersistentVolume Template: Modify `templates/pv.yaml`:
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.pvName }}
spec:
accessModes:
- {{ .Values.accessModes }}
storageClassName: {{ .Values.storageClass }}
capacity:
storage: {{ .Values.pvStorage }}
hostPath:
path: {{ .Values.hostPath }}
5. Edit the PersistentVolumeClaim Template: Modify `templates/pvc.yaml`:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.claimName }}
labels:
type: local
spec:
storageClassName: {{ .Values.storageClass }}
accessModes:
- {{ .Values.accessModes }}
resources:
requests:
storage: {{ .Values.pvcStorage }}
#### 4. Validate the Helm Chart
1. Run `helm lint`:
helm lint -f db-values.yaml ./db
Ensure there are no errors.
2. Validate Templates Using `helm template`:
helm template -f db-values.yaml db ./db
3. Test YAML with `kubectl dry-run`:
helm template db ./db | kubectl apply --dry-run=client -f -
#### 5. Pull the Image from Private Registry
1. Login to Docker:
docker login
2. Load the Image into Minikube:
minikube image load devopstrainer/java-mvn-privaterepos:mysql
3. Check the Image List in Minikube:
minikube image ls
#### 6. Deploy the Helm Chart
1. Install the Chart:
helm install -f db-values.yaml db ./db
2. Verify the Deployment:
kubectl get deployments
kubectl get svc
#### 7. Test the Application
1. Port Forward the Service:
kubectl port-forward svc/db 8081:3306
2. Access the Application:
Open your browser or use `curl`:
curl http://localhost:8081
#### 8. Upgrade the Helm Chart
1. Modify `db-values.yaml`: Update the replica count:
replicaCount: 2
2. Apply the Update:
helm upgrade db ./db -f db-values.yaml
3. Verify the Upgrade:
kubectl get pods
#### 9. Uninstall the Helm Chart
1. Uninstall the Release:
helm uninstall db
2. Verify Cleanup:
kubectl get all
### Lab Summary
This hands-on lab covered:
- Helm Chart Creation: Using `helm create`.
- Validation:
- Syntax check with `helm lint`.
- Template validation with `helm template`.
- Kubernetes dry-run with `kubectl apply --dry-run`.
- Deployment and Management: Deploying and upgrading the chart using `helm install` and `helm upgrade`.
- Cleanup: Removing resources using `helm uninstall`.