The Kubernetes Status Page Operator is a custom controller that automatically manages components on a status page (like StatusPage.io) based on the state of resources in your Kubernetes cluster. It allows you to monitor specific Pods, Services, and Ingresses across selected namespaces and reflect their status on your status page.
- Automatically create, update, and delete status page components based on Kubernetes resources
- Selectively monitor specific resources using CustomResourceDefinitions (CRDs)
- Configure monitored namespaces using a ConfigMap
- Real-time status updates based on Kubernetes events
- Easy integration with StatusPage.io (extensible to other status page providers)
- Kubernetes cluster (version 1.16+)
kubectl
configured to communicate with your cluster- Docker (for building the operator image)
- StatusPage.io account (or similar status page service)
-
Clone this repository:
git clone https://github.com/your-username/k8s-status-page-operator.git cd k8s-status-page-operator
-
Build the Docker image:
docker build -t your-registry/statuspage-operator:latest . docker push your-registry/statuspage-operator:latest
-
Create a Secret with your StatusPage API key and page ID:
apiVersion: v1 kind: Secret metadata: name: statuspage-secrets namespace: default type: Opaque stringData: api-key: your-statuspage-api-key page-id: your-statuspage-page-id
Apply this Secret to your cluster:
kubectl apply -f statuspage-secrets.yaml
-
Apply the Kubernetes resources:
kubectl apply -f crd.yaml kubectl apply -f configmap.yaml kubectl apply -f rbac.yaml kubectl apply -f deployment.yaml
Edit the statuspage-operator-config
ConfigMap to specify which namespaces should be monitored:
apiVersion: v1
kind: ConfigMap
metadata:
name: statuspage-operator-config
namespace: default
data:
config.yaml: |
monitored_namespaces:
- default
- production
- staging
Apply the changes:
kubectl apply -f configmap.yaml
The operator will automatically reload the configuration every 5 minutes.
To monitor a specific Kubernetes resource:
-
Create a
StatusPageMonitor
custom resource:apiVersion: statuspage.example.com/v1 kind: StatusPageMonitor metadata: name: monitor-my-service namespace: default spec: resourceType: Service resourceName: my-service namespace: default
-
Apply the custom resource:
kubectl apply -f status-page-monitor.yaml
The operator will create a corresponding component on your status page and keep it updated based on the state of the Kubernetes resource.
- Python 3.9+
- pipenv
-
Install dependencies:
pipenv install
-
Activate the virtual environment:
pipenv shell
-
Run the operator locally:
kopf run status_page_operator.py --verbose
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.