Skip to content

Volumes

Definition

# application workload volumes
volumes:
  volume1:
    mounts: 
      application: /some-data
      jsreport: /some-another-data-but-same-as-for-application

cronjobs:
  cleanup:
    spec:
      schedule: 0 6 * * *
      jobTemplate:
        spec:
          template:
            metadata:
              labels:
                custom-label: "custom label"
              annotations:
                custom-annotation: "custom annotation"
    # cronjob containers
    containers:
      main: 
        spec:
          args: 
            - "tag" 
            - "delete"
            - "--registry"
    # cronjob init containers
    initContainers:
      "cleanup-init":
        image: 
          repository: cicd-sample/cleanup-init
          version: 1.0.0     
    # cronjob volumes
    volumes:
      volume2:
        spec:
          emptyDir:
            sizeLimit: 300Mi            
        mounts: 
          main: /some-data
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations: {}
  labels:
    app.kubernetes.io/component: cicd-sample
    app.kubernetes.io/instance: docs
    app.kubernetes.io/managed-by: helm
    app.kubernetes.io/name: cicd-sample
    app.kubernetes.io/part-of: cicd
    app.kubernetes.io/version: 1.0.0
    exordis/application: cicd-sample
    exordis/application-instance: docs
    exordis/application-type: service
    exordis/application-workload: "true"
    exordis/environment: test
    exordis/product: Some Product
    exordis/subsystem: cicd
    helm.sh/chart: cicd-subsystem-application-0.1.0
  name: cicd-sample-docs
  namespace: cicd-test
spec:
  replicas: 3
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      exordis/application: cicd-sample
      exordis/application-instance: docs
      exordis/application-workload: "true"
      exordis/environment: test
      exordis/subsystem: cicd
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        checksum/configMap.config-map-with-containers: 48b7e320feb03b105aa89ed415344c030af90d34a34c66f56146d9f0fd2da3e3
        checksum/configMap.config-map-without-containers: 1dbfa263d171e565d412b904c69bdf60fc6bc8db2fcb31e13049242a8bbdecac
        checksum/configMap.envs: 7804c1a2bc6fb98bc7b87c036f6bdb678f897e534204c2e4efd7d881bf5b2924
        checksum/configMap.external-secret-template: f921d5d8c41b9909941321f0d31975eb7ca6d83cba279a6fa91b5f035c9c3f56
        checksum/secret.secret-with-containers: 8e0836f50407f40dc36bf200910416c00f82b8bf5284ab96e908b1d709eb65e3
        checksum/secret.secret-without-containers: 2e931d517cebd760f5460ea95663a82d8df2673e2c075918c21b33c96bfd6686
        custom-annotation: custom annotation
      labels:
        app.kubernetes.io/component: cicd-sample
        app.kubernetes.io/instance: docs
        app.kubernetes.io/managed-by: helm
        app.kubernetes.io/name: cicd-sample
        app.kubernetes.io/part-of: cicd
        app.kubernetes.io/version: 1.0.0
        custom-label: custom label
        exordis/application: cicd-sample
        exordis/application-instance: docs
        exordis/application-type: service
        exordis/application-workload: "true"
        exordis/environment: test
        exordis/product: Some Product
        exordis/subsystem: cicd
        helm.sh/chart: cicd-subsystem-application-0.1.0
    spec:
      containers:
        - envFrom:
            - secretRef:
                name: cicd-sample-docs-external-full
            - secretRef:
                name: cicd-sample-docs-secret-without-containers
            - secretRef:
                name: cicd-sample-docs-secret-with-containers
            - configMapRef:
                name: cicd-sample-docs-envs
            - configMapRef:
                name: cicd-sample-docs-config-map-without-containers
            - configMapRef:
                name: cicd-sample-docs-config-map-with-containers
          image: registry.gitlab.com/cicd-unittests:1.0.0
          imagePullPolicy: IfNotPresent
          livenessProbe:
            failureThreshold: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 80
            timeoutSeconds: 1
          name: application
          ports:
            - containerPort: 80
              name: http
              protocol: TCP
          readinessProbe:
            failureThreshold: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 80
            timeoutSeconds: 1
          resources:
            limits:
              cpu: 200m
              memory: 256Mi
            requests:
              cpu: 50m
              memory: 64Mi
          startupProbe:
            failureThreshold: 30
            periodSeconds: 5
            successThreshold: 1
            tcpSocket:
              port: 80
            timeoutSeconds: 1
          volumeMounts:
            - mountPath: /some-data
              name: volume1
            - mountPath: /pvc-data
              name: mypvc
        - envFrom:
            - secretRef:
                name: cicd-sample-docs-external-full
            - secretRef:
                name: cicd-sample-docs-secret-without-containers
            - configMapRef:
                name: cicd-sample-docs-envs
            - configMapRef:
                name: cicd-sample-docs-config-map-without-containers
          image: docker.io/jsreport/jsreport:4.7.0
          imagePullPolicy: IfNotPresent
          name: jsreport
          resources:
            limits:
              cpu: 200m
              memory: 256Mi
            requests:
              cpu: 50m
              memory: 64Mi
          volumeMounts:
            - mountPath: /some-another-data-but-same-as-for-application
              name: volume1
      initContainers:
        - envFrom:
            - secretRef:
                name: cicd-sample-docs-external-full
            - secretRef:
                name: cicd-sample-docs-secret-without-containers
            - configMapRef:
                name: cicd-sample-docs-envs
            - configMapRef:
                name: cicd-sample-docs-config-map-without-containers
          image: registry.gitlab.com/my-migration-image:1.0.0
          imagePullPolicy: Always
          name: migration
          resources:
            limits:
              cpu: 200m
              memory: 256Mi
            requests:
              cpu: 50m
              memory: 64Mi
          volumeMounts: []
      serviceAccountName: cicd-sample-docs-workload
      terminationGracePeriodSeconds: 60
      volumes:
        - name: mypvc
          persistentVolumeClaim:
            claimName: cicd-sample-docs-mypvc
        - emptyDir:
            sizeLimit: 100Mi
          name: volume1
apiVersion: batch/v1
kind: CronJob
metadata:
  annotations: {}
  labels:
    app.kubernetes.io/component: cicd-sample
    app.kubernetes.io/instance: docs
    app.kubernetes.io/managed-by: helm
    app.kubernetes.io/name: cicd-sample
    app.kubernetes.io/part-of: cicd
    app.kubernetes.io/version: 1.0.0
    exordis/application: cicd-sample
    exordis/application-instance: docs
    exordis/application-type: service
    exordis/environment: test
    exordis/product: Some Product
    exordis/subsystem: cicd
    helm.sh/chart: cicd-subsystem-application-0.1.0
  name: cicd-sample-docs-cleanup
  namespace: cicd-test
spec:
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            custom-annotation: custom annotation
          labels:
            app.kubernetes.io/component: cicd-sample
            app.kubernetes.io/instance: docs
            app.kubernetes.io/managed-by: helm
            app.kubernetes.io/name: cicd-sample
            app.kubernetes.io/part-of: cicd
            app.kubernetes.io/version: 1.0.0
            custom-label: custom label
            exordis/application: cicd-sample
            exordis/application-instance: docs
            exordis/application-type: service
            exordis/environment: test
            exordis/product: Some Product
            exordis/subsystem: cicd
            helm.sh/chart: cicd-subsystem-application-0.1.0
        spec:
          containers:
            - args:
                - tag
                - delete
                - --registry
              envFrom:
                - secretRef:
                    name: cicd-sample-docs-external-full
                - secretRef:
                    name: cicd-sample-docs-secret-without-containers
                - secretRef:
                    name: cicd-sample-docs-secret-with-containers
                - configMapRef:
                    name: cicd-sample-docs-envs
                - configMapRef:
                    name: cicd-sample-docs-config-map-without-containers
              image: registry.gitlab.com/cicd-unittests:1.0.0
              imagePullPolicy: IfNotPresent
              name: main
              resources:
                limits:
                  cpu: 200m
                  memory: 256Mi
                requests:
                  cpu: 50m
                  memory: 64Mi
              volumeMounts:
                - mountPath: /some-data
                  name: volume2
          initContainers:
            - envFrom:
                - secretRef:
                    name: cicd-sample-docs-external-full
                - secretRef:
                    name: cicd-sample-docs-secret-without-containers
                - configMapRef:
                    name: cicd-sample-docs-envs
                - configMapRef:
                    name: cicd-sample-docs-config-map-without-containers
              image: registry.gitlab.com/cicd-sample/cleanup-init:1.0.0
              imagePullPolicy: IfNotPresent
              name: cleanup-init
              resources:
                limits:
                  cpu: 200m
                  memory: 256Mi
                requests:
                  cpu: 50m
                  memory: 64Mi
              volumeMounts: []
          restartPolicy: Never
          serviceAccountName: default
          volumes:
            - emptyDir:
                sizeLimit: 300Mi
              name: volume2
      ttlSecondsAfterFinished: 86400
  schedule: 0 6 * * *
mounts

Defines list of mounts for containers. Format key - container name, value - mount path

spec

Defines volume spec

default:

if none of pvc configMap secret is defined

emptyDir:
  sizeLimit: 100Mi

pvc

Defines PVC` id to use in spec

  • generates volume of persistentVolumeClaim type if spec is not provided
  • puts PVC name to spec.persistentVolumeClaim.claimName: if claimName is not provided explicitly
configMap

Defines ConfigMap id to use in spec

  • generates volume of configMap type if spec is not provided and pvc is not defined
  • puts ConfigMap name to spec.configMap.name: and projected.sources[?(@.configMap)].name: if any of these is defined in spec without explicit name.
secret

Defines Secret or ExternalSecret id to use in spec

  • generates volume of secret type if spec is not provided and neither pvc nor configMap is defined
  • puts Secret name (target secret name for ExternalSecret) to spec.secret.secretName: and projected.sources[?(@.secret)].secretName: if any of these is defined in spec without explicit secretName

Validations

  • pvc references exiting PVC id and it has same namespace as volume workload
  • configMap references exiting ConfigMap id and it has same namespace as volume workload
  • secret references exiting Secret or ExternalSecret id and it has same namespace as volume workload

Overrides

spec.name

name is generated from id by convention

Manifests Generation

  • Volume is added to workload manifest volumes and volume spec is added to spec.volumeMounts of main workload , if workload is not set to none