0
0
Kubernetesdevops~5 mins

Installing charts in Kubernetes - Step-by-Step CLI Walkthrough

Choose your learning style9 modes available
Introduction
Installing charts helps you add ready-made applications to your Kubernetes cluster easily. Charts package all the resources needed to run an app, so you don't have to create each part manually.
When you want to deploy a database like MySQL quickly without writing all Kubernetes files.
When you need to add monitoring tools like Prometheus to your cluster with minimal setup.
When you want to install a web server such as Nginx with default settings fast.
When you want to try out an application without configuring every detail yourself.
When you want to manage app upgrades and rollbacks easily using a package system.
Commands
This command adds the Bitnami chart repository to Helm so you can access many ready-to-use charts from Bitnami.
Terminal
helm repo add bitnami https://charts.bitnami.com/bitnami
Expected OutputExpected
"bitnami" has been added to your repositories
This updates your local list of charts from all added repositories to make sure you have the latest versions.
Terminal
helm repo update
Expected OutputExpected
Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "bitnami" chart repository Update Complete.
This installs the Nginx chart from Bitnami repository into your Kubernetes cluster with the release name 'my-nginx'.
Terminal
helm install my-nginx bitnami/nginx
Expected OutputExpected
NAME: my-nginx LAST DEPLOYED: Sat Jun 10 12:00:00 2023 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: 1. Get the application URL by running these commands: export POD_NAME=$(kubectl get pods --namespace default -l app.kubernetes.io/name=nginx -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl port-forward $POD_NAME 8080:80
--namespace - Specify the Kubernetes namespace to install the chart into
--set - Override chart default values during installation
This command checks the status of pods in your cluster to verify that the Nginx pod is running after installation.
Terminal
kubectl get pods
Expected OutputExpected
NAME READY STATUS RESTARTS AGE my-nginx-nginx-5d7f9d7f7b-abcde 1/1 Running 0 30s
Key Concept

If you remember nothing else from this pattern, remember: Helm charts let you install complex apps on Kubernetes with one simple command.

Common Mistakes
Trying to install a chart without adding the repository first
Helm won't find the chart because it doesn't know where to look for it.
Always add the chart repository using 'helm repo add' before installing charts from it.
Not running 'helm repo update' after adding a new repository
Your local list of charts will be outdated, so you might not get the latest chart versions.
Run 'helm repo update' to refresh your chart list before installing.
Not checking pod status after installation
You might think the app is running when it actually failed to start.
Use 'kubectl get pods' to confirm the app pods are running properly.
Summary
Add a chart repository with 'helm repo add' to access ready-made apps.
Update your local chart list with 'helm repo update' to get the latest versions.
Install an app using 'helm install' with a release name and chart name.
Verify the app is running by checking pods with 'kubectl get pods'.