apiVersion: v1
kind: ServiceAccount
metadata:
  name: piranhadns-webhook
  namespace: cert-manager
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: piranhadns-webhook
rules:
  - apiGroups:
      - ""
    resources:
      - secrets
    verbs:
      - get
      - list
      - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: piranhadns-webhook
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: piranhadns-webhook
subjects:
  - kind: ServiceAccount
    name: piranhadns-webhook
    namespace: cert-manager
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: piranhadns-webhook:webhook-authentication-reader
  namespace: kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
  - kind: ServiceAccount
    name: piranhadns-webhook
    namespace: cert-manager
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: piranhadns-webhook:auth-delegator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator
subjects:
  - kind: ServiceAccount
    name: piranhadns-webhook
    namespace: cert-manager
---
apiVersion: v1
kind: Service
metadata:
  name: piranhadns-webhook
  namespace: cert-manager
spec:
  ports:
    - name: https
      port: 443
      targetPort: https
  selector:
    app: piranhadns-webhook
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: piranhadns-webhook
  namespace: cert-manager
spec:
  replicas: 1
  selector:
    matchLabels:
      app: piranhadns-webhook
  template:
    metadata:
      labels:
        app: piranhadns-webhook
    spec:
      serviceAccountName: piranhadns-webhook
      imagePullSecrets:
        - name: registrypullsecret-pcr
      containers:
        - name: webhook
          image: pcr.piranha.sh/piranha-cert-manager-webhook-piranhadns:0.0.1
          imagePullPolicy: Always
          ports:
            - name: https
              containerPort: 443
          env:
            - name: GROUP_NAME
              value: "acme.piranha.sh"
          livenessProbe:
            httpGet:
              path: /healthz
              port: https
              scheme: HTTPS
            initialDelaySeconds: 10
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /healthz
              port: https
              scheme: HTTPS
            initialDelaySeconds: 5
            periodSeconds: 5
          volumeMounts:
            - name: certs
              mountPath: /tls
              readOnly: true
      volumes:
        - name: certs
          secret:
            secretName: piranhadns-webhook-tls
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  name: v1alpha1.acme.piranha.sh
  annotations:
    cert-manager.io/inject-ca-from: cert-manager/piranhadns-webhook-tls
spec:
  group: acme.piranha.sh
  groupPriorityMinimum: 1000
  versionPriority: 15
  service:
    name: piranhadns-webhook
    namespace: cert-manager
  version: v1alpha1
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: piranhadns-webhook-tls
  namespace: cert-manager
spec:
  secretName: piranhadns-webhook-tls
  dnsNames:
    - piranhadns-webhook
    - piranhadns-webhook.cert-manager
    - piranhadns-webhook.cert-manager.svc
  issuerRef:
    name: piranhadns-webhook-selfsign
    kind: Issuer
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: piranhadns-webhook-selfsign
  namespace: cert-manager
spec:
  selfSigned: {}
