diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 91c103d7..77b6919d 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -7,3 +7,6 @@ appVersion: "0.1.2" maintainers: - name: ashwani-opstree - name: tripathishikha1 + - name: khushimalhoz + + diff --git a/charts/microservice/examples/affinity.yaml b/charts/microservice/examples/affinity.yaml new file mode 100644 index 00000000..5c71eaea --- /dev/null +++ b/charts/microservice/examples/affinity.yaml @@ -0,0 +1,38 @@ +global: + namespace: "default" + # replicacount: 5 + 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 + affinity: + enabled: false # Set to false to disable podAntiAffinity + topologySpreadConstraints: + enabled: false # Set to false to disable topologySpreadConstraints + volumes: + enabled: true + configMaps: + - name: index + mountPath: /usr/share/nginx/html + data: + index.html: | + Hello! Opstree + diff --git a/charts/microservice/examples/deploy-nginx.yaml b/charts/microservice/examples/deploy-nginx.yaml index 20311c45..26bda319 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -30,4 +30,3 @@ deployment: data: index.html: | Hello! Opstree - \ No newline at end of file diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 7795ae8d..021dcf38 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -102,9 +102,25 @@ spec: {{- end }} {{- with .Values.deployment.affinity }} affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.deployment.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} + {{- if .Values.deployment.affinity.enabled }} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }} + topologyKey: topology.kubernetes.io/zone + {{- end }} + {{- if .Values.deployment.topologySpreadConstraints.enabled }} + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "topology.kubernetes.io/zone" + whenUnsatisfiable: "DoNotSchedule" + labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }} + minDomains: 2 + {{- end }} {{- end }} + diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 99757b40..e552c4a3 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -120,12 +120,16 @@ deployment: tolerations: [] - affinity: {} + affinity: + enabled: true + + topologySpreadConstraints: + enabled: true hpa: enabled: true - minReplicas: 1 - maxReplicas: 1 + minReplicas: 5 + maxReplicas: 6 targetCPU: 80 targetMemory: 80