Skip to content

Commit

Permalink
Add monitor scripts, dev edit for d3i
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRunfola committed Feb 14, 2025
1 parent 31f74b4 commit 9aacfd3
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 49 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build_gb_monitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: geoBoundaries Base Image Build
run-name: gB Base Build
on:
push:
branches: ['main']
paths: ['geoBoundaryBuilder/images/**']
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Define lowercase repository owner
id: repo
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./geoBoundaryBuilder/images/gBMonitor.Dockerfile
push: true
tags: ghcr.io/${{ env.REPO_OWNER }}/gb-monitor:latest
build-args: BUILDKIT_STEP_LOG_MAX_SIZE=10485760 BUILDKIT_STEP_LOG_MAX_SPEED=100000000
env:
# Enable Docker CLI debug output
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
DEBUG: 1
Empty file.
48 changes: 48 additions & 0 deletions geoBoundaryBuilder/debug/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: v1
kind: Pod
metadata:
name: worker-operator
namespace: geoboundaries
labels:
app: worker-operator
spec:
restartPolicy: Never # Restart policy at the Pod level
securityContext:
runAsUser: 71032 # User ID for accessing NFS
runAsGroup: 9915 # Group ID for accessing NFS
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- dss
- d3i00.sciclone.wm.edu
containers:
- name: worker-operator
image: ghcr.io/wmgeolab/gb-base:latest
command: ["/bin/bash", "-c"]
args:
- |
export KUBECONFIG=/sciclone/geograd/geoBoundaries/.kube && \
cd /sciclone/geograd/geoBoundaries/geoBoundaryBot/geoBoundaryBuilder/modules/
python worker_operator.py
env:
- name: DB_SERVICE
value: "geoboundaries-postgres-service"
- name: DB_NAME
value: "geoboundaries"
- name: DB_USER
value: "geoboundaries"
- name: DB_PASSWORD
value: ""
volumeMounts:
- name: sciclone-volume
mountPath: /sciclone # Mount kubeconfig directory
volumes:
- name: sciclone-volume
nfs:
server: 128.239.59.144
path: /sciclone
55 changes: 55 additions & 0 deletions geoBoundaryBuilder/debug/debug_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: v1
kind: Pod
metadata:
name: geoboundaries-postgres
namespace: geoboundaries
labels:
app: geoboundaries-postgres
spec:
securityContext:
runAsUser: 71032 # Required for NFS compatibility
runAsGroup: 9915 # Required for NFS group access
fsGroup: 9915 # Ensures group ownership for the data directory
containers:
- name: postgres
image: postgis/postgis:14-3.3 # PostGIS-enabled PostgreSQL image
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: "geoboundaries" # User to be created on first run
- name: POSTGRES_PASSWORD
value: "" # Empty password (trust authentication enabled)
- name: POSTGRES_DB
value: "geoboundaries" # Database to be created on first run
- name: POSTGRES_HOST_AUTH_METHOD
value: "trust" # Allow connections without a password
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data # Persistent data directory
resources:
requests:
memory: "8Gi"
cpu: "2"
limits:
memory: "16Gi"
cpu: "4"
volumes:
- name: postgres-data
nfs:
server: 128.239.59.144 # Replace with your NFS server IP
path: /sciclone/geograd/geoBoundaries/postgres # NFS path for PostgreSQL data storage
---
apiVersion: v1
kind: Service
metadata:
name: geoboundaries-postgres-service
namespace: geoboundaries
spec:
selector:
app: geoboundaries-postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
type: ClusterIP
14 changes: 14 additions & 0 deletions geoBoundaryBuilder/images/gBMonitor.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.9-slim

WORKDIR /app

RUN pip install --no-cache-dir \
Flask==2.3.3 \
psycopg2-binary==2.9.7 \
Werkzeug==2.3.7

COPY ./geoBoundaryBuilder/monitor /app/

EXPOSE 5000

CMD ["python", "app.py"]
46 changes: 46 additions & 0 deletions geoBoundaryBuilder/k8s_manifests/monitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: geoboundaries-monitor
namespace: geoboundaries
spec:
replicas: 1
selector:
matchLabels:
app: geoboundaries-monitor
template:
metadata:
labels:
app: geoboundaries-monitor
spec:
containers:
- name: monitor
image: ghcr.io/wmgeolab/gb-monitor:latest
ports:
- containerPort: 5000
env:
- name: DB_SERVICE
value: "geoboundaries-postgres-service"
- name: DB_NAME
value: "geoboundaries"
- name: DB_USER
value: "geoboundaries"
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
---
apiVersion: v1
kind: Service
metadata:
name: geoboundaries-monitor-service
namespace: geoboundaries
spec:
type: NodePort
ports:
- port: 80
targetPort: 5000
nodePort: 30081 # Similar to adminer's setup
selector:
app: geoboundaries-monitor
10 changes: 10 additions & 0 deletions geoBoundaryBuilder/k8s_manifests/worker_operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ spec:
securityContext:
runAsUser: 71032 # User ID for accessing NFS
runAsGroup: 9915 # Group ID for accessing NFS
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- dss
- d3i00.sciclone.wm.edu
containers:
- name: worker-operator
image: ghcr.io/wmgeolab/gb-base:latest
Expand Down
Loading

0 comments on commit 9aacfd3

Please sign in to comment.