Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
Signed-off-by: Ashwani Singh <ashwani.singh@opstree.com>
  • Loading branch information
ashwani-opstree committed Jul 9, 2024
1 parent 1942de9 commit df2dfef
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 53 deletions.
2 changes: 2 additions & 0 deletions charts/microservice/examples/config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name=opstree
address=opstreesolution
31 changes: 27 additions & 4 deletions charts/microservice/examples/deploy-nginx.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
global:
namespace: "nginx"
fullnameOverride: "webapp"

deployment:
image:
name: nginx
tag: latest
pullPolicy: IfNotPresent




livenessProbe:
httpGet:
path: "/"
port: http
readinessProbe:
httpGet:
path: "/"
port: http
resources:
requests:
memory: 100Mi
cpu: 100m
limits:
memory: 500Mi
cpu: 500m
volumes:
enabled: true
configMaps:
- name: webapp
mountPath: /webapp
data:
webapp.conf: |
name="opstree"
11 changes: 11 additions & 0 deletions charts/microservice/templates/_capabilities.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ Return the appropriate apiVersion for Horizontal Pod Autoscaler.
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for deployment.
*/}}
{{- define "microservice.capabilities.deployment.apiVersion" -}}
{{- $kubeVersion := include "microservice.capabilities.kubeVersion" . -}}
{{- if and (not (empty $kubeVersion)) (semverCompare "<1.14-0" $kubeVersion) -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/microservice/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data:
{{- range $file := $cm.files }}
{{ $file.destination }}: |
{{ $header | toString | indent 4 }}
{{ $root.Files.Get $file.source }}
{{ $root.Files.Get "$file.source" }}
{{- end}}
{{- end }}
{{- end }}
Expand Down
39 changes: 26 additions & 13 deletions charts/microservice/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,34 @@ metadata:
{{- include "microservice.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: {{ include "microservice.capabilities.deployment.apiVersion" . }}
kind: Deployment
name: {{ include "microservice.fullname" . }}
name: {{ include "microservice.fullname" . }}-app
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
{{- if .Values.hpa.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.hpa.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.hpa.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.hpa.targetMemoryUtilizationPercentage }}
{{- end }}
{{- if .Values.hpa.targetMemory }}
- type: Resource
resource:
name: memory
{{- if semverCompare "<1.23-0" (include "microservice.capabilities.kubeVersion" .) }}
targetAverageUtilization: {{ .Values.hpa.targetMemory }}
{{- else }}
target:
type: Utilization
averageUtilization: {{ .Values.hpa.targetMemory }}
{{- end }}
{{- end }}
{{- if .Values.hpa.targetCPU }}
- type: Resource
resource:
name: cpu
{{- if semverCompare "<1.23-0" (include "microservice.capabilities.kubeVersion" .) }}
targetAverageUtilization: {{ .Values.hpa.targetCPU }}
{{- else }}
target:
type: Utilization
averageUtilization: {{ .Values.hpa.targetCPU }}
{{- end }}
{{- end }}
{{- end }}
69 changes: 34 additions & 35 deletions charts/microservice/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
global:
namespace: "default"
replicaCount: 1
nameOverride: "ashwani"
fullnameOverride: "ashwani"
nameOverride: ""
fullnameOverride: ""
imagePullSecrets: []
environment: {}
# list of key: value
Expand All @@ -24,47 +24,46 @@ deployment:
# Annotation for the Deployment
annotations: {}

livenessProbe: {}
# livenessProbe:
# httpGet:
# path: "/"
# port: http
# initialDelaySeconds: 25
# periodSeconds: 10
# timeoutSeconds: 5
# successThreshold: 1
# failureThreshold: 5

readinessProbe: {}
# readinessProbe:
# httpGet:
# path: "/"
# port: http
# initialDelaySeconds: 25
# periodSeconds: 10
# timeoutSeconds: 5
# successThreshold: 1
# failureThreshold: 5

environment:
ashwani: singh

# environment: {}
# livenessProbe: {}
livenessProbe:
# httpGet:
# path: "/"
# port: http
initialDelaySeconds: 250
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5

# readinessProbe: {}
readinessProbe:
# httpGet:
# path: "/"
# port: http
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5

environment: {}
# VAR1: value1

resources: {}

# resources:
# requests:
# memory: 100m
# memory: 100Mi
# cpu: 100m
# limits:
# memory: 100m
# memory: 100Mi
# cpu: 100m

# Additional volumes on the output Deployment definition.
volumes:
enabled: false
enabled: true
pvc:
enabled: false
# pvc:
# enabled: false
# existing_claim: false
Expand All @@ -79,7 +78,7 @@ deployment:
# line1
# line2

# configMaps:
configMaps:
# - name: test
# mountPath: /test
# data:
Expand Down Expand Up @@ -118,8 +117,8 @@ hpa:
enabled: true
minReplicas: 1
maxReplicas: 1
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
targetCPU: 80
targetMemory: 80

service:
type: ClusterIP
Expand All @@ -129,7 +128,7 @@ service:
name: http

serviceAccount:
create: true
create: false
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
Expand Down

0 comments on commit df2dfef

Please sign in to comment.