Initial
This commit is contained in:
commit
c9139aa850
7
Chart.yaml
Normal file
7
Chart.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
# Chart.yaml
|
||||
apiVersion: v2
|
||||
name: basic-app
|
||||
description: A basic Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "1.0.0"
|
130
README.md
Normal file
130
README.md
Normal file
@ -0,0 +1,130 @@
|
||||
# Basic Application Helm Chart
|
||||
|
||||
## Overview
|
||||
This Helm chart deploys a basic application on a Kubernetes cluster with the following components:
|
||||
- A deployment with configurable replicas
|
||||
- A persistent volume claim for data storage
|
||||
- A service for internal communication
|
||||
- An ingress for external access with TLS support
|
||||
|
||||
## Prerequisites
|
||||
- Kubernetes 1.19+
|
||||
- Helm 3.0+
|
||||
- PV provisioner support in the underlying infrastructure
|
||||
- Ingress controller (e.g., nginx-ingress)
|
||||
|
||||
## Installation
|
||||
|
||||
### Add the repository
|
||||
```bash
|
||||
# If hosted in a Helm repository
|
||||
helm repo add my-repo https://charts.example.com
|
||||
helm repo update
|
||||
```
|
||||
|
||||
### Install the chart
|
||||
```bash
|
||||
# Using default values
|
||||
helm install my-release .
|
||||
|
||||
# Using custom values file
|
||||
helm install my-release . -f values.yaml
|
||||
|
||||
# Using --set
|
||||
helm install my-release . --set ingress.hosts[0].host=example.com
|
||||
```
|
||||
|
||||
## Uninstallation
|
||||
```bash
|
||||
helm uninstall my-release
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The following table lists the configurable parameters of the chart and their default values.
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `replicaCount` | Number of replicas | `1` |
|
||||
| `image.repository` | Image repository | `nginx` |
|
||||
| `image.tag` | Image tag | `latest` |
|
||||
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
|
||||
| `service.type` | Kubernetes service type | `ClusterIP` |
|
||||
| `service.port` | Kubernetes service port | `80` |
|
||||
| `ingress.enabled` | Enable ingress | `true` |
|
||||
| `ingress.className` | Ingress class name | `nginx` |
|
||||
| `ingress.annotations` | Ingress annotations | `{}` |
|
||||
| `ingress.hosts[0].host` | Hostname | `chart-example.local` |
|
||||
| `ingress.hosts[0].paths[0].path` | Path | `/` |
|
||||
| `ingress.hosts[0].paths[0].pathType` | Path type | `Prefix` |
|
||||
| `ingress.tls.enabled` | Enable TLS | `true` |
|
||||
| `ingress.tls.secretName` | TLS secret name | `chart-example-tls` |
|
||||
| `persistence.enabled` | Enable persistence | `true` |
|
||||
| `persistence.accessMode` | PVC access mode | `ReadWriteOnce` |
|
||||
| `persistence.size` | PVC size | `1Gi` |
|
||||
| `persistence.storageClass` | PVC storage class | `""` |
|
||||
|
||||
### Ingress Annotations Examples
|
||||
|
||||
For NGINX ingress controller:
|
||||
```yaml
|
||||
ingress:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
```
|
||||
|
||||
For cert-manager SSL certificates:
|
||||
```yaml
|
||||
ingress:
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
```
|
||||
|
||||
## TLS Configuration
|
||||
|
||||
To use TLS, create a TLS secret in the namespace:
|
||||
|
||||
```bash
|
||||
kubectl create secret tls chart-example-tls \
|
||||
--cert=path/to/tls.cert \
|
||||
--key=path/to/tls.key
|
||||
```
|
||||
|
||||
Then enable it in values.yaml:
|
||||
```yaml
|
||||
ingress:
|
||||
tls:
|
||||
enabled: true
|
||||
secretName: chart-example-tls
|
||||
hosts:
|
||||
- chart-example.local
|
||||
```
|
||||
|
||||
## Persistence
|
||||
|
||||
The chart mounts a Persistent Volume at `/data`. The volume is created using dynamic volume provisioning.
|
||||
|
||||
## Upgrading
|
||||
|
||||
```bash
|
||||
# Upgrade using values file
|
||||
helm upgrade my-release . -f values.yaml
|
||||
|
||||
# Upgrade with --set flag
|
||||
helm upgrade my-release . --set replicaCount=3
|
||||
```
|
||||
|
||||
## Limitations
|
||||
- The chart has been tested on Kubernetes 1.19+
|
||||
- Persistent volume provisioning support in underlying infrastructure
|
||||
- Ingress controller must be present in the cluster
|
||||
|
||||
## Contributing
|
||||
If you find any issues with this chart or want to contribute improvements:
|
||||
1. Fork the repository
|
||||
2. Create a new branch for your changes
|
||||
3. Submit a pull request
|
||||
|
||||
## License
|
||||
This Helm chart is licensed under the MIT License.
|
17
templates/_helpers.tpl
Normal file
17
templates/_helpers.tpl
Normal file
@ -0,0 +1,17 @@
|
||||
{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "basic-app.labels" -}}
|
||||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
||||
app.kubernetes.io/name: {{ .Chart.Name }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "basic-app.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ .Chart.Name }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
31
templates/deployment.yaml
Normal file
31
templates/deployment.yaml
Normal file
@ -0,0 +1,31 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "basic-app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "basic-app.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "basic-app.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .Release.Name }}-pvc
|
||||
|
38
templates/ingress.yaml
Normal file
38
templates/ingress.yaml
Normal file
@ -0,0 +1,38 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "basic-app.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- if and .Values.ingress.tls .Values.ingress.tls.enabled }}
|
||||
tls:
|
||||
- hosts:
|
||||
{{- range .Values.ingress.tls.hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .Values.ingress.tls.secretName }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $.Release.Name }}
|
||||
port:
|
||||
number: {{ $.Values.service.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
15
templates/pvc.yaml
Normal file
15
templates/pvc.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-pvc
|
||||
labels:
|
||||
{{- include "basic-app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.accessMode }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size }}
|
||||
{{- if .Values.persistence.storageClass }}
|
||||
storageClassName: {{ .Values.persistence.storageClass }}
|
||||
{{- end }}
|
16
templates/service.yaml
Normal file
16
templates/service.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "basic-app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "basic-app.selectorLabels" . | nindent 4 }}
|
||||
|
37
values.yaml
Normal file
37
values.yaml
Normal file
@ -0,0 +1,37 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: nginx
|
||||
pullPolicy: IfNotPresent
|
||||
tag: "latest"
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
|
||||
persistence:
|
||||
enabled: true
|
||||
accessMode: ReadWriteOnce
|
||||
size: 1Gi
|
||||
storageClass: ""
|
||||
|
||||
|
||||
ingress:
|
||||
tls:
|
||||
enabled: true
|
||||
secretName: chart-example-tls
|
||||
hosts:
|
||||
- chart-example.local
|
||||
annotations: {}
|
||||
# kubernetes.io/ingress.class: nginx
|
||||
# kubernetes.io/tls-acme: "true"
|
||||
# cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
Loading…
Reference in New Issue
Block a user