From 5372a75ea4b8de686f836fcccfdfa29492625880 Mon Sep 17 00:00:00 2001 From: Saadullah Khan Warsi Date: Sun, 8 Oct 2023 01:19:21 +0400 Subject: [PATCH] Add files via upload --- kubernetes/myapp/Chart.yaml | 24 +++++++++ kubernetes/myapp/templates/_helpers.tpl | 62 ++++++++++++++++++++++ kubernetes/myapp/templates/deployment.yaml | 54 +++++++++++++++++++ kubernetes/myapp/templates/service.yaml | 15 ++++++ kubernetes/myapp/values.yaml | 16 ++++++ 5 files changed, 171 insertions(+) create mode 100644 kubernetes/myapp/Chart.yaml create mode 100644 kubernetes/myapp/templates/_helpers.tpl create mode 100644 kubernetes/myapp/templates/deployment.yaml create mode 100644 kubernetes/myapp/templates/service.yaml create mode 100644 kubernetes/myapp/values.yaml diff --git a/kubernetes/myapp/Chart.yaml b/kubernetes/myapp/Chart.yaml new file mode 100644 index 0000000..d61200e --- /dev/null +++ b/kubernetes/myapp/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: myapp +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.2.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" diff --git a/kubernetes/myapp/templates/_helpers.tpl b/kubernetes/myapp/templates/_helpers.tpl new file mode 100644 index 0000000..124f429 --- /dev/null +++ b/kubernetes/myapp/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "myapp.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "myapp.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "myapp.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "myapp.labels" -}} +helm.sh/chart: {{ include "myapp.chart" . }} +{{ include "myapp.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "myapp.selectorLabels" -}} +app.kubernetes.io/name: {{ include "myapp.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "myapp.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "myapp.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/kubernetes/myapp/templates/deployment.yaml b/kubernetes/myapp/templates/deployment.yaml new file mode 100644 index 0000000..da8bcd7 --- /dev/null +++ b/kubernetes/myapp/templates/deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "myapp.fullname" . }} + labels: + {{- include "myapp.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "myapp.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "myapp.selectorLabels" . | nindent 8 }} + spec: + imagePullSecrets: + - name: registry-secret + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + command: ["/bin/sh"] + args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"] + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 60 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 60 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + timeoutSeconds: 10 + resources: + requests: + memory: 0.25Gi + cpu: 0.5 + limits: + memory: 0.25Gi + cpu: 0.5 + diff --git a/kubernetes/myapp/templates/service.yaml b/kubernetes/myapp/templates/service.yaml new file mode 100644 index 0000000..d522de0 --- /dev/null +++ b/kubernetes/myapp/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "myapp.fullname" . }} + labels: + {{- include "myapp.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "myapp.selectorLabels" . | nindent 4 }} diff --git a/kubernetes/myapp/values.yaml b/kubernetes/myapp/values.yaml new file mode 100644 index 0000000..58af58c --- /dev/null +++ b/kubernetes/myapp/values.yaml @@ -0,0 +1,16 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 2 + +image: + repository: IMAGE_NAME + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: IMAGE_TAG + +service: + type: NodePort + port: 8080 +