apiVersion: v1
kind: Service
metadata:
  name: memberships
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: memberships
  ports:
    - name: ui
      protocol: TCP
      port: {{ .Values.port }}
      targetPort: ui
---
apiVersion: v1
kind: Service
metadata:
  name: memberships-api
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: memberships
  ports:
    - name: api
      protocol: TCP
      port: {{ .Values.apiPort }}
      targetPort: api
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: memberships
  namespace: {{ .Release.Namespace }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: memberships
  template:
    metadata:
      labels:
        app: memberships
    spec:
      containers:
      - name: memberships
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        ports:
        - name: ui
          containerPort: {{ .Values.port }}
          protocol: TCP
        - name: api
          containerPort: {{ .Values.apiPort }}
          protocol: TCP
        command:
        - /usr/bin/memberships
        - --port={{ .Values.port }}
        - --api-port={{ .Values.apiPort }}
        - --db-path=/data/memberships.db
        volumeMounts:
        - name: memberships
          mountPath: /data
      volumes:
      - name: memberships
        persistentVolumeClaim:
          claimName: {{ .Values.volumeClaimName }}
