Skip to content

Instantly share code, notes, and snippets.

@C-Loftus
Last active April 17, 2025 15:56
Show Gist options
  • Select an option

  • Save C-Loftus/44c9d18be2e3775ba15eb3dbc7467bfd to your computer and use it in GitHub Desktop.

Select an option

Save C-Loftus/44c9d18be2e3775ba15eb3dbc7467bfd to your computer and use it in GitHub Desktop.
Simple pygeoapi with k8s
#!/bin/bash
sudo docker run \
--privileged \
--name k3s-server-1 \
--hostname k3s-server-1 \
-p 6443:6443 \
-d rancher/k3s:v1.24.10-k3s1 \
server
set -e # Exit on error
# Define the pod YAML configuration
cat <<EOF > pygeoapi-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: pygeoapi
labels:
role: myrole
spec:
containers:
- name: pygeoapi
image: geopython/pygeoapi:latest
ports:
- name: web
containerPort: 80
protocol: TCP
EOF
# Create the pod
echo "Creating the pygeoapi pod..."
kubectl apply -f pygeoapi-pod.yaml
# Wait for the pod to be ready
echo "Waiting for the pygeoapi pod to be ready..."
kubectl wait --for=condition=Ready pod/pygeoapi --timeout=60s
# Port-forward local port 5000 to the container's port 80
echo "Port forwarding from localhost:5000 to pygeoapi:80..."
kubectl port-forward pod/pygeoapi 5000:80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment