Skip to content

Instantly share code, notes, and snippets.

@hardyscc
Last active September 13, 2022 07:53
Show Gist options
  • Save hardyscc/ea42102a8158b505cf4b9a3ee6abf9a8 to your computer and use it in GitHub Desktop.
Save hardyscc/ea42102a8158b505cf4b9a3ee6abf9a8 to your computer and use it in GitHub Desktop.
Cert Manager on Kubernetes

Install Cert Manager

helm repo add jetstack https://charts.jetstack.io
helm repo update

kubectl create namespace cert-manager

helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --version v1.9.1 \
  --set installCRDs=true

kubectl apply -f - <<YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-staging
spec:
  acme:
    server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: [email protected]
    privateKeySecretRef:
      name: letsencrypt-staging
    solvers:
    - http01:
        ingress:
          class: public
YAML

kubectl apply -f - <<YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: [email protected]
    privateKeySecretRef:
       name: letsencrypt-prod
    solvers:
    - http01:
        ingress:
          class: public
YAML
kubectl delete ClusterIssuer letsencrypt-staging
kubectl delete ClusterIssuer letsencrypt-prod
helm delete cert-manager -n cert-manager

Sample Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: production-auto-deploy
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    # kubernetes.io/ingress.class: public
spec:
  ingressClassName: public
  rules:
  - host: sample.apps.domain.com
    http:
      paths:
      - backend:
          service:
            name: production-auto-deploy
            port:
              number: 5000
        path: /
        pathType: Prefix
  tls:
  - hosts:
    - sample.apps.domain.com
    secretName: production-auto-deploy-tls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment