From 30a0e61e8a1148506884834b0bc374afebe692a0 Mon Sep 17 00:00:00 2001 From: dannc Date: Tue, 21 Mar 2023 11:03:24 +0700 Subject: [PATCH] [stage-3] add helm chart for simple application --- k8s/helm/simple-app/.helmignore | 23 ++++++++++++++ k8s/helm/simple-app/Chart.yaml | 24 +++++++++++++++ k8s/helm/simple-app/templates/NOTES.txt | 6 ++++ k8s/helm/simple-app/templates/deployment.yaml | 30 +++++++++++++++++++ k8s/helm/simple-app/templates/ingress.yaml | 20 +++++++++++++ k8s/helm/simple-app/templates/service.yaml | 12 ++++++++ k8s/helm/simple-app/values.yaml | 14 +++++++++ 7 files changed, 129 insertions(+) create mode 100644 k8s/helm/simple-app/.helmignore create mode 100644 k8s/helm/simple-app/Chart.yaml create mode 100644 k8s/helm/simple-app/templates/NOTES.txt create mode 100644 k8s/helm/simple-app/templates/deployment.yaml create mode 100644 k8s/helm/simple-app/templates/ingress.yaml create mode 100644 k8s/helm/simple-app/templates/service.yaml create mode 100644 k8s/helm/simple-app/values.yaml diff --git a/k8s/helm/simple-app/.helmignore b/k8s/helm/simple-app/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/k8s/helm/simple-app/.helmignore @@ -0,0 +1,23 @@ +# 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/ diff --git a/k8s/helm/simple-app/Chart.yaml b/k8s/helm/simple-app/Chart.yaml new file mode 100644 index 0000000..4844d67 --- /dev/null +++ b/k8s/helm/simple-app/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: simple-app +description: application helm chart + +# 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: "latest" diff --git a/k8s/helm/simple-app/templates/NOTES.txt b/k8s/helm/simple-app/templates/NOTES.txt new file mode 100644 index 0000000..2589bf1 --- /dev/null +++ b/k8s/helm/simple-app/templates/NOTES.txt @@ -0,0 +1,6 @@ +--------------------------------------------------------- + +Content of NOTES.txt appears after deploy. +Deployed version {{ .Chart.AppVersion }}. + +--------------------------------------------------------- diff --git a/k8s/helm/simple-app/templates/deployment.yaml b/k8s/helm/simple-app/templates/deployment.yaml new file mode 100644 index 0000000..435a7ac --- /dev/null +++ b/k8s/helm/simple-app/templates/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: {{ .Chart.Name }}-{{ .Values.environment }} + service: application + name: {{ .Chart.Name }}-{{ .Values.environment }}-application +spec: + replicas: {{ .Values.application.replicasCount }} + selector: + matchLabels: + app: {{ .Chart.Name }}-{{ .Values.environment }} + service: application + template: + metadata: + labels: + app: {{ .Chart.Name }}-{{ .Values.environment }} + service: application + spec: + containers: + - image: {{ .Values.image.name }}:{{ .Chart.AppVersion }} + imagePullPolicy: Always + name: application + ports: + - name: web + containerPort: 80 + resources: + {{- toYaml .Values.application.resources | nindent 12 }} + terminationGracePeriodSeconds: 30 diff --git a/k8s/helm/simple-app/templates/ingress.yaml b/k8s/helm/simple-app/templates/ingress.yaml new file mode 100644 index 0000000..a877b3c --- /dev/null +++ b/k8s/helm/simple-app/templates/ingress.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Chart.Name }}-{{ .Values.environment }}-application-ingress + annotations: + kubernetes.io/ingress.class: nginx + ingress.kubernetes.io/rewrite-target: / +spec: + rules: + - host: app-gw.my.to + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Chart.Name }}-{{ .Values.environment }}-application + port: + number: 80 diff --git a/k8s/helm/simple-app/templates/service.yaml b/k8s/helm/simple-app/templates/service.yaml new file mode 100644 index 0000000..71d6bdf --- /dev/null +++ b/k8s/helm/simple-app/templates/service.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-{{ .Values.environment }}-application +spec: + ports: + - name: web + port: 80 + selector: + app: {{ .Chart.Name }}-{{ .Values.environment }} + service: application diff --git a/k8s/helm/simple-app/values.yaml b/k8s/helm/simple-app/values.yaml new file mode 100644 index 0000000..c44d8a1 --- /dev/null +++ b/k8s/helm/simple-app/values.yaml @@ -0,0 +1,14 @@ +environment: production + +image: + name: dannecron/parcel-example-neko + +application: + replicasCount: 1 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi