Skip to content

Commit

Permalink
build: add pdb/hpa config
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth V. Domingo committed Jun 5, 2024
1 parent 8cb92eb commit 97772fc
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 242 deletions.
41 changes: 37 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,19 @@ tasks:
- docker push {{.DATA_SHARING_PROXY_IMAGE_REPOSITORY}}:{{.COMMIT_SHA}}
- docker push {{.DATA_SHARING_DELTA_IMAGE_REPOSITORY}}:{{.COMMIT_SHA}}

k8s-prereqs:
desc: Install K8s prerequisites
dir: infra/k8s
cmds:
- kubectl apply -f namespace.yaml
- kubectl apply -f configmap.yaml --namespace giga-data-sharing
- kubectl apply -f secrets.yaml --namespace giga-data-sharing

helm-up:
desc: Install/upgrade Helm chart
desc: Install/upgrade Helm chart on a local K8s cluster
dir: infra
cmds:
- kubectl apply -f k8s/namespace.yaml
- kubectl apply -f k8s/configmap.yaml --namespace giga-data-sharing
- kubectl apply -f k8s/secrets.yaml --namespace giga-data-sharing
- task: k8s-prereqs
- >
helm upgrade --install data-sharing-delta ./helm/data-sharing-delta
--namespace giga-data-sharing
Expand All @@ -130,6 +136,33 @@ tasks:
--set image.tag={{.COMMIT_SHA}}
--set service.type=LoadBalancer
helm-upi:
desc: Install/upgrade Helm chart on a K8s cluster with configured ingress
dir: infra
cmds:
- task: k8s-prereqs
- >
helm upgrade --install data-sharing-delta ./helm/data-sharing-delta
--namespace giga-data-sharing
--set image.repository={{.DATA_SHARING_DELTA_IMAGE_REPOSITORY}}
--set image.tag={{.COMMIT_SHA}}
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
- >
helm upgrade --install data-sharing-proxy ./helm/data-sharing-proxy
--namespace giga-data-sharing
--set image.repository={{.DATA_SHARING_PROXY_IMAGE_REPOSITORY}}
--set image.tag={{.COMMIT_SHA}}
--set ingress.enabled=true
--set ingress.annotations=null
--set ingress.hosts[0].host={{.DATA_SHARING_INGRESS_HOST}}
--set ingress.hosts[0].paths[0].path=/
--set ingress.hosts[0].paths[0].pathType=Prefix
--set postgresql.primary.readinessProbe.enabled=false
--set postgresql.primary.livenessProbe.enabled=false
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
helm-down:
desc: Uninstall Helm chart
cmds:
Expand Down
43 changes: 40 additions & 3 deletions azure/templates/helm-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
- checkout: self

- task: HelmDeploy@0
displayName: Helm deploy Data Sharing Delta
displayName: Helm deploy Data Sharing Delta dev
condition: eq(variables.environment, 'dev')
inputs:
command: upgrade
chartType: FilePath
Expand All @@ -20,9 +21,41 @@ jobs:
--set image.repository="$(containerRegistryName).azurecr.io/giga-data-sharing-delta"
--set image.tag="$(Build.SourceVersion)"
- task: HelmDeploy@0
displayName: Helm deploy Data Sharing Delta stg/prd
condition: or(eq(variables.environment, 'stg'), eq(variables.environment, 'prd'))
inputs:
command: upgrade
chartType: FilePath
chartPath: infra/helm/data-sharing-delta
releaseName: data-sharing-delta
namespace: $(kubernetesNamespace)
arguments: >
--set image.repository="$(containerRegistryName).azurecr.io/giga-data-sharing-delta"
--set image.tag="$(Build.SourceVersion)"
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
- task: HelmDeploy@0
displayName: Helm deploy Data Sharing proxy dev
condition: eq(variables.environment, 'dev')
inputs:
command: upgrade
chartType: FilePath
chartPath: infra/helm/data-sharing-proxy
releaseName: data-sharing-proxy
namespace: $(kubernetesNamespace)
arguments: >
--set image.repository="$(containerRegistryName).azurecr.io/giga-data-sharing-proxy"
--set image.tag="$(Build.SourceVersion)"
--set ingress.enabled=true
--set ingress.hosts[0].host="$(ingressHost)"
--set ingress.hosts[0].paths[0].path="/"
--set ingress.hosts[0].paths[0].pathType=Prefix
- task: HelmDeploy@0
displayName: Helm deploy Data Sharing proxy
condition: or(eq(variables.environment, 'dev'), eq(variables.environment, 'stg'))
condition: eq(variables.environment, 'stg')
inputs:
command: upgrade
chartType: FilePath
Expand All @@ -36,9 +69,11 @@ jobs:
--set ingress.hosts[0].host="$(ingressHost)"
--set ingress.hosts[0].paths[0].path="/"
--set ingress.hosts[0].paths[0].pathType=Prefix
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
- task: HelmDeploy@0
displayName: Helm deploy production-config Data Sharing proxy
displayName: Helm deploy Data Sharing proxy prd
condition: eq(variables.environment, 'prd')
inputs:
command: upgrade
Expand All @@ -54,3 +89,5 @@ jobs:
--set ingress.hosts[0].paths[0].path="/"
--set ingress.hosts[0].paths[0].pathType=Prefix
--set ingress.annotations."appgw\.ingress\.kubernetes\.io/appgw-ssl-certificate"=kv-cert-gigaglobal
--set autoscaling.enabled=true
--set podDisruptionBudget.enabled=true
44 changes: 0 additions & 44 deletions custom-sas-provider/.dockerignore

This file was deleted.

44 changes: 0 additions & 44 deletions custom-sas-provider/.gitignore

This file was deleted.

84 changes: 0 additions & 84 deletions custom-sas-provider/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 12 additions & 0 deletions infra/helm/data-sharing-delta/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.podDisruptionBudget.enabled }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: "{{ include "data-sharing-delta.fullname" . }}-pdb"
spec:
selector:
matchLabels:
{{- include "data-sharing-delta.selectorLabels" . | nindent 6 }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
8 changes: 6 additions & 2 deletions infra/helm/data-sharing-delta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ resources: { }

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
minReplicas: 2
maxReplicas: 5
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

podDisruptionBudget:
enabled: false
minAvailable: 2

nodeSelector: { }

tolerations: [ ]
Expand Down
6 changes: 6 additions & 0 deletions infra/helm/data-sharing-proxy/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ spec:
name: {{ include "data-sharing-proxy.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
behavior:
scaleUp:
policies:
- type: Pods
periodSeconds: 30
value: 1
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
Expand Down
Loading

0 comments on commit 97772fc

Please sign in to comment.