Commit c0d76144 authored by Nguyễn Văn Vũ's avatar Nguyễn Văn Vũ

Week8 - Deploy minio application by helm

parent 7673cec2
# Create helm chart
helm create web-app-minio
# Upgrade chart
cd web-app-minio
helm upgrade web-app-minio .
# Rollback version (Current version is 2)
helm rollback web-app-minio 1
# Delete application
helm delete web-app-minio
dependencies:
- name: minio
repository: ""
version: 12.13.2
digest: sha256:4ebb94ff5dccdd869438afe0ec716b0833c4bac1defaa27a0e54f836a7de4835
generated: "2024-01-17T09:21:50.399621+07:00"
apiVersion: v2
name: web-app-minio
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
# Dependencies
dependencies:
- name: minio
version: "12.13.2"
\ No newline at end of file
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
apiVersion: v2
name: minio
description: A Helm chart for deploy Minio in Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "2024.1.16"
Webapp is deploying, just wait a few minutes.
\ No newline at end of file
{{/*
Expand the name of the chart.
*/}}
{{- define "minio.name" -}}
{{- default .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "minio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end }}
{{/*
Common labels
*/}}
{{- define "minio.labels" -}}
helm.sh/chart: {{ include "minio.chart" . }}
{{ include "minio.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "minio.selectorLabels" -}}
app.kubernetes.io/name: {{ include "minio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ include "minio.name" . }}-cm"
namespace: {{ .Values.namespace }}
labels:
{{- include "minio.labels" . | nindent 4 }}
data:
MINIO_ROOT_USER: {{ .Values.config.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: {{ .Values.config.MINIO_ROOT_PASSWORD }}
---
# Deploys a new MinIO Pod into the metadata.namespace Kubernetes namespace
#
# The `spec.containers[0].args` contains the command run on the pod
# The `/data` directory corresponds to the `spec.containers[0].volumeMounts[0].mountPath`
# That mount path corresponds to a Kubernetes HostPath which binds `/data` to a local drive or volume on the worker node where the pod runs
#
apiVersion: v1
kind: Pod
metadata:
name: {{ include "minio.name" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "minio.labels" . | nindent 4 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
pullPolicy: {{ .Values.image.pullPolicy }}
resources:
limits:
memory: {{ .Values.limits.memory }}
cpu: {{ .Values.limits.cpu }}
envFrom:
- configMapRef:
name: "{{ include "minio.name" . }}-cm"
{{- with .Values.command }}
command:
{{- toYaml . | nindent 8 -}}
{{- end -}}
{{- with .Values.args }}
args:
{{- toYaml . | nindent 8 -}}
{{- end -}}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 8 -}}
{{- end -}}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 6 -}}
{{- end -}}
\ No newline at end of file
# Deploys a new Namespace for the MinIO Pod
{{- if ne .Values.namespace "default" -}}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace }}
labels:
{{- include "minio.labels" . | nindent 4 -}}
{{- end -}}
\ No newline at end of file
apiVersion: v1
kind: PersistentVolume
metadata:
name: "{{ include "minio.name" . }}-pv"
spec:
capacity:
storage: {{ .Values.persistence.storage }}
volumeMode: {{ .Values.persistence.volumeMode }}
persistentVolumeReclaimPolicy: {{ .Values.persistence.persistentVolumeReclaimPolicy }}
storageClassName: ""
accessModes:
- ReadWriteOnce
nfs:
path: {{ .Values.persistence.nfs.path }}
server: {{ .Values.persistence.nfs.server }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "{{ include "minio.name" . }}-pvc"
namespace: {{ .Values.namespace }}
labels:
{{- include "minio.labels" . | nindent 4 }}
spec:
resources:
requests:
storage: {{ .Values.persistenceClaim.storage }}
volumeMode: {{ .Values.persistenceClaim.volumeMode }}
storageClassName: ""
accessModes:
- ReadWriteOnce
volumeName: "{{ include "minio.name" . }}-pv"
apiVersion: v1
kind: Service
metadata:
name: {{ include "minio.name" . }}
namespace: {{ .Values.namespace }}
spec:
type: {{ .Values.service.type }}
ports:
- name: cluster
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
selector:
{{- include "minio.selectorLabels" . | nindent 4 -}}
# Default values for minio.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
namespace: default
# Deloyment
image:
repository: quay.io/minio/minio
tag: latest
pullPolicy: IfNotPresent
limits:
memory: "2024Mi"
cpu: "2000m"
command:
- /bin/bash
- -c
args:
- minio server /data --console-address :9090
volumeMounts:
- mountPath: /data
name: localvolume
volumes:
- name: localvolume
persistentVolumeClaim:
claimName: minio-pvc
# Service
service:
type: ClusterIP
port: 9000
targetPort: 9000
minioport:
port: 9000
nodePort: 30021
targetPort: 9000
# Persistent Volume Claim
persistenceClaim:
storage: 1024Mi
volumeMode: Filesystem
storageClassName: ""
accessModes: ReadWriteOnce
# Persistent Volume
persistence:
storage: 1024Mi
volumeMode: Filesystem
accessModes: ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
nfs: # NFS server detail
path: /var/nfs/k8s
server: 192.168.67.9
# Config Map
config:
MINIO_ROOT_USER: user
MINIO_ROOT_PASSWORD: password
\ No newline at end of file
Deploy Web-app successful.
\ No newline at end of file
{{/*
Expand the name of the chart.
*/}}
{{- define "web-app-minio.name" -}}
{{- default .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "web-app-minio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "web-app-minio.selectorLabels" -}}
app.kubernetes.io/name: {{ include "web-app-minio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "web-app-minio.labels" -}}
helm.sh/chart: {{ include "web-app-minio.chart" . }}
{{ include "web-app-minio.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ include "web-app-minio.name" . }}-cm"
data:
MINIO_ACCESS_KEY_ID: {{ .Values.configMap.MINIO_ACCESS_KEY_ID }}
MINIO_SECRET_ACCESS_KEY: {{ .Values.configMap.MINIO_SECRET_ACCESS_KEY }}
MINIO_STORAGE_BUCKET_NAME: {{ .Values.configMap.MINIO_STORAGE_BUCKET_NAME }}
MINIO_API: "http://minio.{{ .Values.namespace }}.svc.cluster.local:9000"
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "web-app-minio.name" . }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
{{- include "web-app-minio.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: 5
progressDeadlineSeconds: 300
minReadySeconds: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
{{- include "web-app-minio.labels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag}}"
pullPolicy: Always
envFrom:
- configMapRef:
name: "{{ include "web-app-minio.name" . }}-cm"
ports:
- containerPort: {{ .Values.containerPort }}
resources:
limits:
memory: {{ .Values.limits.memory }}
cpu: {{ .Values.limits.cpu }}
apiVersion: v1
kind: Service
metadata:
name: "{{ include "web-app-minio.name" . }}-svc"
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
protocol: {{ .Values.service.protocol }}
selector:
{{- include "web-app-minio.selectorLabels" . | nindent 4}}
# Default values for web-app-minio.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
namespace: default
# Deployment
replicas: 1
image:
repository: garovu/django-minio
tag: latest
limits:
memory: "1024Mi"
cpu: "1000m"
containerPort: 8000
# ConfigMap
configMap:
MINIO_ACCESS_KEY_ID: user
MINIO_SECRET_ACCESS_KEY: password
MINIO_STORAGE_BUCKET_NAME: static
# MINIO_API: "http://172.17.0.1:9000"
# Service
service:
type: NodePort
port: 8000
protocol: TCP
# Minio Setup
minio:
namespace: default
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment