---
# Source: zammad/charts/redis/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
automountServiceAccountToken: true
metadata:
  name: zammad-redis
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm

---
# Source: zammad/charts/redis/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: zammad-redis-configuration
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
data:
  redis.conf: |-
    # User-supplied common configuration:
    # Enable AOF https://redis.io/topics/persistence#append-only-file
    appendonly yes
    # Disable RDB persistence, AOF persistence already enabled.
    save ""
    # End of common configuration
  master.conf: |-
    dir /data
    # User-supplied master configuration:
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    # End of master configuration
  replica.conf: |-
    dir /data
    # User-supplied replica configuration:
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    # End of replica configuration

---
# Source: zammad/charts/redis/templates/health-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: zammad-redis-health
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
data:
  ping_readiness_local.sh: |-
    #!/bin/bash

    [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
    [[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
    response=$(
      timeout -s 15 $1 \
      redis-cli \
        -h localhost \
        -p $REDIS_PORT \
        ping
    )
    if [ "$?" -eq "124" ]; then
      echo "Timed out"
      exit 1
    fi
    if [ "$response" != "PONG" ]; then
      echo "$response"
      exit 1
    fi
  ping_liveness_local.sh: |-
    #!/bin/bash

    [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
    [[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
    response=$(
      timeout -s 15 $1 \
      redis-cli \
        -h localhost \
        -p $REDIS_PORT \
        ping
    )
    if [ "$?" -eq "124" ]; then
      echo "Timed out"
      exit 1
    fi
    responseFirstWord=$(echo $response | head -n1 | awk '{print $1;}')
    if [ "$response" != "PONG" ] && [ "$responseFirstWord" != "LOADING" ] && [ "$responseFirstWord" != "MASTERDOWN" ]; then
      echo "$response"
      exit 1
    fi
  ping_readiness_master.sh: |-
    #!/bin/bash

    [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
    [[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
    response=$(
      timeout -s 15 $1 \
      redis-cli \
        -h $REDIS_MASTER_HOST \
        -p $REDIS_MASTER_PORT_NUMBER \
        ping
    )
    if [ "$?" -eq "124" ]; then
      echo "Timed out"
      exit 1
    fi
    if [ "$response" != "PONG" ]; then
      echo "$response"
      exit 1
    fi
  ping_liveness_master.sh: |-
    #!/bin/bash

    [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
    [[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
    response=$(
      timeout -s 15 $1 \
      redis-cli \
        -h $REDIS_MASTER_HOST \
        -p $REDIS_MASTER_PORT_NUMBER \
        ping
    )
    if [ "$?" -eq "124" ]; then
      echo "Timed out"
      exit 1
    fi
    responseFirstWord=$(echo $response | head -n1 | awk '{print $1;}')
    if [ "$response" != "PONG" ] && [ "$responseFirstWord" != "LOADING" ]; then
      echo "$response"
      exit 1
    fi
  ping_readiness_local_and_master.sh: |-
    script_dir="$(dirname "$0")"
    exit_status=0
    "$script_dir/ping_readiness_local.sh" $1 || exit_status=$?
    "$script_dir/ping_readiness_master.sh" $1 || exit_status=$?
    exit $exit_status
  ping_liveness_local_and_master.sh: |-
    script_dir="$(dirname "$0")"
    exit_status=0
    "$script_dir/ping_liveness_local.sh" $1 || exit_status=$?
    "$script_dir/ping_liveness_master.sh" $1 || exit_status=$?
    exit $exit_status

---
# Source: zammad/charts/redis/templates/scripts-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: zammad-redis-scripts
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
data:
  start-master.sh: |
    #!/bin/bash

    [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
    if [[ -f /opt/bitnami/redis/mounted-etc/master.conf ]];then
        cp /opt/bitnami/redis/mounted-etc/master.conf /opt/bitnami/redis/etc/master.conf
    fi
    if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
        cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
    fi
    ARGS=("--port" "${REDIS_PORT}")
    ARGS+=("--requirepass" "${REDIS_PASSWORD}")
    ARGS+=("--masterauth" "${REDIS_PASSWORD}")
    ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
    ARGS+=("--include" "/opt/bitnami/redis/etc/master.conf")
    exec redis-server "${ARGS[@]}"

---
# Source: zammad/templates/configmap-init.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: zammad-init
  labels:
    helm.sh/chart: zammad-10.2.1
    app.kubernetes.io/name: zammad
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/version: "6.2.0-1"
    app.kubernetes.io/managed-by: Helm
data:
  postgresql-init: |-
    #!/bin/bash
    set -e
    if ! (bundle exec rails r 'puts User.any?' 2> /dev/null | grep -q true); then
        bundle exec rake db:migrate
        bundle exec rake db:seed
    else
        echo Executing migrations...
        bundle exec rake db:migrate

        echo Synchronizing locales...
        bundle exec rails r "Locale.sync"

        echo Synchronizing translations...
        bundle exec rails r "Translation.sync"
    fi
    echo "postgresql init complete :)"
  zammad-init: |-
    #!/bin/bash
    set -e
    if [ -n "${AUTOWIZARD_JSON}" ]; then
        echo "${AUTOWIZARD_JSON}" | base64 -d > /opt/zammad/var/auto_wizard.json
    fi
    echo "zammad init complete :)"

  elasticsearch-init: |-
    #!/bin/bash
    set -e
    bundle exec rails r 'Setting.set("es_url", "http://zammad-elasticsearch:9200")'
    ELASTICSEARCH_USER=${ELASTICSEARCH_USER:-}
    if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASSWORD}" ]; then
        bundle exec rails r "Setting.set(\"es_user\", \"${ELASTICSEARCH_USER}\")"
        bundle exec rails r "Setting.set(\"es_password\", \"${ELASTICSEARCH_PASSWORD}\")"
    fi
    bundle exec rake zammad:searchindex:rebuild
    
    echo "elasticsearch init complete :)"

---
# Source: zammad/templates/configmap-nginx.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: zammad-nginx
  labels:
    helm.sh/chart: zammad-10.2.1
    app.kubernetes.io/name: zammad
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/version: "6.2.0-1"
    app.kubernetes.io/managed-by: Helm
data:
  default: |-
    #
    # kubernetes nginx config for zammad
    #

    server_tokens off;

    upstream zammad-railsserver {
        server localhost:3000;
    }

    upstream zammad-websocket {
        server localhost:6042;
    }

    server {
        listen 8080;

        server_name _;

        root /opt/zammad/public;

        client_body_temp_path /tmp 1 2;
        fastcgi_temp_path /tmp 1 2;
        proxy_temp_path /tmp 1 2;
        scgi_temp_path /tmp 1 2;
        uwsgi_temp_path /tmp 1 2;

        access_log /dev/stdout;
        error_log  /dev/stderr;

        client_max_body_size 50M;
        

        location ~ ^/(assets/|robots.txt|humans.txt|favicon.ico) {
            expires max;
        }

        location /ws {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header CLIENT_IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 86400;
            proxy_pass http://zammad-websocket;
        }

        location /cable {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header CLIENT_IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 86400;
            proxy_pass http://zammad-railsserver;
        }

        location / {
            proxy_set_header Host $http_host;
            proxy_set_header CLIENT_IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 180;
            proxy_pass http://zammad-railsserver;

            gzip on;
            gzip_types text/plain text/xml text/css image/svg+xml application/javascript application/x-javascript application/json application/xml;
            gzip_proxied any;
        }
    }
  nginx.conf: |-
    worker_processes auto;
    
    pid /tmp/nginx.pid;
    
    include /etc/nginx/modules-enabled/*.conf;

    events {
        worker_connections 768;
    }

    http {
        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;

        access_log /dev/stdout;
        error_log /dev/stdout;

        gzip on;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    }

---
# Source: zammad/charts/elasticsearch/templates/master/svc-headless.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-elasticsearch-master-hl
  namespace: "zammad"
  labels: 
    app.kubernetes.io/name: elasticsearch
    helm.sh/chart: elasticsearch-19.10.3
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: master
spec:
  type: ClusterIP
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
    - name: tcp-rest-api
      port: 9200
      targetPort: rest-api
    - name: tcp-transport
      port: 9300
      targetPort: transport
  selector:
    app.kubernetes.io/name: elasticsearch
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: master

---
# Source: zammad/charts/elasticsearch/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-elasticsearch
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: elasticsearch
    helm.sh/chart: elasticsearch-19.10.3
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: master
  annotations:
spec:
  type: ClusterIP
  sessionAffinity: None
  ports:
    - name: tcp-rest-api
      port: 9200
      targetPort: rest-api
      nodePort: null
    - name: tcp-transport
      port: 9300
      nodePort: null
  selector:
    app.kubernetes.io/name: elasticsearch
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: master

---
# Source: zammad/charts/memcached/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-memcached
  namespace: zammad
  labels:
    app.kubernetes.io/name: memcached
    helm.sh/chart: memcached-6.5.4
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
  annotations:
spec:
  type: ClusterIP
  sessionAffinity: None
  ports:
    - name: memcache
      port: 11211
      targetPort: memcache
      nodePort: null
  selector:
    app.kubernetes.io/name: memcached
    app.kubernetes.io/instance: zammad

---
# Source: zammad/charts/postgresql/templates/primary/svc-headless.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-postgresql-hl
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: postgresql
    helm.sh/chart: postgresql-12.6.4
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: primary
    # Use this annotation in addition to the actual publishNotReadyAddresses
    # field below because the annotation will stop being respected soon but the
    # field is broken in some versions of Kubernetes:
    # https://github.com/kubernetes/kubernetes/issues/58662
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
  type: ClusterIP
  clusterIP: None
  # We want all pods in the StatefulSet to have their addresses published for
  # the sake of the other Postgresql pods even before they're ready, since they
  # have to be able to talk to each other in order to become ready.
  publishNotReadyAddresses: true
  ports:
    - name: tcp-postgresql
      port: 5432
      targetPort: tcp-postgresql
  selector:
    app.kubernetes.io/name: postgresql
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: primary

---
# Source: zammad/charts/postgresql/templates/primary/svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-postgresql
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: postgresql
    helm.sh/chart: postgresql-12.6.4
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: primary
spec:
  type: ClusterIP
  sessionAffinity: None
  ports:
    - name: tcp-postgresql
      port: 5432
      targetPort: tcp-postgresql
      nodePort: null
  selector:
    app.kubernetes.io/name: postgresql
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: primary

---
# Source: zammad/charts/redis/templates/headless-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-redis-headless
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
  annotations:
    
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: tcp-redis
      port: 6379
      targetPort: redis
  selector:
    app.kubernetes.io/name: redis
    app.kubernetes.io/instance: zammad

---
# Source: zammad/charts/redis/templates/master/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad-redis-master
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: master
spec:
  type: ClusterIP
  internalTrafficPolicy: Cluster
  sessionAffinity: None
  ports:
    - name: tcp-redis
      port: 6379
      targetPort: redis
      nodePort: null
  selector:
    app.kubernetes.io/name: redis
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: master

---
# Source: zammad/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: zammad
  labels:
    helm.sh/chart: zammad-10.2.1
    app.kubernetes.io/name: zammad
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/version: "6.2.0-1"
    app.kubernetes.io/managed-by: Helm
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: zammad
    app.kubernetes.io/instance: zammad

---
# Source: zammad/storage-longhorn-adoption
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: zammad-elasticsearch-data-longhorn
  namespace: zammad
  labels:
    app.kubernetes.io/name: elasticsearch
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: master
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 8Gi

---
# Source: zammad/storage-longhorn-adoption
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: zammad-postgresql-data-longhorn
  namespace: zammad
  labels:
    app.kubernetes.io/name: postgresql
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: primary
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 8Gi

---
# Source: zammad/storage-longhorn-adoption
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: zammad-redis-data-longhorn
  namespace: zammad
  labels:
    app.kubernetes.io/name: redis
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/component: master
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 8Gi

---
# Source: zammad/storage-longhorn-adoption
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: zammad-var-longhorn
  namespace: zammad
  labels:
    app.kubernetes.io/name: zammad
    app.kubernetes.io/instance: zammad
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 5Gi

---
# Source: zammad/charts/memcached/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: zammad-memcached
  namespace: zammad
  labels:
    app.kubernetes.io/name: memcached
    helm.sh/chart: memcached-6.5.4
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: memcached
      app.kubernetes.io/instance: zammad
  replicas: 1
  strategy:
    rollingUpdate: {}
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: memcached
        helm.sh/chart: memcached-6.5.4
        app.kubernetes.io/instance: zammad
        app.kubernetes.io/managed-by: Helm
      annotations:
    spec:
      nodeSelector:
        kubernetes.io/hostname: mbrkanov-mini-it13

      affinity:
        podAffinity:
          
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: memcached
                    app.kubernetes.io/instance: zammad
                topologyKey: kubernetes.io/hostname
              weight: 1
        nodeAffinity:
          
      securityContext:
        fsGroup: 1001
      serviceAccountName: default
      containers:
        - name: memcached
          image: docker.io/bitnami/memcached:1.6.21-debian-11-r4
          imagePullPolicy: "IfNotPresent"
          securityContext:
            runAsNonRoot: true
            runAsUser: 1001
          env:
            - name: BITNAMI_DEBUG
              value: "false"
            - name: MEMCACHED_PORT_NUMBER
              value: "11211"
          ports:
            - name: memcache
              containerPort: 11211
          livenessProbe:
            failureThreshold: 6
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
            tcpSocket:
              port: memcache
          readinessProbe:
            failureThreshold: 6
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            timeoutSeconds: 3
            tcpSocket:
              port: memcache
          resources:
            limits: {}
            requests:
              cpu: 250m
              memory: 256Mi
          volumeMounts:
            - name: tmp
              mountPath: /tmp
      volumes:
        - name: tmp
          emptyDir: {}

---
# Source: zammad/charts/elasticsearch/templates/master/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zammad-elasticsearch-master
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: elasticsearch
    helm.sh/chart: elasticsearch-19.10.3
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: master
    ## Istio Labels: https://istio.io/docs/ops/deployment/requirements/
    app: master
spec:
  replicas: 1
  podManagementPolicy: Parallel
  selector:
    matchLabels:
      app.kubernetes.io/name: elasticsearch
      app.kubernetes.io/instance: zammad
      app.kubernetes.io/component: master
  serviceName: zammad-elasticsearch-master-hl
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: elasticsearch
        helm.sh/chart: elasticsearch-19.10.3
        app.kubernetes.io/instance: zammad
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: master
        ## Istio Labels: https://istio.io/docs/ops/deployment/requirements/
        app: master
      annotations:
    spec:
      serviceAccountName: default
      nodeSelector:
        kubernetes.io/hostname: mbrkanov-mini-it13

      affinity:
        podAffinity:
          
        podAntiAffinity:
          
        nodeAffinity:
          
      securityContext:
        fsGroup: 1001
      initContainers:
        ## Image that performs the sysctl operation to modify Kernel settings (needed sometimes to avoid boot errors)
        - name: sysctl
          image: docker.io/bitnami/bitnami-shell:11-debian-11-r131
          imagePullPolicy: "IfNotPresent"
          command:
            - /bin/bash
            - -ec
            - |
              CURRENT=`sysctl -n vm.max_map_count`;
              DESIRED="262144";
              if [ "$DESIRED" -gt "$CURRENT" ]; then
                  sysctl -w vm.max_map_count=262144;
              fi;
              CURRENT=`sysctl -n fs.file-max`;
              DESIRED="65536";
              if [ "$DESIRED" -gt "$CURRENT" ]; then
                  sysctl -w fs.file-max=65536;
              fi;
          securityContext:
            privileged: true
            runAsUser: 0
          resources:
            limits: {}
            requests: {}
      containers:
        - name: elasticsearch
          image: docker.io/bitnami/elasticsearch:8.8.2-debian-11-r0
          imagePullPolicy: "IfNotPresent"
          securityContext:
            runAsNonRoot: true
            runAsUser: 1001
          env:
            - name: BITNAMI_DEBUG
              value: "false"
            - name: MY_POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: ELASTICSEARCH_IS_DEDICATED_NODE
              value: "no"
            - name: ELASTICSEARCH_NODE_ROLES
              value: "master"
            - name: ELASTICSEARCH_TRANSPORT_PORT_NUMBER
              value: "9300"
            - name: ELASTICSEARCH_HTTP_PORT_NUMBER
              value: "9200"
            - name: ELASTICSEARCH_CLUSTER_NAME
              value: "zammad"
            - name: ELASTICSEARCH_CLUSTER_HOSTS
              value: "zammad-elasticsearch-master-hl.zammad.svc.cluster.local,"
            - name: ELASTICSEARCH_TOTAL_NODES
              value: "1"
            - name: ELASTICSEARCH_CLUSTER_MASTER_HOSTS
              value: zammad-elasticsearch-master-0 
            - name: ELASTICSEARCH_MINIMUM_MASTER_NODES
              value: "1"
            - name: ELASTICSEARCH_ADVERTISED_HOSTNAME
              value: "$(MY_POD_NAME).zammad-elasticsearch-master-hl.zammad.svc.cluster.local"
            - name: ELASTICSEARCH_HEAP_SIZE
              value: "512m"
          ports:
            - name: rest-api
              containerPort: 9200
            - name: transport
              containerPort: 9300
          livenessProbe:
            failureThreshold: 5
            initialDelaySeconds: 90
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
            exec:
              command:
                - /opt/bitnami/scripts/elasticsearch/healthcheck.sh
          readinessProbe:
            failureThreshold: 5
            initialDelaySeconds: 90
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
            exec:
              command:
                - /opt/bitnami/scripts/elasticsearch/healthcheck.sh
          resources:
            limits: {}
            requests: {}
          volumeMounts:
            - name: data
              mountPath: /bitnami/elasticsearch/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: zammad-elasticsearch-data-longhorn

---
# Source: zammad/charts/postgresql/templates/primary/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zammad-postgresql
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: postgresql
    helm.sh/chart: postgresql-12.6.4
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: primary
spec:
  replicas: 1
  serviceName: zammad-postgresql-hl
  updateStrategy:
    rollingUpdate: {}
    type: RollingUpdate
  selector:
    matchLabels:
      app.kubernetes.io/name: postgresql
      app.kubernetes.io/instance: zammad
      app.kubernetes.io/component: primary
  template:
    metadata:
      name: zammad-postgresql
      labels:
        app.kubernetes.io/name: postgresql
        helm.sh/chart: postgresql-12.6.4
        app.kubernetes.io/instance: zammad
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: primary
    spec:
      serviceAccountName: default
      nodeSelector:
        kubernetes.io/hostname: mbrkanov-mini-it13

      affinity:
        podAffinity:
          
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: postgresql
                    app.kubernetes.io/instance: zammad
                    app.kubernetes.io/component: primary
                topologyKey: kubernetes.io/hostname
              weight: 1
        nodeAffinity:
          
      securityContext:
        fsGroup: 1001
      hostNetwork: false
      hostIPC: false
      containers:
        - name: postgresql
          image: docker.io/bitnami/postgresql:15.3.0-debian-11-r17
          imagePullPolicy: "IfNotPresent"
          securityContext:
            runAsUser: 1001
          env:
            - name: BITNAMI_DEBUG
              value: "false"
            - name: POSTGRESQL_PORT_NUMBER
              value: "5432"
            - name: POSTGRESQL_VOLUME_DIR
              value: "/bitnami/postgresql"
            - name: PGDATA
              value: "/bitnami/postgresql/data"
            # Authentication
            - name: POSTGRES_USER
              value: "zammad"
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql
                  key: password
            - name: POSTGRES_POSTGRES_PASSWORD
              value: zammad
            - name: POSTGRES_DATABASE
              value: "zammad_production"
            # Replication
            # Initdb
            # Standby
            # LDAP
            - name: POSTGRESQL_ENABLE_LDAP
              value: "no"
            # TLS
            - name: POSTGRESQL_ENABLE_TLS
              value: "no"
            # Audit
            - name: POSTGRESQL_LOG_HOSTNAME
              value: "false"
            - name: POSTGRESQL_LOG_CONNECTIONS
              value: "false"
            - name: POSTGRESQL_LOG_DISCONNECTIONS
              value: "false"
            - name: POSTGRESQL_PGAUDIT_LOG_CATALOG
              value: "off"
            # Others
            - name: POSTGRESQL_CLIENT_MIN_MESSAGES
              value: "error"
            - name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
              value: "pgaudit"
          ports:
            - name: tcp-postgresql
              containerPort: 5432
          livenessProbe:
            failureThreshold: 6
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
            exec:
              command:
                - /bin/sh
                - -c
                - exec pg_isready -U "zammad" -d "dbname=zammad_production" -h 127.0.0.1 -p 5432
          readinessProbe:
            failureThreshold: 6
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
            exec:
              command:
                - /bin/sh
                - -c
                - -e
                - |
                  exec pg_isready -U "zammad" -d "dbname=zammad_production" -h 127.0.0.1 -p 5432
                  [ -f /opt/bitnami/postgresql/tmp/.initialized ] || [ -f /bitnami/postgresql/.initialized ]
          resources:
            limits: {}
            requests:
              cpu: 250m
              memory: 256Mi
          volumeMounts:
            - name: dshm
              mountPath: /dev/shm
            - name: data
              mountPath: /bitnami/postgresql
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
        - name: data
          persistentVolumeClaim:
            claimName: zammad-postgresql-data-longhorn
---
# Source: zammad/charts/redis/templates/master/application.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zammad-redis-master
  namespace: "zammad"
  labels:
    app.kubernetes.io/name: redis
    helm.sh/chart: redis-17.11.7
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: master
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: redis
      app.kubernetes.io/instance: zammad
      app.kubernetes.io/component: master
  serviceName: zammad-redis-headless
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: redis
        helm.sh/chart: redis-17.11.7
        app.kubernetes.io/instance: zammad
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: master
      annotations:
        checksum/configmap: 8ee2aaced65441065d6a85b6aac8252391a63d1b93ffc87a4b5af01089292bfc
        checksum/health: 968799a8d5027295a83a30b279de709a6d8b5e273dad5ee137e7d64b290ecb83
        checksum/scripts: 2e17a300e084eb8119434d422c295001f95d7bc382ea4f47792aac596abc40f6
        checksum/secret: f9d770ad02f15ac61b788e0488d6d967f32e5e85019223edc9a0fa4e22a3dba7
    spec:
      nodeSelector:
        kubernetes.io/hostname: mbrkanov-mini-it13

      securityContext:
        fsGroup: 1001
      serviceAccountName: zammad-redis
      automountServiceAccountToken: true
      affinity:
        podAffinity:
          
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: redis
                    app.kubernetes.io/instance: zammad
                    app.kubernetes.io/component: master
                topologyKey: kubernetes.io/hostname
              weight: 1
        nodeAffinity:
          
      terminationGracePeriodSeconds: 30
      containers:
        - name: redis
          image: docker.io/bitnami/redis:7.0.11-debian-11-r20
          imagePullPolicy: "IfNotPresent"
          securityContext:
            runAsUser: 1001
          command:
            - /bin/bash
          args:
            - -c
            - /opt/bitnami/scripts/start-scripts/start-master.sh
          env:
            - name: BITNAMI_DEBUG
              value: "false"
            - name: REDIS_REPLICATION_MODE
              value: master
            - name: ALLOW_EMPTY_PASSWORD
              value: "no"
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis
                  key: redis-password
            - name: REDIS_TLS_ENABLED
              value: "no"
            - name: REDIS_PORT
              value: "6379"
          ports:
            - name: redis
              containerPort: 6379
          livenessProbe:
            initialDelaySeconds: 20
            periodSeconds: 5
            # One second longer than command timeout should prevent generation of zombie processes.
            timeoutSeconds: 6
            successThreshold: 1
            failureThreshold: 5
            exec:
              command:
                - sh
                - -c
                - /health/ping_liveness_local.sh 5
          readinessProbe:
            initialDelaySeconds: 20
            periodSeconds: 5
            timeoutSeconds: 2
            successThreshold: 1
            failureThreshold: 5
            exec:
              command:
                - sh
                - -c
                - /health/ping_readiness_local.sh 1
          resources:
            limits: {}
            requests: {}
          volumeMounts:
            - name: start-scripts
              mountPath: /opt/bitnami/scripts/start-scripts
            - name: health
              mountPath: /health
            - name: redis-data
              mountPath: /data
            - name: config
              mountPath: /opt/bitnami/redis/mounted-etc
            - name: redis-tmp-conf
              mountPath: /opt/bitnami/redis/etc/
            - name: tmp
              mountPath: /tmp
      volumes:
        - name: start-scripts
          configMap:
            name: zammad-redis-scripts
            defaultMode: 0755
        - name: health
          configMap:
            name: zammad-redis-health
            defaultMode: 0755
        - name: config
          configMap:
            name: zammad-redis-configuration
        - name: redis-tmp-conf
          emptyDir: {}
        - name: tmp
          emptyDir: {}
        - name: redis-data
          persistentVolumeClaim:
            claimName: zammad-redis-data-longhorn
---
# Source: zammad/templates/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zammad
  labels:
    helm.sh/chart: zammad-10.2.1
    app.kubernetes.io/name: zammad
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/version: "6.2.0-1"
    app.kubernetes.io/managed-by: Helm
spec:
  replicas: 1
  serviceName: zammad
  selector:
    matchLabels:
      app.kubernetes.io/name: zammad
      app.kubernetes.io/instance: zammad
  template:
    metadata:
      labels:
        helm.sh/chart: zammad-10.2.1
        app.kubernetes.io/name: zammad
        app.kubernetes.io/instance: zammad
        app.kubernetes.io/version: "6.2.0-1"
        app.kubernetes.io/managed-by: Helm
    spec:
      nodeSelector:
        kubernetes.io/hostname: mbrkanov-mini-it13
      initContainers:
        - name: zammad-volume-permissions
          image: "alpine:3.18.4"
          imagePullPolicy: IfNotPresent
          command:
            - /bin/sh
            - -cx
            - |
              chown 1000:1000 -R /opt/zammad/var
              chmod 770 /opt/zammad/tmp
          securityContext:
            capabilities:
              drop:
              - ALL
            privileged: true
            readOnlyRootFilesystem: true
            runAsNonRoot: false
            runAsUser: 0
          volumeMounts:
            - name: zammad-tmp
              mountPath: /opt/zammad/tmp
            - name: zammad-var
              mountPath: /opt/zammad/var
        - name: postgresql-init
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          env:
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis-pass
                  key: redis-password
            - name: MEMCACHE_SERVERS
              value: "zammad-memcached:11211"
            - name: REDIS_URL
              value: "redis://:$(REDIS_PASSWORD)@zammad-redis-master:6379"
            - name: POSTGRESQL_PASS
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql-pass
                  key: postgresql-pass
            - name: DATABASE_URL
              value: "postgres://zammad:$(POSTGRESQL_PASS)@zammad-postgresql:5432/zammad_production"
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: zammad-init
              mountPath: /docker-entrypoint.sh
              readOnly: true
              subPath: postgresql-init
            - name: zammad-tmp
              mountPath: /opt/zammad/tmp
            - name: zammad-var
              mountPath: /opt/zammad/storage
            - name: zammad-var
              mountPath: /opt/zammad/var
        - name: zammad-init
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          env:
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis-pass
                  key: redis-password
            - name: MEMCACHE_SERVERS
              value: "zammad-memcached:11211"
            - name: REDIS_URL
              value: "redis://:$(REDIS_PASSWORD)@zammad-redis-master:6379"
            - name: POSTGRESQL_PASS
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql-pass
                  key: postgresql-pass
            - name: DATABASE_URL
              value: "postgres://zammad:$(POSTGRESQL_PASS)@zammad-postgresql:5432/zammad_production"
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: zammad-init
              mountPath: /docker-entrypoint.sh
              readOnly: true
              subPath: zammad-init
            - name: zammad-tmp
              mountPath: /opt/zammad/tmp
            - name: zammad-var
              mountPath: /opt/zammad/storage
            - name: zammad-var
              mountPath: /opt/zammad/var
        - name: elasticsearch-init
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          env:
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis-pass
                  key: redis-password
            - name: MEMCACHE_SERVERS
              value: "zammad-memcached:11211"
            - name: REDIS_URL
              value: "redis://:$(REDIS_PASSWORD)@zammad-redis-master:6379"
            - name: POSTGRESQL_PASS
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql-pass
                  key: postgresql-pass
            - name: DATABASE_URL
              value: "postgres://zammad:$(POSTGRESQL_PASS)@zammad-postgresql:5432/zammad_production"
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
          - name: zammad-init
            mountPath: /docker-entrypoint.sh
            readOnly: true
            subPath: elasticsearch-init
          - name: zammad-tmp
            mountPath: /opt/zammad/tmp
          - name: zammad-var
            mountPath: /opt/zammad/storage
          - name: zammad-var
            mountPath: /opt/zammad/var
      containers:
        - name: zammad-nginx
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          command:
            - /usr/sbin/nginx
            - -g
            - 'daemon off;'
          env:
          ports:
            - name: http
              containerPort: 8080
          livenessProbe:
            failureThreshold: 5
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 8080
            timeoutSeconds: 5
          readinessProbe:
            failureThreshold: 5
            httpGet:
              path: /
              port: 8080
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: zammad-nginx
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
              readOnly: true
            - name: zammad-nginx
              mountPath: /etc/nginx/sites-enabled/default
              subPath: default
              readOnly: true
            - name: zammad-tmp
              mountPath: /tmp
            - name: zammad-tmp
              mountPath: /var/log/nginx
            - name: zammad-var
              mountPath: /opt/zammad/storage
            - name: zammad-var
              mountPath: /opt/zammad/var
        - name: zammad-railsserver
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          command:
            - "bundle"
            - "exec"
            - "puma"
            - "-b"
            - "tcp://[::]:3000"
            - "-w"
            - "0"
            - "-e"
            - "production"
          env:
            - name: TMP
              value: /opt/zammad/tmp
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis-pass
                  key: redis-password
            - name: MEMCACHE_SERVERS
              value: "zammad-memcached:11211"
            - name: RAILS_TRUSTED_PROXIES
              value: "['127.0.0.1', '::1']"
            - name: REDIS_URL
              value: "redis://:$(REDIS_PASSWORD)@zammad-redis-master:6379"
            - name: POSTGRESQL_PASS
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql-pass
                  key: postgresql-pass
            - name: DATABASE_URL
              value: "postgres://zammad:$(POSTGRESQL_PASS)@zammad-postgresql:5432/zammad_production"
          ports:
            - name: railsserver
              containerPort: 3000
          livenessProbe:
            failureThreshold: 5
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 3000
            timeoutSeconds: 5
          readinessProbe:
            failureThreshold: 5
            httpGet:
              path: /
              port: 3000
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: zammad-tmp
              mountPath: /opt/zammad/tmp
            - name: zammad-var
              mountPath: /opt/zammad/storage
            - name: zammad-var
              mountPath: /opt/zammad/var
        - name: zammad-scheduler
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          command:
            - "bundle"
            - "exec"
            - "script/background-worker.rb"
            - "start"
          env:
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis-pass
                  key: redis-password
            - name: MEMCACHE_SERVERS
              value: "zammad-memcached:11211"
            - name: REDIS_URL
              value: "redis://:$(REDIS_PASSWORD)@zammad-redis-master:6379"
            - name: POSTGRESQL_PASS
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql-pass
                  key: postgresql-pass
            - name: DATABASE_URL
              value: "postgres://zammad:$(POSTGRESQL_PASS)@zammad-postgresql:5432/zammad_production"
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: zammad-tmp
              mountPath: /opt/zammad/tmp
            - name: zammad-var
              mountPath: /opt/zammad/storage
            - name: zammad-var
              mountPath: /opt/zammad/var
        - name: zammad-websocket
          image: "ghcr.io/zammad/zammad:6.2.0-1"
          imagePullPolicy: IfNotPresent
          command:
            - "bundle"
            - "exec"
            - "script/websocket-server.rb"
            - "-b"
            - "0.0.0.0"
            - "-p"
            - "6042"
            - "start"
          env:
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: zammad-redis-pass
                  key: redis-password
            - name: MEMCACHE_SERVERS
              value: "zammad-memcached:11211"
            - name: REDIS_URL
              value: "redis://:$(REDIS_PASSWORD)@zammad-redis-master:6379"
            - name: POSTGRESQL_PASS
              valueFrom:
                secretKeyRef:
                  name: zammad-postgresql-pass
                  key: postgresql-pass
            - name: DATABASE_URL
              value: "postgres://zammad:$(POSTGRESQL_PASS)@zammad-postgresql:5432/zammad_production"
          ports:
            - name: websocket
              containerPort: 6042
          livenessProbe:
            failureThreshold: 10
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 6042
            timeoutSeconds: 5
          readinessProbe:
            failureThreshold: 5
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 6042
            timeoutSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: zammad-tmp
              mountPath: /opt/zammad/tmp
            - name: zammad-var
              mountPath: /opt/zammad/storage
            - name: zammad-var
              mountPath: /opt/zammad/var
      securityContext:
        fsGroup: 1000
        fsGroupChangePolicy: Always
        runAsGroup: 1000
        runAsNonRoot: true
        runAsUser: 1000
        seccompProfile:
          type: RuntimeDefault
      volumes:
        - name: zammad-init
          configMap:
            name: zammad-init
            defaultMode: 0755
        - name: zammad-nginx
          configMap:
            name: zammad-nginx
        - name: zammad-tmp
          emptyDir:
            sizeLimit: 100Mi
        - name: zammad-var
          persistentVolumeClaim:
            claimName: zammad-var-longhorn
