# Example: Create a secret with Piranha DNS API credentials
# kubectl create secret generic piranhadns-credentials \
#   --namespace cert-manager \
#   --from-literal=key-id=YOUR_KEY_ID \
#   --from-literal=secret-key=YOUR_SECRET_KEY
---
apiVersion: v1
kind: Secret
metadata:
  name: piranhadns-credentials
  namespace: cert-manager
type: Opaque
stringData:
  key-id: "YOUR_KEY_ID_HERE"
  secret-key: "YOUR_SECRET_KEY_HERE"
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-piranhadns
spec:
  acme:
    # Use Let's Encrypt production
    server: https://acme-v02.api.letsencrypt.org/directory
    # For testing, use staging:
    # server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: admin@piranha.sh
    privateKeySecretRef:
      name: letsencrypt-piranhadns-account-key
    solvers:
      - dns01:
          webhook:
            groupName: acme.piranha.sh
            solverName: piranhadns
            config:
              apiEndpoint: https://api.piranha.sh
              keyIdSecretRef:
                name: piranhadns-credentials
                key: key-id
              secretKeyRef:
                name: piranhadns-credentials
                key: secret-key
---
# Example Certificate request
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: example-certificate
  namespace: default
spec:
  secretName: example-tls
  issuerRef:
    name: letsencrypt-piranhadns
    kind: ClusterIssuer
  dnsNames:
    - "example.piranha.sh"
    - "*.example.piranha.sh"
