K8s Slackbot

5 min read
K8s Slackbot

Deploying a python slack-bot in k8s
This is my setup for a slackbot running in k8s. It is a working solution designed for kubernetes 1.17

Dockerfile

FROM python:rc-alpine

RUN mkdir /app
RUN mkdir /app/config
WORKDIR /app

COPY requirements.txt /app
RUN pip install -r requirements.txt

COPY mybot_random.py /app
COPY trafik_status.py /app
COPY trafikhelp.py /app
COPY trafikbotxml.py /app
COPY run.py /app

CMD ["python3","./run.py"]

k8s deployment yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
generation: 1
labels:
    app: zadeotrafikbot
name: zadeotrafikbot
replicas: 1
selector:
    matchLabels:
    app: zadeotrafikbot
strategy:
    type: Recreate
template:
    labels:
        app: zadeotrafikbot
    spec:
    containers:
        image: pylab2.enskede.local:5000/zadeotrafikbot:1.3.1-py38
        imagePullPolicy: IfNotPresent
        name: zadeotrafikbot
        resources: {}
        volumeMounts:
        - mountPath: /app/config/
        name: app-config
    dnsPolicy: ClusterFirst
    restartPolicy: Always
    terminationGracePeriodSeconds: 5
    volumes:
    - configMap:
        defaultMode: 420
        name: zadeo.trafikbot.config
        name: app-config