Automating OnCall Summary Page Generation
This is final part of 3 part series discussing automation of generating on call summary of PagerDuty incidents into a Notion page. In this blog we will discuss combining everything we did in last 2 parts and schedule it using K8 CronJob.
PagerDuty is designed to alert clients to disruptions and outages through machine learning and automation. Notion is a collaboration platform with markdown support that integrates kanban boards, tasks, wikis, and databases.
Let’s first create a docker image. Assume the python file for collecting incidents from PagerDuty (Part 1) is named get_pd_incidents.py and python file for creating notion page (Part 2) is named create_notion_page.py. A simple Dockerfile will look like:
FROM python:3.7.1
# Install required dependencies
RUN pip3 install --upgrade pip
RUN pip3 install requests
RUN pip3 install pdpyras
RUN pip3 install notion
# Bundle app source
COPY get_pd_incidents.py /src/get_pd_incidents.py
COPY create_notion_page.py /src/create_notion_page.py
CMD ["python3", "/src/get_pd_incidents.py"]
Make sure the files are present in your current working directory where Dockerfile is present. Build the docker image using:
docker build . -t <docker_hub>/on-call-summary:0.0.0
Now let’s schedule the application using K8 CronJob.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: on-call-summary
spec:
schedule: “0 0 * * SUN"
jobTemplate:
spec:
template:
spec:
containers:
- name: on-call-summary
image: <docker_hub>/on-call-summary:0.0.0
Save it to on-call-summary-cron.yml file and apply it using:
kubectl apply -f on-call-summary-cron.yml
Complete application code can be found in my GitHub.