-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement application health check and hpa
Signed-off-by: Ashwani Singh <ashwani.singh@opstree.com>
- Loading branch information
1 parent
1a5113d
commit b962755
Showing
7 changed files
with
144 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
--- | ||
apiVersion: v2 | ||
name: microservice | ||
description: A Helm chart for a microservice in Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart | ||
# | ||
# Application chart deploys a complete application, includes all necessary Kubernetes resources, | ||
# used for installing and managing applications. | ||
# | ||
# Library chart provides reusable templates and components, does not deploy an application by itself, | ||
# used to promote consistency and reuse across multiple charts. | ||
type: application | ||
|
||
# This is the chart version. This chart version should be incremented with each change to the chart | ||
# or its templates, including the app version. | ||
# Follow Semantic Versioning (https://semver.org/). | ||
version: 0.1.2 | ||
|
||
# This is the application version number, which should be incremented with each change to the application. | ||
# It doesn't need to follow Semantic Versioning but should reflect the application's version. | ||
# Quotes are recommended. | ||
appVersion: "0.1.2" | ||
|
||
# This is maintainers files. this field lists the individuals or teams responsible for maintaining the Helm chart. | ||
# It typically includes their names and contact information, such as email addresses. | ||
maintainers: | ||
- name: Opstree Solutions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,48 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "app.fullname" . }} | ||
name: {{ include "microservice.fullname" . }} | ||
labels: | ||
{{- include "app.labels" . | nindent 4 }} | ||
{{- include "microservice.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
replicas: {{ .Values.global.replicaCount }} | ||
selector: | ||
matchLabels: | ||
{{- include "app.selectorLabels" . | nindent 6 }} | ||
{{- include "microservice.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "app.selectorLabels" . | nindent 8 }} | ||
{{- include "microservice.selectorLabels" . | nindent 8 }} | ||
spec: | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
- name: {{ include "microservice.fullname" . }} | ||
image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}" | ||
imagePullPolicy: {{ .Values.deployment.image.pullPolicy | default "IfNotPresent" }} | ||
ports: | ||
- name: http | ||
containerPort: 80 | ||
protocol: TCP | ||
{{- if .Values.deployment.livenessProbe }} | ||
livenessProbe: | ||
httpGet: | ||
path: {{ default "/health" .Values.deployment.livenessProbe.httpPath }} | ||
port: http | ||
initialDelaySeconds: {{ default 25 .Values.deployment.livenessProbe.initialDelaySeconds }} | ||
periodSeconds: {{ default 10 .Values.deployment.livenessProbe.periodSeconds }} | ||
timeoutSeconds: {{ default 5 .Values.deployment.livenessProbe.timeoutSeconds }} | ||
successThreshold: {{ default 1 .Values.deployment.livenessProbe.successThreshold }} | ||
failureThreshold: {{ default 5 .Values.deployment.livenessProbe.failureThreshold }} | ||
{{- end }} | ||
{{- if .Values.deployment.readinessProbe }} | ||
readinessProbe: | ||
httpGet: | ||
path: {{ default "/health" .Values.deployment.readinessProbe.httpPath }} | ||
port: http | ||
initialDelaySeconds: {{ default 25 .Values.deployment.readinessProbe.initialDelaySeconds }} | ||
periodSeconds: {{ default 10 .Values.deployment.readinessProbe.periodSeconds }} | ||
timeoutSeconds: {{ default 5 .Values.deployment.readinessProbe.timeoutSeconds }} | ||
successThreshold: {{ default 1 .Values.deployment.readinessProbe.successThreshold }} | ||
failureThreshold: {{ default 5 .Values.deployment.readinessProbe.failureThreshold }} | ||
{{- end }} | ||
resources: | ||
{{- toYaml .Values.deployment.resources | nindent 12 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{- if .Values.hpa }} | ||
apiVersion: autoscaling/v2beta1 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ include "microservice.HorizontalScalingName" . }} | ||
labels: | ||
{{- include "microservice.labels" . | nindent 4 }} | ||
spec: | ||
scaleTargetRef: | ||
kind: Deployment | ||
name: {{ include "microservice.fullname" . }} | ||
minReplicas: {{ default 1 .Values.hpa.minReplicas }} | ||
maxReplicas: {{ default 1 .Values.hpa.maxReplicas }} | ||
metrics: | ||
{{- if .Values.hpa.targetAverageCPUUtilization }} | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
targetAverageUtilization: {{ default 50 .Values.hpa.targetAverageCPUUtilization }} | ||
{{- end }} | ||
{{- if .Values.hpa.targetAverageMemoryUtilization }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
targetAverageUtilization: {{ default 50 .Values.hpa.targetAverageMemoryUtilization }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
replicaCount: 1 | ||
# -- global variables | ||
global: | ||
replicaCount: 1 | ||
fullnameOverride: "nginx" | ||
nameOverride: "" | ||
|
||
fullnameOverride: "nginx" | ||
nameOverride: "" | ||
image: | ||
repository: nginx | ||
pullPolicy: IfNotPresent | ||
tag: "latest" | ||
# -- Object that configures Deployment instance | ||
deployment: | ||
# -- Override default container image format | ||
image: | ||
# -- Image repository | ||
repository: "nginx" | ||
# -- Image tag | ||
tag: "latest" | ||
# -- Variable used to control when the image should be fetched | ||
pullPolicy: always | ||
# -- Definition of the liveness probe | ||
livenessProbe: | ||
httpPath: '/' | ||
# -- Definition of the readiness probe | ||
readinessProbe: | ||
httpPath: '/' | ||
# -- Configure container's resource request and limits | ||
resources: | ||
# -- Resources that the container is guaranteed to get | ||
requests: | ||
# -- Memory that the container is guaranteed to get | ||
memory: | ||
# -- CPU that the container is guaranteed to get | ||
cpu: | ||
# -- Defines a hard ceiling on resource use | ||
limits: | ||
# -- Defines a hard ceiling on how much Memory time that the container can use | ||
memory: | ||
# -- Defines a hard ceiling on how much CPU time that the container can use | ||
cpu: | ||
|
||
hpa: {} | ||
|
||
service: | ||
type: ClusterIP | ||
port: 80 | ||
port: 80 |