diff --git a/dysnix/app/Chart.yaml b/dysnix/app/Chart.yaml index 23e948f9..d293de1a 100644 --- a/dysnix/app/Chart.yaml +++ b/dysnix/app/Chart.yaml @@ -3,7 +3,7 @@ name: app description: Generic application Helm chart home: https://github.com/dysnix/charts/tree/main/dysnix/app icon: https://dysnix.com/images/logo.svg -version: 0.99.17 +version: 0.99.18 sources: - https://github.com/dysnix/charts keywords: diff --git a/dysnix/app/README.md b/dysnix/app/README.md index 193f40da..cee44bd9 100644 --- a/dysnix/app/README.md +++ b/dysnix/app/README.md @@ -293,24 +293,25 @@ containers: ### App chart parameters -| Name | Description | Value | -| ---------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------ | -| `app.name` | Specifies the chart/application name (app.kubernetes.io/name), since this is a generic chart | `app` | -| `app.workload.enabled` | Specifies whether the default workload resource is generated (Deployment/StatefulSet etc) | `true` | -| `app.workload.type` | Specifies type of the main workload resource | `deployment` | -| `app.components` | Specifies list of components to enable used in direct mode (it respectively expects .Values.[component] to be present) | `[]` | -| `selector.matchLabels` | Specifies additional selector labels for the workload resources and services | `{}` | -| `reuse` | Enables reuse/merge of the upper-level component values (applicable for containers/initContainers) | `false` | -| `containers` | Specify a map of additional pod containers | `{}` | -| `initContainers` | Specifies initContainers **(use, values map for order and data)** | `{}` | -| `env` | Name Map of environment variables for the main container | `{}` | -| `envFrom` | Configures of envFrom to include into the main container | `[]` | -| `volumes` | Specify volumes for the main pod | `{}` | -| `volumeMounts` | Specify volumeMounts for the main container | `{}` | -| `configMaps` | Creates application сonfigMaps (note the name is prefixed with the app name) | `{}` | -| `secrets` | Creates application secrets (note the name is prefixed with the app name) | `{}` | -| `templateChecksums` | Specifies list of template files to add as an annotation checksum into the pod. | `[]` | - +| Name | Description | Value | +| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------ | +| `app.name` | Specifies the chart/application name (app.kubernetes.io/name), since this is a generic chart | `app` | +| `app.workload.enabled` | Specifies whether the default workload resource is generated (Deployment/StatefulSet etc) | `true` | +| `app.workload.type` | Specifies type of the main workload resource ("deployment" or "statefulset/sts") | `deployment` | +| `app.components` | Specifies list of components to enable used in direct mode (it respectively expects .Values.[component] to be present) | `[]` | +| `selector.matchLabels` | Specifies additional selector labels for the workload resources and services | `{}` | +| `reuse` | Enables reuse/merge of the upper-level component values (applicable for containers/initContainers) | `false` | +| `enableServiceLinks` | Can be disabled to remove information about services from pod's environment variables | `true` | +| `persistentVolumeClaimRetentionPolicy` | Describes the lifecycle of PVCs created from volumeClaimTemplates (only "statefulset" workload type) | `{}` | +| `containers` | Specify a map of additional pod containers | `{}` | +| `initContainers` | Specifies initContainers **(use, values map for order and data)** | `{}` | +| `env` | Name Map of environment variables for the main container | `{}` | +| `envFrom` | Configures of envFrom to include into the main container | `[]` | +| `volumes` | Specify volumes for the main pod | `{}` | +| `volumeMounts` | Specify volumeMounts for the main container | `{}` | +| `configMaps` | Creates application сonfigMaps (note the name is prefixed with the app name) | `{}` | +| `secrets` | Creates application secrets (note the name is prefixed with the app name) | `{}` | +| `templateChecksums` | Specifies list of template files to add as an annotation checksum into the pod. | `[]` | ### Global parameters @@ -320,7 +321,6 @@ containers: | `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` | | `global.storageClass` | Global StorageClass for Persistent Volume(s) | `""` | - ### Common parameters | Name | Description | Value | @@ -337,11 +337,10 @@ containers: | `diagnosticMode.command` | Command to override all containers in the deployment | `["sleep"]` | | `diagnosticMode.args` | Args to override all containers in the deployment | `["infinity"]` | - ### Main pod Parameters | Name | Description | Value | -| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |-----------------| +| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | | `image.registry` | image registry | `""` | | `image.repository` | image repository | `""` | | `image.tag` | image tag (immutable tags are recommended) | `""` | @@ -400,22 +399,26 @@ containers: | `podAffinityPreset` | Pod affinity preset. Ignored if `affinity` is set. Allowed values: `soft` or `hard` | `""` | | `podAntiAffinityPreset` | Pod anti-affinity preset. Ignored if `affinity` is set. Allowed values: `soft` or `hard` | `soft` | | `pdb.create` | Enable/disable a Pod Disruption Budget creation | `false` | -| `pdb.minAvailable` | Minimum number/percentage of pods that should remain scheduled | `null` | -| `pdb.maxUnavailable` | Maximum number/percentage of pods that may be made unavailable | `null` | +| `pdb.minAvailable` | Minimum number/percentage of pods that should remain scheduled | `nil` | +| `pdb.maxUnavailable` | Maximum number/percentage of pods that may be made unavailable | `nil` | +| `pdb.unhealthyPodEvictionPolicy` | IfHealthyBudget/AlwaysAllow | `nil` | +| `pdb.selector` | extra selector for PDB | `{}` | | `autoscaling.enabled` | Enable autoscaling for %%MAIN_OBJECT_BLOCK%% | `false` | | `autoscaling.minReplicas` | Minimum number of %%MAIN_OBJECT_BLOCK%% replicas | `""` | | `autoscaling.maxReplicas` | Maximum number of %%MAIN_OBJECT_BLOCK%% replicas | `""` | | `autoscaling.targetCPU` | Target CPU utilization percentage | `""` | | `autoscaling.targetMemory` | Target Memory utilization percentage | `""` | +| `autoscaling.behavior` | HPA behavior | `{}` | | `nodeAffinityPreset.type` | Node affinity preset type. Ignored if `affinity` is set. Allowed values: `soft` or `hard` | `""` | | `nodeAffinityPreset.key` | Node label key to match. Ignored if `affinity` is set | `""` | | `nodeAffinityPreset.values` | Node label values to match. Ignored if `affinity` is set | `[]` | | `affinity` | Affinity for pods assignment | `{}` | | `nodeSelector` | Node labels for pods assignment | `{}` | | `tolerations` | Tolerations for pods assignment | `[]` | -| `updateStrategy.type` | statefulset strategy type | `RollingUpdate` | +| `updateStrategy.type` | deployment strategy type | `RollingUpdate` | | `dnsPolicy` | Set DNS policy for the pod. Defaults to "ClusterFirst". | `nil` | | `hostNetwork` | Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false. | `nil` | +| `automountServiceAccountToken` | Automount service account token for the pod. Defaults to "true" | `nil` | | `podManagementPolicy` | Statefulset Pod management policy, it needs to be Parallel to be able to complete the cluster join | `OrderedReady` | | `priorityClassName` | pods' priorityClassName | `""` | | `topologySpreadConstraints` | Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template | `[]` | @@ -430,7 +433,6 @@ containers: | `sidecars` | Add additional sidecar containers to the pod(s) | `[]` | | `extraInitContainers` | Add additional init containers to the pod(s) (go after .initContainers) | `[]` | - ### Traffic Exposure Parameters | Name | Description | Value | @@ -442,6 +444,7 @@ containers: | `service.loadBalancerSourceRanges` | service Load Balancer sources | `[]` | | `service.externalTrafficPolicy` | service external traffic policy | `Cluster` | | `service.annotations` | Additional custom annotations for service | `{}` | +| `service.extraSelectors` | Additional custom selectors for pods to match the service | `{}` | | `service.extraPorts` | Extra ports to expose in service (normally used with the `sidecars` value) | `[]` | | `service.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` | | `service.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` | @@ -465,12 +468,12 @@ containers: | `ingress.secrets` | Custom TLS certificates as secrets | `[]` | | `ingress.extraRules` | Additional rules to be covered with this ingress record | `[]` | - ### Persistence Parameters | Name | Description | Value | | --------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------- | | `persistence.enabled` | Enable persistence using Persistent Volume Claims | `false` | +| `persistence.type` | Create separate PVC when set to "pvc", or from volumeClaimTemplates if set to "sts" | `pvc` | | `persistence.emptyDir` | Enable emptyDir persistence instead of a PVC | `false` | | `persistence.mountName` | Persistent volume name | `data` | | `persistence.mountPath` | Path to mount the volume at | `/data` | @@ -483,7 +486,6 @@ containers: | `persistence.selector` | Selector to match an existing Persistent Volume for WordPress data PVC | `{}` | | `persistence.dataSource` | Custom PVC data source | `{}` | - ### Init Container Parameters | Name | Description | Value | @@ -498,11 +500,11 @@ containers: | `volumePermissions.resources.requests` | The requested resources for the init container | `{}` | | `volumePermissions.containerSecurityContext.runAsUser` | Set init container's Security Context runAsUser | `0` | - ### Other Parameters | Name | Description | Value | | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------- | +| `minReadySeconds` | minimum seconds for pod to become ready. 0 is the default k8s value | `0` | | `rbac.create` | Specifies whether RBAC resources should be created | `false` | | `rbac.rules` | Custom RBAC rules to set | `[]` | | `serviceAccount.create` | Specifies whether a ServiceAccount should be created | `true` | diff --git a/dysnix/app/templates/_resources.tpl b/dysnix/app/templates/_resources.tpl index 963b2b0b..38fdfba6 100644 --- a/dysnix/app/templates/_resources.tpl +++ b/dysnix/app/templates/_resources.tpl @@ -52,6 +52,10 @@ Usage {{- include "app.resources.include" (dict "resource" "deployment" | merge .) -}} {{- end -}} +{{- define "app.statefulset" -}} + {{- include "app.resources.include" (dict "resource" "statefulset" | merge .) -}} +{{- end -}} + {{- define "app.service-account" -}} {{- include "app.resources.include" (dict "resource" "service-account" | merge .) -}} {{- end -}} diff --git a/dysnix/app/templates/deployment.yaml b/dysnix/app/templates/deployment.yaml index b2776692..78dff8b5 100644 --- a/dysnix/app/templates/deployment.yaml +++ b/dysnix/app/templates/deployment.yaml @@ -46,6 +46,9 @@ spec: {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }} {{- end }} spec: + {{- with .Values.enableServiceLinks }} + enableServiceLinks: {{ . }} + {{- end }} serviceAccountName: {{ template "app.serviceAccountName" . }} {{- if kindIs "bool" .Values.automountServiceAccountToken }} automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} diff --git a/dysnix/app/templates/pvc.yaml b/dysnix/app/templates/pvc.yaml index b270028e..f428aa26 100644 --- a/dysnix/app/templates/pvc.yaml +++ b/dysnix/app/templates/pvc.yaml @@ -1,6 +1,6 @@ {{/* vim: set filetype=helm: */}} {{- define "app.resources.pvc" -}} -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) (not (has .Values.persistence.type (list "sts" "statefulset"))) }} --- apiVersion: v1 kind: PersistentVolumeClaim diff --git a/dysnix/app/templates/statefulset.yaml b/dysnix/app/templates/statefulset.yaml new file mode 100644 index 00000000..27aea636 --- /dev/null +++ b/dysnix/app/templates/statefulset.yaml @@ -0,0 +1,266 @@ +{{/* vim: set filetype=helm: */}} + +{{- define "app.resources.statefulset" -}} +{{- if and .Values.app.workload.enabled (has .Values.app.workload.type (list "statefulset" "sts")) }} +--- +apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} +kind: StatefulSet +metadata: + name: {{ template "common.names.fullname" . }} + namespace: {{ include "common.names.namespace" . | quote }} + labels: + {{- include "common.labels.standard" . | nindent 4 }} + {{- include "app.labels.component" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + serviceName: {{ template "common.names.fullname" . }} + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + {{- if .Values.updateStrategy }} + updateStrategy: {{- toYaml .Values.updateStrategy | nindent 4 }} + {{- end }} + minReadySeconds: {{ .Values.minReadySeconds }} + podManagementPolicy: {{ .Values.podManagementPolicy }} + {{- with .Values.persistentVolumeClaimRetentionPolicy }} + persistentVolumeClaimRetentionPolicy: {{- toYaml . | nindent 4 }} + {{- end }} + selector: + matchLabels: + {{- include "common.labels.matchLabels" . | nindent 6 }} + {{- include "app.labels.component" . | nindent 6 }} + template: + metadata: + annotations: + {{- include "app.template.checksums" $ | indent 8 }} + {{- if .Values.podAnnotations }} + {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }} + {{- end }} + labels: + {{- include "common.labels.standard" . | nindent 8 }} + {{- include "app.labels.component" . | nindent 8 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} + {{- end }} + {{- if .Values.podLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }} + {{- end }} + spec: + {{- with .Values.enableServiceLinks }} + enableServiceLinks: {{ . }} + {{- end }} + serviceAccountName: {{ template "app.serviceAccountName" . }} + {{- if kindIs "bool" .Values.automountServiceAccountToken }} + automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} + {{- end }} + {{- include "app.imagePullSecrets" . | nindent 6 }} + {{- if .Values.hostAliases }} + hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }} + {{- end }} + {{- if kindIs "bool" .Values.hostNetwork }} + hostNetwork: {{ .Values.hostNetwork }} + {{- end }} + {{- if .Values.dnsPolicy }} + dnsPolicy: {{ .Values.dnsPolicy }} + {{- end }} + {{- if .Values.affinity }} + affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }} + {{- else }} + affinity: + podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" ._include.component "context" $) | nindent 10 }} + podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" ._include.component "context" $) | nindent 10 }} + nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }} + {{- end }} + {{- if .Values.nodeSelector }} + nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.nodeSelector "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName | quote }} + {{- end }} + {{- if .Values.schedulerName }} + schedulerName: {{ .Values.schedulerName | quote }} + {{- end }} + {{- if .Values.topologySpreadConstraints }} + topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.podSecurityContext.enabled }} + securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + {{- if .Values.terminationGracePeriodSeconds }} + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + {{- end }} + initContainers: + {{- if and .Values.volumePermissions .Values.persistence .Values.volumePermissions.command .Values.persistence.enabled }} + - name: volume-permissions + image: {{ include "app.volumePermissions.image" .Values }} + imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.volumePermissions.command "context" $) | nindent 12 -}} + securityContext: {{- include "common.tplvalues.render" . | nindent 12 }} + {{- if .Values.volumePermissions.resources }} + resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }} + {{- end }} + volumeMounts: + {{- if .Values.persistence.enabled }} + - name: {{ .Values.persistence.mountName }} + mountPath: {{ .Values.persistence.mountPath }} + {{- if .Values.persistence.subPath }} + subPath: {{ .Values.persistence.subPath }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.initContainers -}} + {{/* Use extendeded .Values.initContainers (use, values map) */}} + {{- include "app.containers" (dict "initContainers" true "values" .Values.initContainers "top" $) | nindent 8 }} + {{- end }} + {{- if .Values.extraInitContainers }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraInitContainers "context" $) | nindent 8 }} + {{- end }} + containers: + - name: {{ .Values.app.name }} + image: {{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} + {{- else if .Values.command }} + command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.diagnosticMode.enabled }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} + {{- else if .Values.args }} + args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} + {{- end }} + env: + {{- with .Values.env }} + {{- include "app.tplvalues.named-list" (dict "valueKey" "value" "value" . "toString" true "context" $) | nindent 12 -}} + {{- end }} + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} + {{- end }} + envFrom: + {{- with .Values.envFrom }} + {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.extraEnvVarsCM }} + - configMapRef: + name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }} + {{- end }} + {{- if .Values.extraEnvVarsSecret }} + - secretRef: + name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }} + {{- end }} + {{- if .Values.resources }} + resources: {{- toYaml .Values.resources | nindent 12 }} + {{- end }} + {{- with include "app.tplvalues.named-list" ( dict "value" .Values.containerPorts "valueKey" "containerPort" "context" $) }} + ports: {{ . | nindent 12 }} + {{- end }} + {{- if not .Values.diagnosticMode.enabled }} + {{- if .Values.customLivenessProbe }} + livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} + {{- else if .Values.livenessProbe.enabled }} + livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.customReadinessProbe }} + readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} + {{- else if .Values.readinessProbe.enabled }} + readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.customStartupProbe }} + startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} + {{- else if .Values.startupProbe.enabled }} + startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }} + {{- end }} + {{- end }} + {{- if .Values.lifecycleHooks }} + lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} + {{- end }} + volumeMounts: + {{- if .Values.persistence.enabled }} + - name: {{ .Values.persistence.mountName }} + mountPath: {{ .Values.persistence.mountPath }} + {{- if .Values.persistence.subPath }} + subPath: {{ .Values.persistence.subPath }} + {{- end }} + {{- end }} + {{- with .Values.volumeMounts }} + {{- include "app.tplvalues.named-list" (dict "value" . "context" $) | nindent 12 -}} + {{- end }} + {{- if .Values.extraVolumeMounts }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} + {{- end }} + {{- if .Values.containers }} + {{/* Use extendeded .Values.app.containers (use, values map) */}} + {{- include "app.containers" (dict "values" .Values.containers "top" $) | nindent 8 }} + {{- end }} + {{- if .Values.sidecars }} + {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }} + {{- end }} + volumes: + {{- if and .Values.persistence.enabled (or (eq .Values.persistence.type "pvc") .Values.persistence.emptyDir) }} + - name: {{ .Values.persistence.mountName }} + {{- if .Values.persistence.emptyDir }} + emptyDir: {} + {{- else }} + persistentVolumeClaim: + claimName: {{ default (include "common.names.fullname" $) .Values.persistence.existingClaim }} + {{- end }} + {{- end }} + {{- with .Values.volumes }} + {{- include "app.tplvalues.named-list" (dict "value" . "context" $) | nindent 8 -}} + {{- end }} + {{- if .Values.extraVolumes }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }} + {{- end }} + {{- if and .Values.persistence.enabled (has .Values.persistence.type (list "sts" "statefulset")) }} + volumeClaimTemplates: + - metadata: + name: {{ .Values.persistence.mountName }} + labels: + {{- include "common.labels.matchLabels" . | nindent 8 }} + {{- include "app.labels.component" . | nindent 8 }} + {{- if or .Values.persistence.annotations .Values.commonAnnotations }} + annotations: + {{- if .Values.persistence.annotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.persistence.annotations "context" $ ) | nindent 8 }} + {{- end }} + {{- if .Values.commonAnnotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 8 }} + {{- end }} + {{- end }} + spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- if .Values.persistence.selector }} + selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.persistence.dataSource }} + dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.dataSource "context" $) | nindent 8 }} + {{- end }} + {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 6 }} + {{- end }} +{{- end }} +{{- end -}} + +{{/* Include the resource */}} +{{- if eq "direct" (include "app.chart.mode" .) -}} + {{- range $_, $component := concat (list "") $.Values.app.components -}} + {{- $values := ternary $.Values (get $.Values "component") (eq $component "") | default dict -}} + {{- include "app.statefulset" (dict "component" $component "values" $values "top" $) -}} + {{- end -}} +{{- end -}} diff --git a/dysnix/app/tests/persistence_test.yaml b/dysnix/app/tests/persistence_test.yaml index e5c1eaab..86e58888 100644 --- a/dysnix/app/tests/persistence_test.yaml +++ b/dysnix/app/tests/persistence_test.yaml @@ -2,6 +2,7 @@ suite: persistence templates: - pvc.yaml - deployment.yaml + - statefulset.yaml tests: - it: persistence enabled @@ -88,4 +89,21 @@ tests: isSubset: path: metadata.labels content: - common: label \ No newline at end of file + common: label + - + it: persistence enabled with app.workload.type "sts" and .persistence.type "sts" + values: + - ./values/persistence.yaml + - ./values/app.yaml + set: + app.workload.type: sts + persistence.type: sts + asserts: + - + template: pvc.yaml + hasDocuments: + count: 0 + - + template: statefulset.yaml + isNotEmpty: + path: spec.volumeClaimTemplates[0] diff --git a/dysnix/app/tests/statefulset-common_test.yaml b/dysnix/app/tests/statefulset-common_test.yaml new file mode 100644 index 00000000..3bbe3c2e --- /dev/null +++ b/dysnix/app/tests/statefulset-common_test.yaml @@ -0,0 +1,78 @@ +suite: statefulset +templates: + - statefulset.yaml +tests: + - + it: chart naming + values: + - ./values/common.yaml + set: + app.workload.type: statefulset + asserts: + - isKind: + of: StatefulSet + - equal: + path: metadata.name + value: RELEASE-NAME-app-name + - + it: .namespaceOverride + values: + - ./values/common.yaml + set: + app.workload.type: statefulset + namespaceOverride: foo + asserts: + - isKind: + of: StatefulSet + - equal: + path: metadata.namespace + value: foo + - + it: release name is equal to release+.app.name + values: + - ./values/common.yaml + set: + app.workload.type: statefulset + release: + name: foo + asserts: + - equal: + path: metadata.name + value: foo-app-name + - + it: image naming + values: + - ./values/common.yaml + set: + app.workload.type: statefulset + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: foo/alpine:bar + - + it: selector matchLabels + values: + - ./values/common.yaml + set: + app.workload.type: statefulset + asserts: + - isSubset: + path: spec.selector.matchLabels + content: + tenant: foo + - + it: statefulset labels + values: + - ./values/common.yaml + set: + app.workload.type: statefulset + asserts: + - isSubset: + path: metadata.labels + content: + common: label + - isSubset: + path: spec.template.metadata.labels + content: + common: label + pod: label \ No newline at end of file diff --git a/dysnix/app/values.yaml b/dysnix/app/values.yaml index 131d72ea..e76c47fb 100644 --- a/dysnix/app/values.yaml +++ b/dysnix/app/values.yaml @@ -9,7 +9,7 @@ ## ## @param app.name Specifies the chart/application name (app.kubernetes.io/name), since this is a generic chart ## @param app.workload.enabled Specifies whether the default workload resource is generated (Deployment/StatefulSet etc) -## @param app.workload.type Specifies type of the main workload resource +## @param app.workload.type Specifies type of the main workload resource ("deployment" or "statefulset/sts") ## app: name: app @@ -37,6 +37,14 @@ selector: ## reuse: false +## @param enableServiceLinks Can be disabled to remove information about services from pod's environment variables +## +enableServiceLinks: true + +## @param persistentVolumeClaimRetentionPolicy Describes the lifecycle of PVCs created from volumeClaimTemplates (only "statefulset" workload type) +## +persistentVolumeClaimRetentionPolicy: {} + ## @param containers Specify a map of additional pod containers ## ## e.g. @@ -397,6 +405,7 @@ pdb: ## @param autoscaling.maxReplicas Maximum number of %%MAIN_OBJECT_BLOCK%% replicas ## @param autoscaling.targetCPU Target CPU utilization percentage ## @param autoscaling.targetMemory Target Memory utilization percentage +## @param autoscaling.behavior HPA behavior ## autoscaling: enabled: false @@ -713,6 +722,9 @@ persistence: ## @param persistence.enabled Enable persistence using Persistent Volume Claims ## enabled: false + ## @param persistence.type Create separate PVC when set to "pvc", or from volumeClaimTemplates if set to "sts" + ## + type: pvc ## @param persistence.emptyDir Enable emptyDir persistence instead of a PVC ## emptyDir: false