Skip to content

Commit 6e19bba

Browse files
Create Kubernetes - Helm.md
1 parent d297069 commit 6e19bba

File tree

1 file changed

+241
-0
lines changed

1 file changed

+241
-0
lines changed
+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
# Kubernetes - Helm Notes
2+
3+
4+
## **What is Helm?**
5+
Helm is a package manager for Kubernetes that simplifies the deployment, management, and scaling of applications. It uses preconfigured templates, called Helm Charts, to automate the process of creating Kubernetes resources.
6+
7+
### **Why Use Helm?**
8+
- **Simplifies Kubernetes deployments**: Automates the creation and management of Kubernetes resources.
9+
- **Provides version control**: Manage different versions of your application.
10+
- **Reusable templates**: Create consistent and repeatable deployments.
11+
12+
---
13+
14+
## **Key Concepts in Helm**
15+
16+
### **1. Helm Charts**
17+
Helm Charts are collections of templates that define Kubernetes resources. These charts contain all the necessary files to deploy an application on Kubernetes.
18+
19+
#### **Structure of a Helm Chart**
20+
- **Chart.yaml**: Contains metadata about the chart (name, version, description).
21+
- **Values.yaml**: Contains default configuration values for the chart.
22+
- **Templates/**: Directory containing YAML templates for Kubernetes resources.
23+
24+
#### **Example of Chart.yaml:**
25+
```yaml
26+
apiVersion: v2
27+
name: my-application
28+
version: 1.0.0
29+
description: A Helm chart for my application
30+
```
31+
32+
### **2. Helm Repositories**
33+
Helm Repositories are storage locations for Helm Charts. These repositories can be public or private and allow you to store and retrieve charts for your deployments.
34+
35+
#### **Popular Helm Repositories:**
36+
- Bitnami
37+
- ArtifactHub
38+
- Helm Stable Repository
39+
40+
### **3. Helm Releases**
41+
A Helm Release is a specific deployment of a Helm Chart. Every time a chart is deployed, it is tracked as a release.
42+
43+
---
44+
45+
## **Key Features of Helm**
46+
47+
| **Feature** | **Description** |
48+
|-----------------------|-------------------------------------------------|
49+
| Simplified Deployment | Automates Kubernetes resource creation |
50+
| Version Control | Tracks application versions and rollbacks |
51+
| Reusable Templates | Creates consistent configurations using charts |
52+
| Scalability | Easily manage application scaling |
53+
54+
---
55+
56+
## **Helm Workflow**
57+
The typical workflow for using Helm involves creating charts, installing releases, upgrading them, and rolling back if necessary.
58+
59+
### **Step 1: Create a Chart**
60+
```bash
61+
helm create my-chart
62+
```
63+
This command generates a basic chart structure with the necessary files.
64+
65+
### **Step 2: Install a Release**
66+
```bash
67+
helm install <release-name> <chart>
68+
```
69+
This command installs a release from the specified chart.
70+
71+
#### **Example:**
72+
```bash
73+
helm install my-app ./my-chart
74+
```
75+
76+
### **Step 3: Upgrade a Release**
77+
```bash
78+
helm upgrade <release-name> <chart>
79+
```
80+
This command upgrades an existing release with new chart configurations.
81+
82+
#### **Example:**
83+
```bash
84+
helm upgrade my-app ./my-chart
85+
```
86+
87+
### **Step 4: Rollback a Release**
88+
```bash
89+
helm rollback <release-name> <revision>
90+
```
91+
This command rolls back a release to a previous revision.
92+
93+
#### **Example:**
94+
```bash
95+
helm rollback my-app 1
96+
```
97+
98+
---
99+
100+
## **File Descriptions in Helm**
101+
102+
### **1. Chart.yaml**
103+
This file contains metadata about the Helm Chart.
104+
105+
#### **Example:**
106+
```yaml
107+
apiVersion: v2
108+
name: my-chart
109+
version: 1.0.0
110+
description: A sample Helm chart
111+
```
112+
113+
### **2. Values.yaml**
114+
Contains the default configuration values for the chart.
115+
116+
#### **Example:**
117+
```yaml
118+
replicaCount: 2
119+
image:
120+
repository: nginx
121+
tag: latest
122+
pullPolicy: IfNotPresent
123+
service:
124+
type: ClusterIP
125+
port: 80
126+
```
127+
128+
### **3. Templates/**
129+
Contains Kubernetes resource templates.
130+
131+
#### **Example Template:** ConfigMap
132+
```yaml
133+
apiVersion: v1
134+
kind: ConfigMap
135+
metadata:
136+
name: {{ .Release.Name }}-configmap
137+
data:
138+
myValue: "Example"
139+
```
140+
141+
---
142+
143+
## **Pre-existing Helm Charts**
144+
There are several pre-existing Helm Charts available in repositories:
145+
146+
| **Chart** | **Description** |
147+
|-----------------|--------------------------------------|
148+
| Nginx | Web server |
149+
| Prometheus | Monitoring system |
150+
| Grafana | Dashboard and visualization tool |
151+
| Jenkins | Continuous Integration server |
152+
| MySQL | Database server |
153+
154+
---
155+
156+
## **Helm Commands**
157+
158+
| **Command** | **Description** |
159+
|--------------------------------------|-----------------------------------------------|
160+
| `helm install <release> <chart>` | Install a Helm chart |
161+
| `helm upgrade <release> <chart>` | Upgrade an existing release |
162+
| `helm rollback <release> <revision>` | Rollback a release to a previous revision |
163+
| `helm package <path-to-chart>` | Package a chart into a `.tgz` archive |
164+
| `helm push <chart>` | Push a chart to a repository |
165+
166+
---
167+
168+
## **Helm Templates**
169+
Helm templates use Go template syntax to create dynamic configurations.
170+
171+
### **1. Helper Templates**
172+
Helper templates are reusable components defined in a `_helpers.tpl` file.
173+
174+
#### **Example:**
175+
```yaml
176+
{{- define "my-chart.fullname" -}}
177+
{{ .Release.Name }}-{{ .Chart.Name }}
178+
{{- end -}}
179+
```
180+
181+
### **2. Dynamic Names in Templates**
182+
Dynamic names use variables to customize resource names.
183+
184+
#### **Examples:**
185+
```yaml
186+
metadata:
187+
name: {{ .Release.Name }}-configmap
188+
```
189+
```yaml
190+
metadata:
191+
name: {{ .Release.Name | lower }}-deployment
192+
```
193+
194+
### **3. Conditional Rendering**
195+
Conditional rendering allows templates to include or exclude configurations based on values.
196+
197+
#### **Example:**
198+
```yaml
199+
selector:
200+
app: my-app
201+
{{- if .Values.service.external }}
202+
externalIPs:
203+
- {{ .Values.service.external }}
204+
{{- end }}
205+
```
206+
207+
---
208+
209+
## **Deployment Example: Nginx**
210+
211+
1. **Install Nginx using Helm:**
212+
```bash
213+
helm install my-nginx bitnami/nginx
214+
```
215+
216+
2. **Customize using values.yaml:**
217+
```yaml
218+
replicaCount: 2
219+
service:
220+
type: LoadBalancer
221+
```
222+
223+
---
224+
225+
## **Deployment Example: Prometheus and Grafana**
226+
Use existing Helm charts to set up monitoring tools.
227+
228+
1. **Install Prometheus:**
229+
```bash
230+
helm install prometheus prometheus-community/prometheus
231+
```
232+
233+
2. **Install Grafana:**
234+
```bash
235+
helm install grafana grafana/grafana
236+
```
237+
238+
---
239+
240+
## **Summary**
241+
Helm simplifies Kubernetes application deployments by providing reusable charts, version control, and dynamic templates. It reduces the complexity of managing Kubernetes resources and ensures consistent configurations across environments.

0 commit comments

Comments
 (0)