apiVersion: v1
kind: Service
metadata:
  name: memberships
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: memberships
  ports:
    - name: {{ .Values.portName }}
      protocol: TCP
      port: 80
      targetPort: ui
---
apiVersion: v1
kind: Service
metadata:
  name: memberships-api
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: memberships
  ports:
    - name: {{ .Values.portName }}
      protocol: TCP
      port: 80
      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: 8080
          protocol: TCP
        - name: api
          containerPort: 8081
          protocol: TCP
        command:
        - /usr/bin/memberships
        - --port=8080
        - --api-port=8081
        - --db-path=/data/memberships.db
        volumeMounts:
        - name: memberships
          mountPath: /data
      volumes:
      - name: memberships
        persistentVolumeClaim:
          claimName: {{ .Values.volumeClaimName }}
