suite: deployment template (basic) release: name: gitea-unittests namespace: testing templates: - templates/deployment.yaml - templates/secret_admin.yaml - templates/secret_config.yaml - templates/secret_gpg.yaml - templates/secret_init.yaml - templates/secret_inlineConfig.yaml - templates/secret_metrics.yaml tests: - it: "Render a Deployment" template: templates/deployment.yaml asserts: - hasDocuments: count: 1 - containsDocument: kind: Deployment apiVersion: apps/v1 name: gitea-unittests - it: "Skip rendering when the Deployment is disabled" template: templates/deployment.yaml set: deployment.enabled: false asserts: - hasDocuments: count: 0 - it: "Render the configured Deployment labels" template: templates/deployment.yaml set: deployment.labels: hello: world asserts: - isSubset: path: metadata.labels content: hello: world - isSubset: path: spec.template.metadata.labels content: hello: world - isNotSubset: path: spec.selector.matchLabels content: hello: world - it: "Omit the Deployment labels from the selector matchLabels" template: templates/deployment.yaml set: deployment.labels: custom-label: custom-value another-label: another-value asserts: - equal: path: spec.selector.matchLabels value: app.kubernetes.io/name: gitea app.kubernetes.io/instance: gitea-unittests - it: "Render the Deployment labels even when none are configured" template: templates/deployment.yaml asserts: - isSubset: path: metadata.labels content: app: gitea app.kubernetes.io/name: gitea app.kubernetes.io/instance: gitea-unittests app.kubernetes.io/managed-by: Helm - it: "Omit the Deployment annotations when none are configured" template: templates/deployment.yaml asserts: - notExists: path: metadata.annotations - it: "Render the configured Deployment annotations" template: templates/deployment.yaml set: deployment.annotations: hello: world asserts: - equal: path: metadata.annotations value: hello: world - it: "Omit the nodeSelector when none is configured" asserts: - notExists: path: spec.template.spec.nodeSelector template: templates/deployment.yaml - it: "Render the configured nodeSelector" set: deployment.nodeSelector: foo: bar bar: foo asserts: - isSubset: path: spec.template.spec.nodeSelector content: foo: bar bar: foo template: templates/deployment.yaml - it: "Omit the affinity when none is configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.affinity - it: "Render the configured affinity" template: templates/deployment.yaml set: deployment.affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/os operator: In values: - linux asserts: - equal: path: spec.template.spec.affinity value: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/os operator: In values: - linux - it: "Omit the dnsConfig when none is configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.dnsConfig - it: "Render the configured dnsConfig" template: templates/deployment.yaml set: deployment.dnsConfig: nameservers: - 192.0.2.1 options: - name: ndots value: "2" asserts: - equal: path: spec.template.spec.dnsConfig value: nameservers: - 192.0.2.1 options: - name: ndots value: "2" - it: "Omit the priorityClassName when none is configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.priorityClassName - it: "Render the configured priorityClassName" template: templates/deployment.yaml set: deployment.priorityClassName: high-priority asserts: - equal: path: spec.template.spec.priorityClassName value: high-priority - it: "Omit the schedulerName when none is configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.schedulerName - it: "Render the configured schedulerName" template: templates/deployment.yaml set: deployment.schedulerName: stork asserts: - equal: path: spec.template.spec.schedulerName value: stork - it: "Default the strategy to a rolling update" template: templates/deployment.yaml asserts: - equal: path: spec.strategy value: type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 100% - it: "Omit rollingUpdate for other strategy types" template: templates/deployment.yaml set: deployment.strategy.type: Recreate asserts: - equal: path: spec.strategy value: type: Recreate - it: "Omit the tolerations when none are configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.tolerations - it: "Render the configured tolerations" template: templates/deployment.yaml set: deployment.tolerations: - key: database/type operator: Equal value: postgres effect: NoSchedule asserts: - equal: path: spec.template.spec.tolerations value: - key: database/type operator: Equal value: postgres effect: NoSchedule - it: "Omit the topologySpreadConstraints when none are configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.topologySpreadConstraints - it: "Render the configured topologySpreadConstraints" template: templates/deployment.yaml set: deployment.topologySpreadConstraints: - topologyKey: kubernetes.io/hostname whenUnsatisfiable: DoNotSchedule maxSkew: 1 labelSelector: matchLabels: app.kubernetes.io/instance: gitea-unittests asserts: - equal: path: spec.template.spec.topologySpreadConstraints value: - topologyKey: kubernetes.io/hostname whenUnsatisfiable: DoNotSchedule maxSkew: 1 labelSelector: matchLabels: app.kubernetes.io/instance: gitea-unittests - it: "Inject TMP_EXISTING_ENVS_FILE into the 'init-app-ini' init container" template: templates/deployment.yaml asserts: - contains: path: spec.template.spec.initContainers[1].env content: name: TMP_EXISTING_ENVS_FILE value: /tmp/existing-envs - it: "Inject ENV_TO_INI_MOUNT_POINT into the 'init-app-ini' init container" template: templates/deployment.yaml asserts: - contains: path: spec.template.spec.initContainers[1].env content: name: ENV_TO_INI_MOUNT_POINT value: /env-to-ini-mounts - it: "Inject deployment.gitea.env into all init containers and the gitea container" template: templates/deployment.yaml set: deployment.gitea.env: - name: VARIABLE value: my-value asserts: - contains: path: spec.template.spec.initContainers[0].env content: name: VARIABLE value: my-value - contains: path: spec.template.spec.initContainers[1].env content: name: VARIABLE value: my-value - contains: path: spec.template.spec.initContainers[2].env content: name: VARIABLE value: my-value - contains: path: spec.template.spec.containers[0].env content: name: VARIABLE value: my-value - it: "Render GOMAXPROCS when the CPU resources are defined" template: templates/deployment.yaml set: deployment.gitea.resources: limits: cpu: 200ms memory: 200Mi requests: cpu: 100ms memory: 100Mi asserts: - contains: path: spec.template.spec.containers[0].env content: name: GOMAXPROCS valueFrom: resourceFieldRef: divisor: "1" resource: limits.cpu - equal: path: spec.template.spec.containers[0].resources value: limits: cpu: 200ms memory: 200Mi requests: cpu: 100ms memory: 100Mi - it: "Default the container resources to an empty map and omit GOMAXPROCS" template: templates/deployment.yaml asserts: - equal: path: spec.template.spec.containers[0].resources value: {} - notContains: path: spec.template.spec.containers[0].env content: name: GOMAXPROCS valueFrom: resourceFieldRef: divisor: "1" resource: limits.cpu - it: "Omit the pod level resources when none are configured" template: templates/deployment.yaml asserts: - notExists: path: spec.template.spec.resources - it: "Render the configured pod level resources" template: templates/deployment.yaml set: deployment.resources: limits: cpu: 500m memory: 512Mi requests: cpu: 250m memory: 256Mi asserts: - equal: path: spec.template.spec.resources value: limits: cpu: 500m memory: 512Mi requests: cpu: 250m memory: 256Mi - it: "Render the configured volumeMount path of the init containers" template: templates/deployment.yaml set: initContainersScriptsVolumeMountPath: "/custom/init/path" asserts: - equal: path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath value: "/custom/init/path" - equal: path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath value: "/custom/init/path" - it: "Render the default volumeMount path of the init containers" template: templates/deployment.yaml asserts: - equal: path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath value: "/usr/sbinx" - equal: path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath value: "/usr/sbinx"