apiVersion: v1
kind: Service
metadata:
  name: rpuppy
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: rpuppy
  ports:
  - name: http
    port: 80
    targetPort: http
    protocol: TCP
# ---
# apiVersion: cert-manager.io/v1
# kind: Certificate
# metadata:
#   name: rpuppy
#   namespace: {{ .Release.Namespace }}
#   # annotations:
#   #   helm.sh/resource-policy: keep
# spec:
#   secretName: cert-rpuppy
#   dnsNames:
#   - {{ .Values.domain }}
#   issuerRef:
#     kind: ClusterIssuer
#     name: {{ .Values.certificateIssuer}}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  namespace: {{ .Release.Namespace }}
  annotations:
    acme.cert-manager.io/http01-edit-in-place: "true"
    # acme.cert-manager.io/http01-ingress-class: {{ .Values.ingressClassName }}
    cert-manager.io/cluster-issuer: {{ .Values.certificateIssuer}}
spec:
  ingressClassName: {{ .Values.ingressClassName }}
  tls:
  - hosts:
    - {{ .Values.domain }}
    secretName: cert-rpuppy
  rules:
  - host: {{ .Values.domain }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: rpuppy
            port:
              name: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rpuppy
  namespace: {{ .Release.Namespace }}
spec:
  selector:
    matchLabels:
      app: rpuppy
  replicas: 1
  template:
    metadata:
      labels:
        app: rpuppy
    spec:
      containers:
      - name: rpuppy
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        command: ["rpuppy", "--port=8080"]
        resources:
          requests:
            memory: "10Mi"
            cpu: "10m"
          limits:
            memory: "20Mi"
            cpu: "100m"
      tolerations:
      - key: "pcloud"
        operator: "Equal"
        value: "role"
        effect: "NoSchedule"
