Skip to content

Commit

Permalink
Merge pull request #323 from jkugiya/SPIC-1016/statefulset4akka
Browse files Browse the repository at this point in the history
Enables to use StatefulSet in akka
  • Loading branch information
saramune authored Nov 14, 2024
2 parents ddb5e6b + b8d6428 commit 416369b
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 2 deletions.
2 changes: 1 addition & 1 deletion akka/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.2.20
version: 0.2.21

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
Expand Down
6 changes: 6 additions & 0 deletions akka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ The following table lists the configurable parameters of the akka chart and thei
| `rollout.replicaCount` | Number of replicas for the rollout | `3` |
| `rollout.revisionHistoryLimit` | The number of old ReplicaSets to retain to allow rollback for the rollout | `10` |
| `rollout.strategy` | Specifies the strategy used to replace old pods by new ones for the rollout | `{}` |
| `deployment.enabled` | Specifies whether to create a deployment resource | `true` |
| `statefulset.enabled` | Specifies whether to create a statefulset resource | `false` |
| `statefulSet.updateStrategy` | Specifies the strategy used to replace old pods by new ones for the StatefulSet | `{}` |
| `statefulSet.podManagementPolicy` | statefulset allows you to relax its ordering guarantees while preserving its uniqueness and identity guarantees | `Parallel` |
| `statefulSet.env` | Extra environment variables that will be passed onto pods for StatefulSet. If not set it will be fallback to `env`.| `[]` |


## Akka Configuration file

Expand Down
3 changes: 2 additions & 1 deletion akka/templates/autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- $root := . -}}
{{- if .Values.autoscaling.enabled -}}
{{/* Autoscaler for StatefulSet is not supported for now */}}
{{- if and .Values.autoscaling.enabled .Values.deployment.enabled (not .Values.statefulSet.enabled) -}}
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: autoscaling/v2
{{- else }}
Expand Down
2 changes: 2 additions & 0 deletions akka/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- $root := . -}}
{{- if .Values.deployment.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -234,3 +235,4 @@ spec:
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
239 changes: 239 additions & 0 deletions akka/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{{- $root := . -}}
{{- if .Values.statefulSet.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
{{- with .Values.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "akka.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: "{{ include "akka.fullname" . }}"
spec:
{{- if and (not .Values.autoscaling.enabled) (ne .Values.replicaCount nil) }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "akka.selectorLabels" . | nindent 6 }}
updateStrategy:
{{- toYaml .Values.statefulSet.updateStrategy | nindent 4 }}
podManagementPolicy: {{ .Values.statefulSet.podManagementPolicy }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
annotations:
checksum/configmap: "{{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}"
checksum/secret: "{{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}"
{{- if .Values.metrics.enabled }}
prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.metrics.port }}"
prometheus.io/path: "{{ .Values.metrics.path }}"
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "akka.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
{{- if semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion }}
topologySpreadConstraints:
{{- range .Values.topologySpreadConstraints }}
- maxSkew: {{ .maxSkew }}
topologyKey: {{ .topologyKey }}
whenUnsatisfiable: {{ .whenUnsatisfiable }}
labelSelector:
matchLabels:
{{- include "akka.selectorLabels" $root | nindent 14 }}
{{- end }}
{{- end }}
containers:
- args:
{{- if .Values.useResourceApplicationConf }}
- "-Dconfig.file=/opt/conf/chart.conf"
{{- end }}
command:
{{- toYaml .Values.command | nindent 12 }}
env:
{{- toYaml (default .Values.env .Values.statefulSet.env)| nindent 12 }}
envFrom:
{{- toYaml .Values.envFrom | nindent 12 }}
name: "{{ include "akka.containerName" . }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tags }}"
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
{{- if and .Values.akka.management.enabled .Values.startupProbe.enabled }}
startupProbe:
httpGet:
scheme: HTTP
path: "/{{ .Values.akka.management.healthChecks.startupPath }}"
port: {{ .Values.akka.management.port }}
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.startupProbe.successThreshold }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
{{- else if .Values.startupProbe.enabled }}
startupProbe:
{{- with .Values.startupProbe.httpGet }}
httpGet:
{{- toYaml . | nindent 14 }}
{{- end }}
{{- with .Values.startupProbe.tcpSocket }}
tcpSocket:
{{- toYaml . | nindent 14 }}
{{- end }}
{{- with .Values.startupProbe.exec }}
exec:
{{- toYaml . | nindent 14 }}
{{- end }}
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.startupProbe.successThreshold }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
{{- end }}
{{- if and .Values.akka.management.enabled .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
scheme: HTTP
path: "/{{ .Values.akka.management.healthChecks.livenessPath }}"
port: {{ .Values.akka.management.port }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- else if .Values.livenessProbe.enabled }}
livenessProbe:
{{- with .Values.livenessProbe.httpGet }}
httpGet:
{{- toYaml . | nindent 14 }}
{{- end }}
{{- with .Values.livenessProbe.tcpSocket }}
tcpSocket:
{{- toYaml . | nindent 14 }}
{{- end }}
{{- with .Values.livenessProbe.exec }}
exec:
{{- toYaml . | nindent 14 }}
{{- end }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
lifecycle:
{{- toYaml .Values.lifecycle | nindent 12 }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
ports:
{{- if .Values.akka.http.enabled }}
- name: "{{.Values.akka.http.portName }}"
containerPort: {{ .Values.akka.http.port }}
protocol: TCP
{{- with .Values.akka.http.extraPorts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.akka.management.enabled }}
- name: management
containerPort: {{ .Values.akka.management.port }}
protocol: TCP
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
containerPort: {{ .Values.metrics.port }}
protocol: TCP
{{- end }}
{{- if .Values.akka.remote.enabled }}
- name: remoting
containerPort: {{ .Values.akka.remote.port }}
protocol: TCP
{{- end }}
{{- if and .Values.akka.management.enabled .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
scheme: HTTP
path: "/{{ .Values.akka.management.healthChecks.readinessPath }}"
port: {{ .Values.akka.management.port }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- else if .Values.readinessProbe.enabled }}
readinessProbe:
{{- with .Values.readinessProbe.httpGet }}
httpGet:
{{- toYaml . | nindent 14 }}
{{- end }}
{{- with .Values.readinessProbe.tcpSocket }}
tcpSocket:
{{- toYaml . | nindent 14 }}
{{- end }}
{{- with .Values.readinessProbe.exec }}
exec:
{{- toYaml . | nindent 14 }}
{{- end }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if .Values.useResourceApplicationConf }}
{{- range $name, $v := .Values.configmaps }}
{{- if ne $v "" }}
- name: "{{ $name | replace "." "-" | lower }}"
mountPath: "/opt/conf/{{ $name }}"
subPath: "{{ $name }}"
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
readinessGates:
{{- toYaml .Values.readinessGate | nindent 8 }}
restartPolicy: "{{ .Values.restartPolicy }}"
priorityClassName: {{ .Values.priorityClassName | quote }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccountName: "{{ include "akka.serviceAccountName" . }}"
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
tolerations:
{{- toYaml .Values.tolerations | nindent 8 }}
volumes:
{{- if .Values.useResourceApplicationConf }}
{{- range $name, $v := .Values.configmaps }}
{{- if ne $v "" }}
- name: "{{ $name | replace "." "-" | lower }}"
configMap:
name: "{{ template "akka.fullname" $root }}-{{ $name | replace "." "-" | lower }}"
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions akka/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,12 @@ autoscalingRollout:
metrics: []
# This feature is available since 1.18
behavior: {}

deployment:
enabled: true

statefulSet:
enabled: false
env: []
podManagementPolicy: Parallel
updateStrategy: {}

0 comments on commit 416369b

Please sign in to comment.