From b65d1aad7e50caa76becdab6c8b1c1cea4da141a Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 16:19:18 +0300 Subject: [PATCH 1/7] Add task1 --- k8s/LAB10.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 k8s/LAB10.md diff --git a/k8s/LAB10.md b/k8s/LAB10.md new file mode 100644 index 0000000000..a64b6318c4 --- /dev/null +++ b/k8s/LAB10.md @@ -0,0 +1,84 @@ +# Task 1 + +### Installation +```sh +sudo pacman -S --needed helm +``` +```text +warning: helm-4.1.3-1 is up to date -- skipping + there is nothing to do +``` + +### Version +```sh +helm version +``` +```text +version.BuildInfo{Version:"v4.1.3", GitCommit:"c94d381b03be117e7e57908edbf642104e00eb8f", GitTreeState:"", GoVersion:"go1.26.1-X:nodwarf5", KubeClientVersion:"v1.35"} +``` + +### Output of exploring a public chart + +```sh +helm show chart prometheus-community/prometheus +``` +```yaml +annotations: + artifacthub.io/license: Apache-2.0 + artifacthub.io/links: | + - name: Chart Source + url: https://github.com/prometheus-community/helm-charts + - name: Upstream Project + url: https://github.com/prometheus/prometheus +apiVersion: v2 +appVersion: v3.10.0 +dependencies: +- condition: alertmanager.enabled + name: alertmanager + repository: https://prometheus-community.github.io/helm-charts + version: 1.34.* +- condition: kube-state-metrics.enabled + name: kube-state-metrics + repository: https://prometheus-community.github.io/helm-charts + version: 7.2.* +- condition: prometheus-node-exporter.enabled + name: prometheus-node-exporter + repository: https://prometheus-community.github.io/helm-charts + version: 4.52.* +- condition: prometheus-pushgateway.enabled + name: prometheus-pushgateway + repository: https://prometheus-community.github.io/helm-charts + version: 3.6.* +description: Prometheus is a monitoring system and time series database. +home: https://prometheus.io/ +icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png +keywords: +- monitoring +- prometheus +kubeVersion: '>=1.19.0-0' +maintainers: +- email: gianrubio@gmail.com + name: gianrubio + url: https://github.com/gianrubio +- email: zanhsieh@gmail.com + name: zanhsieh + url: https://github.com/zanhsieh +- email: miroslav.hadzhiev@gmail.com + name: Xtigyro + url: https://github.com/Xtigyro +- email: naseem@transit.app + name: naseemkullah + url: https://github.com/naseemkullah +- email: rootsandtrees@posteo.de + name: zeritti + url: https://github.com/zeritti +name: prometheus +sources: +- https://github.com/prometheus/alertmanager +- https://github.com/prometheus/prometheus +- https://github.com/prometheus/pushgateway +- https://github.com/prometheus/node_exporter +- https://github.com/kubernetes/kube-state-metrics +type: application +version: 28.14.1 +``` From 3317ea74391dc6eebc1541727f790cb62cff8566 Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 16:21:29 +0300 Subject: [PATCH 2/7] Initialize dinfochart --- k8s/dinfochart/.gitignore | 1 + k8s/dinfochart/.helmignore | 23 +++ k8s/dinfochart/Chart.yaml | 24 +++ k8s/dinfochart/templates/NOTES.txt | 35 ++++ k8s/dinfochart/templates/_helpers.tpl | 62 +++++++ k8s/dinfochart/templates/deployment.yaml | 78 +++++++++ k8s/dinfochart/templates/hpa.yaml | 32 ++++ k8s/dinfochart/templates/httproute.yaml | 38 +++++ k8s/dinfochart/templates/ingress.yaml | 43 +++++ k8s/dinfochart/templates/service.yaml | 15 ++ k8s/dinfochart/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 ++ k8s/dinfochart/values.yaml | 161 ++++++++++++++++++ 13 files changed, 540 insertions(+) create mode 100644 k8s/dinfochart/.gitignore create mode 100644 k8s/dinfochart/.helmignore create mode 100644 k8s/dinfochart/Chart.yaml create mode 100644 k8s/dinfochart/templates/NOTES.txt create mode 100644 k8s/dinfochart/templates/_helpers.tpl create mode 100644 k8s/dinfochart/templates/deployment.yaml create mode 100644 k8s/dinfochart/templates/hpa.yaml create mode 100644 k8s/dinfochart/templates/httproute.yaml create mode 100644 k8s/dinfochart/templates/ingress.yaml create mode 100644 k8s/dinfochart/templates/service.yaml create mode 100644 k8s/dinfochart/templates/serviceaccount.yaml create mode 100644 k8s/dinfochart/templates/tests/test-connection.yaml create mode 100644 k8s/dinfochart/values.yaml diff --git a/k8s/dinfochart/.gitignore b/k8s/dinfochart/.gitignore new file mode 100644 index 0000000000..721e9b3ae7 --- /dev/null +++ b/k8s/dinfochart/.gitignore @@ -0,0 +1 @@ +/charts/ diff --git a/k8s/dinfochart/.helmignore b/k8s/dinfochart/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/k8s/dinfochart/.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/dinfochart/Chart.yaml b/k8s/dinfochart/Chart.yaml new file mode 100644 index 0000000000..38cc46e2ee --- /dev/null +++ b/k8s/dinfochart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: dinfochart +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" diff --git a/k8s/dinfochart/templates/NOTES.txt b/k8s/dinfochart/templates/NOTES.txt new file mode 100644 index 0000000000..38d5063ac4 --- /dev/null +++ b/k8s/dinfochart/templates/NOTES.txt @@ -0,0 +1,35 @@ +1. Get the application URL by running these commands: +{{- if .Values.httpRoute.enabled }} +{{- if .Values.httpRoute.hostnames }} + export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }} +{{- else }} + export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}") + {{- end }} +{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }} + echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application" + + NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules. + The rules can be set for path, method, header and query parameters. + You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml' +{{- end }} +{{- else if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dinfochart.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dinfochart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dinfochart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dinfochart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/k8s/dinfochart/templates/_helpers.tpl b/k8s/dinfochart/templates/_helpers.tpl new file mode 100644 index 0000000000..4c45c4b07d --- /dev/null +++ b/k8s/dinfochart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dinfochart.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 "dinfochart.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 "dinfochart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dinfochart.labels" -}} +helm.sh/chart: {{ include "dinfochart.chart" . }} +{{ include "dinfochart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dinfochart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dinfochart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dinfochart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dinfochart.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/k8s/dinfochart/templates/deployment.yaml b/k8s/dinfochart/templates/deployment.yaml new file mode 100644 index 0000000000..303e64816a --- /dev/null +++ b/k8s/dinfochart/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dinfochart.fullname" . }} + labels: + {{- include "dinfochart.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "dinfochart.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "dinfochart.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "dinfochart.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/k8s/dinfochart/templates/hpa.yaml b/k8s/dinfochart/templates/hpa.yaml new file mode 100644 index 0000000000..21d114db73 --- /dev/null +++ b/k8s/dinfochart/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "dinfochart.fullname" . }} + labels: + {{- include "dinfochart.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "dinfochart.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/k8s/dinfochart/templates/httproute.yaml b/k8s/dinfochart/templates/httproute.yaml new file mode 100644 index 0000000000..1dd13d6c9b --- /dev/null +++ b/k8s/dinfochart/templates/httproute.yaml @@ -0,0 +1,38 @@ +{{- if .Values.httpRoute.enabled -}} +{{- $fullName := include "dinfochart.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }} + labels: + {{- include "dinfochart.labels" . | nindent 4 }} + {{- with .Values.httpRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- with .Values.httpRoute.parentRefs }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.httpRoute.hostnames }} + hostnames: + {{- toYaml . | nindent 4 }} + {{- end }} + rules: + {{- range .Values.httpRoute.rules }} + {{- with .matches }} + - matches: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .filters }} + filters: + {{- toYaml . | nindent 8 }} + {{- end }} + backendRefs: + - name: {{ $fullName }} + port: {{ $svcPort }} + weight: 1 + {{- end }} +{{- end }} diff --git a/k8s/dinfochart/templates/ingress.yaml b/k8s/dinfochart/templates/ingress.yaml new file mode 100644 index 0000000000..764ae3ce31 --- /dev/null +++ b/k8s/dinfochart/templates/ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "dinfochart.fullname" . }} + labels: + {{- include "dinfochart.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "dinfochart.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/k8s/dinfochart/templates/service.yaml b/k8s/dinfochart/templates/service.yaml new file mode 100644 index 0000000000..d1e16ddb4e --- /dev/null +++ b/k8s/dinfochart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dinfochart.fullname" . }} + labels: + {{- include "dinfochart.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "dinfochart.selectorLabels" . | nindent 4 }} diff --git a/k8s/dinfochart/templates/serviceaccount.yaml b/k8s/dinfochart/templates/serviceaccount.yaml new file mode 100644 index 0000000000..80ec4d3504 --- /dev/null +++ b/k8s/dinfochart/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dinfochart.serviceAccountName" . }} + labels: + {{- include "dinfochart.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/k8s/dinfochart/templates/tests/test-connection.yaml b/k8s/dinfochart/templates/tests/test-connection.yaml new file mode 100644 index 0000000000..67cff84064 --- /dev/null +++ b/k8s/dinfochart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "dinfochart.fullname" . }}-test-connection" + labels: + {{- include "dinfochart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "dinfochart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/k8s/dinfochart/values.yaml b/k8s/dinfochart/values.yaml new file mode 100644 index 0000000000..644a640ee6 --- /dev/null +++ b/k8s/dinfochart/values.yaml @@ -0,0 +1,161 @@ +# Default values for dinfochart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: nginx + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created. + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account. + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template. + name: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# -- Expose the service via gateway-api HTTPRoute +# Requires Gateway API resources and suitable controller installed within the cluster +# (see: https://gateway-api.sigs.k8s.io/guides/) +httpRoute: + # HTTPRoute enabled. + enabled: false + # HTTPRoute annotations. + annotations: {} + # Which Gateways this Route is attached to. + parentRefs: + - name: gateway + sectionName: http + # namespace: default + # Hostnames matching HTTP header. + hostnames: + - chart-example.local + # List of rules and filters applied. + rules: + - matches: + - path: + type: PathPrefix + value: /headers + # filters: + # - type: RequestHeaderModifier + # requestHeaderModifier: + # set: + # - name: My-Overwrite-Header + # value: this-is-the-only-value + # remove: + # - User-Agent + # - matches: + # - path: + # type: PathPrefix + # value: /echo + # headers: + # - name: version + # value: v2 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 2772da2d04dda53d9a677aa0aacb8f18f5f3db05 Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 16:22:32 +0300 Subject: [PATCH 3/7] Update chart.yaml --- k8s/dinfochart/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s/dinfochart/Chart.yaml b/k8s/dinfochart/Chart.yaml index 38cc46e2ee..9f61b15d84 100644 --- a/k8s/dinfochart/Chart.yaml +++ b/k8s/dinfochart/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: dinfochart -description: A Helm chart for Kubernetes +description: A Helm chart for devops-infoservice # A chart can be either an 'application' or a 'library' chart. # @@ -21,4 +21,4 @@ version: 0.1.0 # 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" +appVersion: "1.1.1" From bfa968f415fd25fedfc2ca641ea75d01e8716085 Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 17:13:53 +0300 Subject: [PATCH 4/7] Fill in the charts --- k8s/deployment.yml | 43 ------ k8s/dinfochart/templates/deployment.yaml | 57 ++------ k8s/dinfochart/templates/service.yaml | 11 +- k8s/dinfochart/values.yaml | 171 +++-------------------- k8s/service.yml | 13 -- 5 files changed, 36 insertions(+), 259 deletions(-) delete mode 100644 k8s/deployment.yml delete mode 100644 k8s/service.yml diff --git a/k8s/deployment.yml b/k8s/deployment.yml deleted file mode 100644 index 5b57351844..0000000000 --- a/k8s/deployment.yml +++ /dev/null @@ -1,43 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: devops-infoservice - labels: - app: devops-infoservice -spec: - replicas: 5 - selector: - matchLabels: - app: devops-infoservice - strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 1 # Extra pods during update - maxUnavailable: 0 # Ensure availability - template: - metadata: - labels: - app: devops-infoservice - spec: - containers: - - name: devops-infoservice - image: 127.0.0.1:5000/timurusmanov/devops-infoservice:latest - ports: - - containerPort: 5000 - resources: - requests: - memory: "128Mi" - cpu: "100m" - limits: - memory: "256Mi" - cpu: "200m" - livenessProbe: - httpGet: - path: /health - port: 5000 - initialDelaySeconds: 10 - readinessProbe: - httpGet: - path: /health - port: 5000 - initialDelaySeconds: 5 diff --git a/k8s/dinfochart/templates/deployment.yaml b/k8s/dinfochart/templates/deployment.yaml index 303e64816a..0cc9082554 100644 --- a/k8s/dinfochart/templates/deployment.yaml +++ b/k8s/dinfochart/templates/deployment.yaml @@ -5,45 +5,32 @@ metadata: labels: {{- include "dinfochart.labels" . | nindent 4 }} spec: - {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} - {{- end }} selector: matchLabels: {{- include "dinfochart.selectorLabels" . | nindent 6 }} + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 # Extra pods during update + maxUnavailable: 0 # Ensure availability template: metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} labels: {{- include "dinfochart.labels" . | nindent 8 }} {{- with .Values.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "dinfochart.serviceAccountName" . }} - {{- with .Values.podSecurityContext }} - securityContext: - {{- toYaml . | nindent 8 }} - {{- end }} containers: - name: {{ .Chart.Name }} - {{- with .Values.securityContext }} - securityContext: + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + ports: + - containerPort: {{ .Values.service.port }} + {{- with .Values.resources }} + resources: {{- toYaml . | nindent 12 }} {{- end }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.service.port }} - protocol: TCP {{- with .Values.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} @@ -52,27 +39,3 @@ spec: readinessProbe: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.resources }} - resources: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.volumeMounts }} - volumeMounts: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.volumes }} - volumes: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/k8s/dinfochart/templates/service.yaml b/k8s/dinfochart/templates/service.yaml index d1e16ddb4e..ba11f6feea 100644 --- a/k8s/dinfochart/templates/service.yaml +++ b/k8s/dinfochart/templates/service.yaml @@ -5,11 +5,10 @@ metadata: labels: {{- include "dinfochart.labels" . | nindent 4 }} spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http + type: NodePort selector: {{- include "dinfochart.selectorLabels" . | nindent 4 }} + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} diff --git a/k8s/dinfochart/values.yaml b/k8s/dinfochart/values.yaml index 644a640ee6..ddbdd5a6df 100644 --- a/k8s/dinfochart/values.yaml +++ b/k8s/dinfochart/values.yaml @@ -1,161 +1,32 @@ -# Default values for dinfochart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ -replicaCount: 1 - -# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +replicaCount: 5 image: - repository: nginx - # This sets the pull policy for images. + repository: timurusmanov/devops-infoservice + tag: "1.1.1" pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ -imagePullSecrets: [] -# This is to override the chart name. -nameOverride: "" -fullnameOverride: "" - -# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ -serviceAccount: - # Specifies whether a service account should be created. - create: true - # Automatically mount a ServiceAccount's API credentials? - automount: true - # Annotations to add to the service account. - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template. - name: "" -# This is for setting Kubernetes Annotations to a Pod. -# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ -podAnnotations: {} -# This is for setting Kubernetes Labels to a Pod. -# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ -podLabels: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ service: - # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types - type: ClusterIP - # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + type: NodePort port: 80 + targetPort: 5000 -# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -# -- Expose the service via gateway-api HTTPRoute -# Requires Gateway API resources and suitable controller installed within the cluster -# (see: https://gateway-api.sigs.k8s.io/guides/) -httpRoute: - # HTTPRoute enabled. - enabled: false - # HTTPRoute annotations. - annotations: {} - # Which Gateways this Route is attached to. - parentRefs: - - name: gateway - sectionName: http - # namespace: default - # Hostnames matching HTTP header. - hostnames: - - chart-example.local - # List of rules and filters applied. - rules: - - matches: - - path: - type: PathPrefix - value: /headers - # filters: - # - type: RequestHeaderModifier - # requestHeaderModifier: - # set: - # - name: My-Overwrite-Header - # value: this-is-the-only-value - # remove: - # - User-Agent - # - matches: - # - path: - # type: PathPrefix - # value: /echo - # headers: - # - name: version - # value: v2 +resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ livenessProbe: httpGet: - path: / - port: http + path: /health + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 + readinessProbe: httpGet: - path: / - port: http - -# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -# Additional volumes on the output Deployment definition. -volumes: [] - # - name: foo - # secret: - # secretName: mysecret - # optional: false - -# Additional volumeMounts on the output Deployment definition. -volumeMounts: [] - # - name: foo - # mountPath: "/etc/foo" - # readOnly: true - -nodeSelector: {} - -tolerations: [] - -affinity: {} + path: /health + port: 5000 + initialDelaySeconds: 5 + periodSeconds: 3 diff --git a/k8s/service.yml b/k8s/service.yml deleted file mode 100644 index 853cd0860f..0000000000 --- a/k8s/service.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: devops-infoservice-service -spec: - type: NodePort - selector: - app: devops-infoservice # Must match Deployment labels - ports: - - protocol: TCP - port: 80 # Service port - targetPort: 5000 # Container port - nodePort: 30080 # Optional: specific node port (30000-32767) From f2f54eba9fd6cd0ce068eb47b843056feb19f1f4 Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 17:19:04 +0300 Subject: [PATCH 5/7] Remove extra files, finish task2 --- k8s/LAB10.md | 238 ++++++++++++++++++ k8s/dinfochart/templates/NOTES.txt | 35 --- k8s/dinfochart/templates/hpa.yaml | 32 --- k8s/dinfochart/templates/httproute.yaml | 38 --- k8s/dinfochart/templates/ingress.yaml | 43 ---- k8s/dinfochart/templates/serviceaccount.yaml | 13 - .../templates/tests/test-connection.yaml | 15 -- 7 files changed, 238 insertions(+), 176 deletions(-) delete mode 100644 k8s/dinfochart/templates/hpa.yaml delete mode 100644 k8s/dinfochart/templates/httproute.yaml delete mode 100644 k8s/dinfochart/templates/ingress.yaml delete mode 100644 k8s/dinfochart/templates/serviceaccount.yaml delete mode 100644 k8s/dinfochart/templates/tests/test-connection.yaml diff --git a/k8s/LAB10.md b/k8s/LAB10.md index a64b6318c4..d8c06a88fa 100644 --- a/k8s/LAB10.md +++ b/k8s/LAB10.md @@ -82,3 +82,241 @@ sources: type: application version: 28.14.1 ``` + +# Task 2 + +```sh +helm lint dinfochart +``` +```text +==> Linting dinfochart +[INFO] Chart.yaml: icon is recommended + +1 chart(s) linted, 0 chart(s) failed +``` + +```sh +helm template dinfochart dinfochart/ +``` +```yaml +--- +# Source: dinfochart/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: dinfochart + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + type: NodePort + selector: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: dinfochart + ports: + - protocol: TCP + port: 80 + targetPort: 5000 +--- +# Source: dinfochart/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: dinfochart + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + replicas: 5 + selector: + matchLabels: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: dinfochart + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 # Extra pods during update + maxUnavailable: 0 # Ensure availability + template: + metadata: + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: dinfochart + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + spec: + containers: + - name: dinfochart + image: "timurusmanov/devops-infoservice:1.1.1" + ports: + - containerPort: 80 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi + livenessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 + readinessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 5 + periodSeconds: 3 +``` + +```sh +helm install --dry-run --debug test-release dinfochart/ +``` +```text +level=WARN msg="--dry-run is deprecated and should be replaced with '--dry-run=client'" +level=DEBUG msg="Original chart version" version="" +level=DEBUG msg="Chart path" path=/home/timur/proj/DevOps-Core-Course/k8s/dinfochart +level=DEBUG msg="number of dependencies in the chart" chart=dinfochart dependencies=0 +NAME: test-release +LAST DEPLOYED: Thu Apr 2 17:17:49 2026 +NAMESPACE: default +STATUS: pending-install +REVISION: 1 +DESCRIPTION: Dry run complete +TEST SUITE: None +USER-SUPPLIED VALUES: +{} + +COMPUTED VALUES: +image: + pullPolicy: IfNotPresent + repository: timurusmanov/devops-infoservice + tag: 1.1.1 +livenessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 +readinessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 5 + periodSeconds: 3 +replicaCount: 5 +resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi +service: + port: 80 + targetPort: 5000 + type: NodePort + +HOOKS: +MANIFEST: +--- +# Source: dinfochart/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: test-release-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + type: NodePort + selector: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + ports: + - protocol: TCP + port: 80 + targetPort: 5000 +--- +# Source: dinfochart/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-release-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + replicas: 5 + selector: + matchLabels: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 # Extra pods during update + maxUnavailable: 0 # Ensure availability + template: + metadata: + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + spec: + containers: + - name: dinfochart + image: "timurusmanov/devops-infoservice:1.1.1" + ports: + - containerPort: 80 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi + livenessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 + readinessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 5 + periodSeconds: 3 + +``` + +```sh +helm install myrelease dinfochart/ +``` +```text +NAME: myrelease +LAST DEPLOYED: Thu Apr 2 17:18:20 2026 +NAMESPACE: default +STATUS: deployed +REVISION: 1 +DESCRIPTION: Install complete +TEST SUITE: None +``` diff --git a/k8s/dinfochart/templates/NOTES.txt b/k8s/dinfochart/templates/NOTES.txt index 38d5063ac4..e69de29bb2 100644 --- a/k8s/dinfochart/templates/NOTES.txt +++ b/k8s/dinfochart/templates/NOTES.txt @@ -1,35 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.httpRoute.enabled }} -{{- if .Values.httpRoute.hostnames }} - export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }} -{{- else }} - export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}") - {{- end }} -{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }} - echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application" - - NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules. - The rules can be set for path, method, header and query parameters. - You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml' -{{- end }} -{{- else if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dinfochart.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dinfochart.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dinfochart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dinfochart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/k8s/dinfochart/templates/hpa.yaml b/k8s/dinfochart/templates/hpa.yaml deleted file mode 100644 index 21d114db73..0000000000 --- a/k8s/dinfochart/templates/hpa.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "dinfochart.fullname" . }} - labels: - {{- include "dinfochart.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "dinfochart.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/k8s/dinfochart/templates/httproute.yaml b/k8s/dinfochart/templates/httproute.yaml deleted file mode 100644 index 1dd13d6c9b..0000000000 --- a/k8s/dinfochart/templates/httproute.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- if .Values.httpRoute.enabled -}} -{{- $fullName := include "dinfochart.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -apiVersion: gateway.networking.k8s.io/v1 -kind: HTTPRoute -metadata: - name: {{ $fullName }} - labels: - {{- include "dinfochart.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - parentRefs: - {{- with .Values.httpRoute.parentRefs }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.httpRoute.hostnames }} - hostnames: - {{- toYaml . | nindent 4 }} - {{- end }} - rules: - {{- range .Values.httpRoute.rules }} - {{- with .matches }} - - matches: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .filters }} - filters: - {{- toYaml . | nindent 8 }} - {{- end }} - backendRefs: - - name: {{ $fullName }} - port: {{ $svcPort }} - weight: 1 - {{- end }} -{{- end }} diff --git a/k8s/dinfochart/templates/ingress.yaml b/k8s/dinfochart/templates/ingress.yaml deleted file mode 100644 index 764ae3ce31..0000000000 --- a/k8s/dinfochart/templates/ingress.yaml +++ /dev/null @@ -1,43 +0,0 @@ -{{- if .Values.ingress.enabled -}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ include "dinfochart.fullname" . }} - labels: - {{- include "dinfochart.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- with .Values.ingress.className }} - ingressClassName: {{ . }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- with .pathType }} - pathType: {{ . }} - {{- end }} - backend: - service: - name: {{ include "dinfochart.fullname" $ }} - port: - number: {{ $.Values.service.port }} - {{- end }} - {{- end }} -{{- end }} diff --git a/k8s/dinfochart/templates/serviceaccount.yaml b/k8s/dinfochart/templates/serviceaccount.yaml deleted file mode 100644 index 80ec4d3504..0000000000 --- a/k8s/dinfochart/templates/serviceaccount.yaml +++ /dev/null @@ -1,13 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "dinfochart.serviceAccountName" . }} - labels: - {{- include "dinfochart.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -automountServiceAccountToken: {{ .Values.serviceAccount.automount }} -{{- end }} diff --git a/k8s/dinfochart/templates/tests/test-connection.yaml b/k8s/dinfochart/templates/tests/test-connection.yaml deleted file mode 100644 index 67cff84064..0000000000 --- a/k8s/dinfochart/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "dinfochart.fullname" . }}-test-connection" - labels: - {{- include "dinfochart.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "dinfochart.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never From 5bc1d40cb62795c58a8b39b5e601a61de855571d Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 17:25:38 +0300 Subject: [PATCH 6/7] Task 4 overrides --- k8s/dinfochart/values-dev.yaml | 19 +++++++++++++++++++ k8s/dinfochart/values-prod.yaml | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 k8s/dinfochart/values-dev.yaml create mode 100644 k8s/dinfochart/values-prod.yaml diff --git a/k8s/dinfochart/values-dev.yaml b/k8s/dinfochart/values-dev.yaml new file mode 100644 index 0000000000..5995b940e4 --- /dev/null +++ b/k8s/dinfochart/values-dev.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + tag: "latest" + +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + +service: + type: NodePort + +livenessProbe: + initialDelaySeconds: 5 + periodSeconds: 10 diff --git a/k8s/dinfochart/values-prod.yaml b/k8s/dinfochart/values-prod.yaml new file mode 100644 index 0000000000..17836a184e --- /dev/null +++ b/k8s/dinfochart/values-prod.yaml @@ -0,0 +1,23 @@ +replicaCount: 5 + +image: + tag: "1.0.0" # Specific version + +resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 200m + memory: 256Mi + +service: + type: LoadBalancer + +livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 5 + +readinessProbe: + initialDelaySeconds: 10 + periodSeconds: 3 From de4221a38e6185d0d65044a547f16999a62f5a73 Mon Sep 17 00:00:00 2001 From: Timur Usmanov Date: Thu, 2 Apr 2026 21:16:13 +0300 Subject: [PATCH 7/7] Lab10 done --- k8s/HELM.md | 428 ++++++++++++++++++ k8s/LAB10.md | 125 +++++ .../templates/hooks/post-install-job.yaml | 20 + .../templates/hooks/pre-install-job.yaml | 20 + 4 files changed, 593 insertions(+) create mode 100644 k8s/HELM.md create mode 100644 k8s/dinfochart/templates/hooks/post-install-job.yaml create mode 100644 k8s/dinfochart/templates/hooks/pre-install-job.yaml diff --git a/k8s/HELM.md b/k8s/HELM.md new file mode 100644 index 0000000000..726e0ca50a --- /dev/null +++ b/k8s/HELM.md @@ -0,0 +1,428 @@ +# Chart Overview +### Chart structure explanation +Here is the file tree structure: + +``` +dinfochart/ +├── charts +├── Chart.yaml +├── templates +│   ├── deployment.yaml +│   ├── _helpers.tpl +│   ├── hooks +│   │   ├── post-install-job.yaml +│   │   └── pre-install-job.yaml +│   ├── NOTES.txt +│   └── service.yaml +├── values-dev.yaml +├── values-prod.yaml +└── values.yaml +``` + +### Key template files and their purpose +- `_helpers.tpl`: defines helpful values for templates +- `deployment.yaml`: defines the structure for the k8s deployment +- `service.yaml`: defines the structure for the k8s service + +### Values organization strategy +We extract the values or blocks that we would like to be configurable from the `.yaml` files into `values.yaml`, +preserving the original names for clarity. + +# Configuration Guide +### Important values and their purpose + +- `replicaCount`: number of pods that will be run. +- `image`: the information about which image to pull (name, tag) +- `service`: configuration for the reverse proxy +- `resources`: limits and reservations for memory and CPU time +- `livenessProbe`: command for checking the responsiveness of a container +- `readinessProbe`: command for checking the health of a container + +### How to customize for different environments +We define another value file with overrides and later supply it in the command: + +```bash +helm install myapp-dev k8s/mychart -f k8s/mychart/values-dev.yaml +``` + +Or specify overrides right in the command line: +```bash +helm install myapp k8s/mychart --set replicaCount=10 +``` + +### Example installations with different configurations +As shown in the lab material: +```bash +# Development +helm install myapp-dev k8s/mychart -f k8s/mychart/values-dev.yaml + +# Production +helm install myapp-prod k8s/mychart -f k8s/mychart/values-prod.yaml + +# Override specific value +helm install myapp k8s/mychart --set replicaCount=10 +``` + +# Hook Implementation +### What hooks you implemented and why +I implemented the pre-install hook and the post-install one. I did that because it was prescribed by the lab. + +### Hook execution order and weights +Hook | Order | Weight +------------------------------ +Pre-install | Before | -5 +Post-install | After | 5 + +### Deletion policies explanation +It allows to set a rule that dictates when the executed hook jobs will be deleted. `before-hook-creation` means right +before the hook is run, its previous invokation will be deleted. `hook-succeeded` and `hook-failed` delete the hook +immediately after it succeeds or fails (respectively). + +# Installation Evidence +### `helm list` output +```text +NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION +myrelease default 1 2026-04-02 18:01:48.36966193 +0300 MSK deployed dinfochart-0.1.0 1.1.1 +``` + +### `kubectl get all` showing deployed resources +```text +NAME READY STATUS RESTARTS AGE +pod/myrelease-dinfochart-5b67fb98d9-2jk9d 1/1 Running 0 22m +pod/myrelease-dinfochart-5b67fb98d9-8c448 1/1 Running 0 22m +pod/myrelease-dinfochart-5b67fb98d9-fq5mz 1/1 Running 0 22m +pod/myrelease-dinfochart-5b67fb98d9-v5zjk 1/1 Running 0 22m +pod/myrelease-dinfochart-5b67fb98d9-wtx52 1/1 Running 0 22m + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/kubernetes ClusterIP 10.96.0.1 443/TCP 9d +service/myrelease-dinfochart NodePort 10.102.118.72 80:30952/TCP 22m + +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/myrelease-dinfochart 5/5 5 5 22m + +NAME DESIRED CURRENT READY AGE +replicaset.apps/myrelease-dinfochart-5b67fb98d9 5 5 5 22m +``` +### Hook execution output (`kubectl get jobs`, `kubectl describe job`) +As per the deletion policy, the hook jobs get deleted after they run and succeed, which is my case. These commands +report errors because there are no jobs to inspect. + +### Different environment deployments (dev vs prod) +`dev` is for testing the latest changes (with the `latest` tag, plenty of resources). + +`prod` is for deployment on a real cluster (with a fixed version and limited resources). + +# Operations +### Installation commands used +```text +helm install [-f ] +``` + +### How to upgrade a release +```bash +helm upgrade myrelease ./mychart +``` + +### How to rollback +```bash +helm rollback myrelease 1 +``` + +### How to uninstall +```bash +helm uninstall myrelease +``` + +# Testing & Validation +### `helm lint` output +```text +==> Linting dinfochart/ +[INFO] Chart.yaml: icon is recommended + +1 chart(s) linted, 0 chart(s) failed +``` + +### `helm template` verification +```yaml +--- +# Source: dinfochart/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: release-name-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + type: NodePort + selector: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + ports: + - protocol: TCP + port: 80 + targetPort: 5000 +--- +# Source: dinfochart/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: release-name-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + replicas: 5 + selector: + matchLabels: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 # Extra pods during update + maxUnavailable: 0 # Ensure availability + template: + metadata: + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + spec: + containers: + - name: dinfochart + image: "timurusmanov/devops-infoservice:1.1.1" + ports: + - containerPort: 80 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi + livenessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 + readinessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 5 + periodSeconds: 3 +--- +# Source: dinfochart/templates/hooks/post-install-job.yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: 'release-name-dinfochart-post-install' + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-weight": "5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: 'release-name-dinfochart-post-install' + spec: + restartPolicy: Never + containers: + - name: post-install-job + image: busybox + command: ['sh', '-c', 'echo Post-install validation && sleep 1 && echo Validation passed'] +--- +# Source: dinfochart/templates/hooks/pre-install-job.yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: 'release-name-dinfochart-pre-install' + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: release-name + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "-5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: 'release-name-dinfochart-pre-install' + spec: + restartPolicy: Never + containers: + - name: pre-install-job + image: busybox + command: ['sh', '-c', 'echo Pre-install task running && sleep 1 && echo Pre-install completed'] +``` + +### Dry-run output +```yaml +NAME: test-release +LAST DEPLOYED: Thu Apr 2 18:29:57 2026 +NAMESPACE: default +STATUS: pending-install +REVISION: 1 +DESCRIPTION: Dry run complete +TEST SUITE: None +HOOKS: +--- +# Source: dinfochart/templates/hooks/post-install-job.yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: 'test-release-dinfochart-post-install' + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-weight": "5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: 'test-release-dinfochart-post-install' + spec: + restartPolicy: Never + containers: + - name: post-install-job + image: busybox + command: ['sh', '-c', 'echo Post-install validation && sleep 1 && echo Validation passed'] +--- +# Source: dinfochart/templates/hooks/pre-install-job.yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: 'test-release-dinfochart-pre-install' + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "-5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: 'test-release-dinfochart-pre-install' + spec: + restartPolicy: Never + containers: + - name: pre-install-job + image: busybox + command: ['sh', '-c', 'echo Pre-install task running && sleep 1 && echo Pre-install completed'] +MANIFEST: +--- +# Source: dinfochart/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: test-release-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + type: NodePort + selector: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + ports: + - protocol: TCP + port: 80 + targetPort: 5000 +--- +# Source: dinfochart/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-release-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm +spec: + replicas: 5 + selector: + matchLabels: + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 # Extra pods during update + maxUnavailable: 0 # Ensure availability + template: + metadata: + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + spec: + containers: + - name: dinfochart + image: "timurusmanov/devops-infoservice:1.1.1" + ports: + - containerPort: 80 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi + livenessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 + readinessProbe: + httpGet: + path: /health + port: 5000 + initialDelaySeconds: 5 + periodSeconds: 3 +``` + +### Application accessibility verification +```bash +kubectl port-forward service/myrelease-dinfochart 8080:80 & +curl localhost:8080/health +``` +```json +{"status":"healthy","timestamp":"2026-04-02T15:35:47.354190+00:00","uptime_seconds":2010} +``` diff --git a/k8s/LAB10.md b/k8s/LAB10.md index d8c06a88fa..02f6061fef 100644 --- a/k8s/LAB10.md +++ b/k8s/LAB10.md @@ -320,3 +320,128 @@ REVISION: 1 DESCRIPTION: Install complete TEST SUITE: None ``` + +# Task 4 + +```sh +# Lint chart +helm lint k8s/dinfochart +``` +```text +==> Linting k8s/dinfochart +[INFO] Chart.yaml: icon is recommended + +1 chart(s) linted, 0 chart(s) failed +``` + +```sh +# Dry run to see hooks +helm install --dry-run=client --debug test-release k8s/dinfochart | grep -A 20 "HOOK\|hook" +``` +```text +level=DEBUG msg="Original chart version" version="" +level=DEBUG msg="Chart path" path=/home/timur/proj/DevOps-Core-Course/k8s/dinfochart +level=DEBUG msg="number of dependencies in the chart" chart=dinfochart dependencies=0 +HOOKS: +--- +# Source: dinfochart/templates/hooks/post-install-job.yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: 'test-release-dinfochart-post-install' + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-weight": "5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: 'test-release-dinfochart-post-install' + spec: + restartPolicy: Never + containers: + - name: post-install-job + image: busybox + command: ['sh', '-c', 'echo Post-install validation && sleep 1 && echo Validation passed'] +--- +# Source: dinfochart/templates/hooks/pre-install-job.yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: 'test-release-dinfochart-pre-install' + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart + app.kubernetes.io/instance: test-release + app.kubernetes.io/version: "1.1.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "-5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: 'test-release-dinfochart-pre-install' + spec: + restartPolicy: Never + containers: + - name: pre-install-job + image: busybox + command: ['sh', '-c', 'echo Pre-install task running && sleep 1 && echo Pre-install completed'] +MANIFEST: +--- +# Source: dinfochart/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: test-release-dinfochart + labels: + helm.sh/chart: dinfochart-0.1.0 + app.kubernetes.io/name: dinfochart +``` + +```sh +# Install and watch hooks +helm install myrelease k8s/dinfochart +kubectl get jobs -w +kubectl get pods -w +``` +```text +NAME: myrelease +LAST DEPLOYED: Thu Apr 2 18:01:48 2026 +NAMESPACE: default +STATUS: deployed +REVISION: 1 +DESCRIPTION: Install complete +TEST SUITE: None +``` +```text +No resources found in default namespace. +``` +```text +NAME READY STATUS RESTARTS AGE +myrelease-dinfochart-5b67fb98d9-2jk9d 1/1 Running 0 39s +myrelease-dinfochart-5b67fb98d9-8c448 1/1 Running 0 39s +myrelease-dinfochart-5b67fb98d9-fq5mz 1/1 Running 0 39s +myrelease-dinfochart-5b67fb98d9-v5zjk 1/1 Running 0 39s +myrelease-dinfochart-5b67fb98d9-wtx52 1/1 Running 0 39s +``` + +```sh +# Verify deletion policy worked +kubectl get jobs +``` +```text +No resources found in default namespace. +``` + +# Task 5 + +Refer to `k8s/HELM.md`. diff --git a/k8s/dinfochart/templates/hooks/post-install-job.yaml b/k8s/dinfochart/templates/hooks/post-install-job.yaml new file mode 100644 index 0000000000..fa5018c191 --- /dev/null +++ b/k8s/dinfochart/templates/hooks/post-install-job.yaml @@ -0,0 +1,20 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: '{{ include "dinfochart.fullname" . }}-post-install' + labels: + {{- include "dinfochart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-weight": "5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: '{{ include "dinfochart.fullname" . }}-post-install' + spec: + restartPolicy: Never + containers: + - name: post-install-job + image: busybox + command: ['sh', '-c', 'echo Post-install validation && sleep 1 && echo Validation passed'] diff --git a/k8s/dinfochart/templates/hooks/pre-install-job.yaml b/k8s/dinfochart/templates/hooks/pre-install-job.yaml new file mode 100644 index 0000000000..2afe4aef29 --- /dev/null +++ b/k8s/dinfochart/templates/hooks/pre-install-job.yaml @@ -0,0 +1,20 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: '{{ include "dinfochart.fullname" . }}-pre-install' + labels: + {{- include "dinfochart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "-5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: '{{ include "dinfochart.fullname" . }}-pre-install' + spec: + restartPolicy: Never + containers: + - name: pre-install-job + image: busybox + command: ['sh', '-c', 'echo Pre-install task running && sleep 1 && echo Pre-install completed']