diff --git a/charts/durpapi/templates/deployment.yaml b/charts/durpapi/templates/deployment.yaml index 20abc33..9679708 100644 --- a/charts/durpapi/templates/deployment.yaml +++ b/charts/durpapi/templates/deployment.yaml @@ -9,7 +9,7 @@ spec: selector: matchLabels: app: {{ .Chart.Name }} - replicas: {{ .Values.deployment.replicas }} + replicas: {{ .Values.deployment.hpa.minReplicas }} template: metadata: labels: @@ -24,4 +24,10 @@ spec: containerPort: {{ .Values.service.targetport }} envFrom: - secretRef: - name: {{ .Values.deployment.secretfile }} \ No newline at end of file + name: {{ .Values.deployment.secretfile }} + resources: + requests: + memory: {{ .Values.deployment.resources.requests.cpu }} + cpu: {{ .Values.deployment.resources.requests.memory }} + limits: + memory: {{ .Values.deployment.resources.limits.memory }} diff --git a/charts/durpapi/templates/hpa.yaml b/charts/durpapi/templates/hpa.yaml new file mode 100644 index 0000000..aab99d5 --- /dev/null +++ b/charts/durpapi/templates/hpa.yaml @@ -0,0 +1,24 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }}-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: ctix + minReplicas: {{ .Values.deployment.hpa.minReplicas }} + maxReplicas: {{ .Values.deployment.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 40 diff --git a/charts/durpapi/values.yaml b/charts/durpapi/values.yaml index 78d7dca..f795be3 100644 --- a/charts/durpapi/values.yaml +++ b/charts/durpapi/values.yaml @@ -1,9 +1,17 @@ deployment: - replicas: 1 image: registry.gitlab.com/developerdurp/durpapi tag: "" imagePullPolicy: Always secretfile: durpapi-secret + hpa: + minReplicas: 3 + maxReplicas: 10 + resources: + requests: + cpu: "100m" + memory: "50Mi" + limits: + memory: "150Mi" ingress: clusterissuer: letsencrypt-production diff --git a/main.go b/main.go index 5ebe25a..bca4a4e 100644 --- a/main.go +++ b/main.go @@ -86,7 +86,7 @@ func authMiddleware(allowedGroups []string) gin.HandlerFunc { if !isAllowed { c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{ "message": "Unauthorized access", - "groups": groupsHeader, + "groups": allowedGroups, }) return }