apiVersion: v1
kind: Service
metadata:
  name: etherpad
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: etherpad
  ports:
  - name: http
    port: {{ .Values.port }}
    targetPort: http
    protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: etherpad
  namespace: {{ .Release.Namespace }}
spec:
  selector:
    matchLabels:
      app: etherpad
  replicas: 1
  template:
    metadata:
      labels:
        app: etherpad
    spec:
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: {{ .Values.persistentVolumeClaimName }}
      containers:
      - name: etherpad
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: http
          containerPort: {{ .Values.port }}
          protocol: TCP
        env:
        - name: "PORT"
          value: "8080"
        - name: "NODE_ENV"
          value: "production"
        - name: "ADMIN_PASSWORD"
          value: "admin"
        - name: "USER_PASSWORD"
          value: "user"
        - name: "DEFAULT_PAD_TEXT"
          value: "dodo"
        - name: "TRUST_PROXY"
          value: "true"
        - name: "DB_TYPE"
          value: "{{ .Values.db.type }}"
        - name: "DB_HOST"
          value: "{{ .Values.db.host }}"
        - name: "DB_PORT"
          value: "{{ .Values.db.port }}"
        - name: "DB_NAME"
          value: "{{ .Values.db.name }}"
        - name: "DB_USER"
          value: "{{ .Values.db.user }}"
        - name: "DB_PASS"
          value: "{{ .Values.db.pass }}"
        - name: "DB_CHARSET"
          value: "{{ .Values.db.charset }}"
        volumeMounts:
        - name: data
          mountPath: /var/lib/etherpad
          readOnly: false
