Skip to content

Commit 3bf2c03

Browse files
committed
helm chart added
1 parent aafda14 commit 3bf2c03

1 file changed

Lines changed: 170 additions & 0 deletions

File tree

assets/helm-chart.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
I'm unable to directly create or provide downloadable files. However, I can provide you with the complete Markdown content here, and you can copy and paste it into a file named `helm-chart.md` on your local machine.
2+
3+
Here is the content for `helm-chart.md`:
4+
5+
```markdown
6+
# Creating a Helm Chart for Nginx
7+
8+
## Step 1: Install Helm
9+
10+
First, ensure you have Helm installed on your workstation. You can install Helm using the following command:
11+
12+
```sh
13+
brew install kubernetes-helm
14+
```
15+
16+
## Step 2: Create a Helm Chart
17+
18+
Use the `helm create` command to generate a new Helm chart. This command creates a directory structure with default files and folders for your chart.
19+
20+
```sh
21+
helm create nginx-chart
22+
```
23+
24+
This will create a directory named `nginx-chart` with the following structure:
25+
26+
```
27+
nginx-chart/
28+
├── Chart.yaml
29+
├── values.yaml
30+
├── .helmignore
31+
├── templates/
32+
│ ├── NOTES.txt
33+
│ ├── _helpers.tpl
34+
│ ├── deployment.yaml
35+
│ ├── hpa.yaml
36+
│ ├── ingress.yaml
37+
│ ├── service.yaml
38+
│ ├── serviceaccount.yaml
39+
│ └── tests/
40+
│ └── test-connection.yaml
41+
└── charts/
42+
```
43+
44+
## Step 3: Edit the Chart Files
45+
46+
Navigate into the `nginx-chart` directory and edit the files to customize your Helm chart.
47+
48+
```sh
49+
cd nginx-chart
50+
```
51+
52+
### Chart.yaml
53+
54+
This file contains metadata about your Helm chart.
55+
56+
```yaml
57+
apiVersion: v2
58+
name: nginx-chart
59+
description: A Helm chart for Kubernetes
60+
version: 0.1.0
61+
appVersion: "1.20"
62+
```
63+
64+
### values.yaml
65+
66+
This file contains default configuration values for your Helm chart.
67+
68+
```yaml
69+
replicaCount: 2
70+
71+
image:
72+
repository: nginx
73+
tag: "1.20"
74+
pullPolicy: IfNotPresent
75+
76+
service:
77+
type: ClusterIP
78+
port: 80
79+
```
80+
81+
### templates/deployment.yaml
82+
83+
This file defines the Kubernetes Deployment resource. It uses Go template syntax to dynamically insert values from `values.yaml`.
84+
85+
```yaml
86+
apiVersion: apps/v1
87+
kind: Deployment
88+
metadata:
89+
name: {{ .Values.name }}
90+
spec:
91+
replicas: {{ .Values.replicaCount }}
92+
selector:
93+
matchLabels:
94+
app: {{ .Values.name }}
95+
template:
96+
metadata:
97+
labels:
98+
app: {{ .Values.name }}
99+
spec:
100+
containers:
101+
- name: {{ .Values.name }}
102+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
103+
ports:
104+
- containerPort: 80
105+
```
106+
107+
### templates/service.yaml
108+
109+
This file defines the Kubernetes Service resource.
110+
111+
```yaml
112+
apiVersion: v1
113+
kind: Service
114+
metadata:
115+
name: {{ .Values.name }}
116+
spec:
117+
type: {{ .Values.service.type }}
118+
ports:
119+
- port: {{ .Values.service.port }}
120+
selector:
121+
app: {{ .Values.name }}
122+
```
123+
124+
## Step 4: Package the Helm Chart
125+
126+
Package your Helm chart using the `helm package` command.
127+
128+
```sh
129+
helm package nginx-chart
130+
```
131+
132+
This will create a `.tgz` file that can be distributed and installed.
133+
134+
## Step 5: Install the Helm Chart
135+
136+
Install the Helm chart using the `helm install` command.
137+
138+
```sh
139+
helm install my-nginx-release ./nginx-chart-0.1.0.tgz
140+
```
141+
142+
You can also customize the installation by passing a `values.yaml` file with specific configurations.
143+
144+
```sh
145+
helm install my-nginx-release ./nginx-chart-0.1.0.tgz -f custom-values.yaml
146+
```
147+
148+
## Step 6: Manage the Helm Release
149+
150+
You can manage the Helm release using commands like `helm upgrade`, `helm rollback`, and `helm status`.
151+
152+
```sh
153+
helm upgrade my-nginx-release ./nginx-chart-0.1.0.tgz -f custom-values.yaml
154+
helm rollback my-nginx-release 1
155+
helm status my-nginx-release
156+
```
157+
158+
## Conclusion
159+
160+
This guide provides a basic example of creating, packaging, and installing a Helm chart for an Nginx application. You can customize the Helm chart further by editing the `values.yaml` file and adding more Kubernetes resources in the `templates` directory.
161+
```
162+
163+
To create the file:
164+
165+
1. Copy the above content.
166+
2. Open a text editor (like Notepad, VS Code, or any other editor).
167+
3. Paste the content into the editor.
168+
4. Save the file with the name `helm-chart.md`.
169+
170+
Now you have a single Markdown file containing the complete guide.

0 commit comments

Comments
 (0)