Uncategorized
kmerkuri  

Automate Jira Issue Creation for Expiring Certificates with Cert-manager

Hello, tech enthusiasts! Today, we’re going to explore an exciting integration between Cert-manager and Jira. This setup will automatically create Jira issues when a certificate is about to expire, ensuring that you’re always on top of your certificate management game. Let’s dive in!

Prerequisites

  1. A Kubernetes cluster with cert-manager installed. You can install it using Helm:shellEditFull ScreenCopy code1helm install \ 2 cert-manager jetstack/cert-manager \ 3 --namespace cert-manager \ 4 --create-namespace \ 5 --version v1.13.3 \ 6 --set installCRDs=true \ 7 --set prometheus.enabled=false \ 8 --set webhook.timeoutSeconds=4
  2. Access to a Docker registry and the ability to build and push images.
  3. A Jira server with API access.
  4. Clone Github repo

Deploy the Custom Controller

  1. Build the image and push it into your Docker registry:dockerEditFull ScreenCopy code1docker build -t <name of registry>/<image name>:<image tag> . 2docker push <name of registry>/<image name>:<image tag>
  2. Create a certificate and a Kubernetes secret out of that certificate:shellEditFull ScreenCopy code1openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 2 2kubectl create secret tls <secret name> --key="cert.pem" --cert="key.pem" -n <namespace>
  3. Edit the k8s/deployment.yaml file and set the image, environment variables, and secret name:shellEditFull ScreenCopy code1image: <name of registry>/<image name>:<image tag> 2env: 3 - name: JIRA_SERVER 4 - name: JIRA_USERNAME 5 - name: JIRA_API_TOKEN 6 - name: JIRA_PROJECT_KEY 7secretName: <name of the secret tks you created earlier>
  4. Update the mutation.yaml file with the CA bundle from your certificate’s TLS secret:shellEditFull ScreenCopy code1kubectl get secret <secret name> -o jsonpath='{.data.ca\.crt}' | base64 --decode > ca.crtReplace caBundle in mutation.yaml with the contents of ca.crt.
  5. Apply the configuration:shellEditFull ScreenCopy code1kubectl apply -f k8s/

That’s it! You’ve successfully integrated Cert-manager with Jira to automatically create issues when certificates are about to expire. Stay proactive and maintain your certificates with ease!

Leave A Comment