177 lines
4.8 KiB
YAML
177 lines
4.8 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: myorg-assistant
|
|
namespace: default
|
|
labels:
|
|
app: myorg-assistant
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: myorg-assistant
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: myorg-assistant
|
|
spec:
|
|
initContainers:
|
|
- name: git-clone
|
|
image: alpine/git:latest
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
if [ ! -d /data/myorg/.git ]; then
|
|
echo "Cloning repository..."
|
|
git clone ${GIT_REPO_URL} /data/myorg
|
|
cd /data/myorg
|
|
git config user.name "${GIT_USERNAME}"
|
|
git config user.email "${GIT_USERNAME}@users.noreply.github.com"
|
|
git config credential.helper store
|
|
echo "https://${GIT_USERNAME}:${GIT_TOKEN}@github.com" > ~/.git-credentials
|
|
else
|
|
echo "Repository already exists, pulling latest changes..."
|
|
cd /data/myorg
|
|
git pull
|
|
fi
|
|
env:
|
|
- name: GIT_REPO_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: GIT_REPO_URL
|
|
- name: GIT_USERNAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: GIT_USERNAME
|
|
- name: GIT_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: GIT_TOKEN
|
|
volumeMounts:
|
|
- name: myorg-data
|
|
mountPath: /data/myorg
|
|
|
|
containers:
|
|
- name: myorg-assistant
|
|
image: gitea.rogi.casa/roger/myorg-assistant/myorg-assistant:latest
|
|
imagePullPolicy: IfNotPresent
|
|
command: ["./start.sh"]
|
|
ports:
|
|
- containerPort: 8000
|
|
name: web
|
|
protocol: TCP
|
|
env:
|
|
# From ConfigMap
|
|
- name: LITELLM_ENDPOINT
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: LITELLM_ENDPOINT
|
|
- name: LITELLM_MODEL
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: LITELLM_MODEL
|
|
- name: MYORG_REPO_PATH
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: MYORG_REPO_PATH
|
|
- name: TIMEZONE
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: TIMEZONE
|
|
- name: WEB_HOST
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: WEB_HOST
|
|
- name: WEB_PORT
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: WEB_PORT
|
|
- name: GIT_BRANCH
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: myorg-assistant-config
|
|
key: GIT_BRANCH
|
|
|
|
# From Secret
|
|
- name: DISCORD_BOT_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: DISCORD_BOT_TOKEN
|
|
- name: DISCORD_CHANNEL_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: DISCORD_CHANNEL_ID
|
|
- name: LITELLM_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: LITELLM_API_KEY
|
|
- name: GIT_REPO_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: GIT_REPO_URL
|
|
- name: GIT_USERNAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: GIT_USERNAME
|
|
- name: GIT_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: GIT_TOKEN
|
|
- name: WEB_SECRET_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: WEB_SECRET_KEY
|
|
- name: WEB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: myorg-assistant-secret
|
|
key: WEB_PASSWORD
|
|
optional: true
|
|
|
|
volumeMounts:
|
|
- name: myorg-data
|
|
mountPath: /data/myorg
|
|
|
|
resources:
|
|
requests:
|
|
memory: "256Mi"
|
|
cpu: "250m"
|
|
limits:
|
|
memory: "512Mi"
|
|
cpu: "500m"
|
|
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- sh
|
|
- -c
|
|
- "ps aux | grep 'python -m src.main bot' | grep -v grep"
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
|
|
volumes:
|
|
- name: myorg-data
|
|
persistentVolumeClaim:
|
|
claimName: myorg-assistant-pvc
|
|
|
|
restartPolicy: Always
|