A Kubernetes operator for experimental deployment of applications in fog computing environments, enabling seamless rollouts across cloud, fog, and edge layers.
Fog Rollouts is a Python-based Kubernetes operator that orchestrates application deployments across multiple computing layers in fog environments. It provides automated synchronization and management of applications between cloud, fog, and edge infrastructures using custom Kubernetes resources.
- Multi-layer Deployment: Deploy applications across cloud, fog, and edge layers
- Automatic Synchronization: Keeps deployments synchronized across different layers
- Custom Resource Definitions: Uses Kubernetes CRDs for declarative fog rollout management
- RESTful API: FastAPI-based service for rollout management
- Version Management: Tracks and manages application versions across layers
- Kubernetes Native: Built on Kubernetes using kopf (Kubernetes Operator Pythonic Framework)
The system operates on a hierarchical fog computing model:
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Cloud βββββΆβ Fog βββββΆβ Edge β
β (Central) β β (Regional) β β (Local) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
- FogRollout CRD: Custom Kubernetes resource defining multi-layer deployments
- Watcher: Python service that synchronizes rollouts between layers
- API Server: FastAPI service providing REST endpoints for rollout management
- Helm Chart: Kubernetes deployment configuration
- Docker - Container platform
- Helm - Kubernetes package manager
- kubectl - Kubernetes management tool
- k3d - Containerized k3s Kubernetes distribution
- pipenv - Python dependency manager
- kopf: Kubernetes operator framework
- fastapi: Modern web framework for APIs
- uvicorn: ASGI server
- pykube-ng: Kubernetes client library
- loguru: Advanced logging
- requests: HTTP library
Create a local k3d cluster:
k3d create --image rancher/k3s:v1.18.2-k3s1Configure kubectl:
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"Use the Makefile to build and deploy:
make runThis command will:
- Build the Docker image
- Import it into k3d
- Deploy using Helm across cloud, fog, and edge namespaces
Deploy the nginx example rollout:
kubectl apply -f examples/nginx-rollout.yml -n cloudCheck rollouts across all namespaces:
kubectl get fog-rollouts --all-namespaces
kubectl get pods --all-namespacesDefine a FogRollout resource:
apiVersion: paguos.io/v1alpha1
kind: FogRollout
metadata:
name: my-app-rollout
spec:
version: v1.0.0
deployments:
cloud:
replicas: 3
containers:
- name: my-app
image: my-app:v1.0.0
ports:
- containerPort: 8080
fog:
replicas: 2
containers:
- name: my-app
image: my-app:v1.0.0
ports:
- containerPort: 8080
edge:
replicas: 1
containers:
- name: my-app
image: my-app:v1.0.0
ports:
- containerPort: 8080The system provides REST API endpoints:
- GET /rollouts: List all rollouts in a namespace
- GET /rollouts/{rollout_name}: Get specific rollout details
Example API usage:
# List rollouts in default namespace
curl http://fog-rollouts-api.cloud/rollouts
# Get specific rollout
curl http://fog-rollouts-api.cloud/rollouts/nginx-rollout- Clone the repository:
git clone <repository-url>
cd fog-rollouts- Install dependencies:
pipenv install --dev
pipenv shell- Run linting:
flake8 fog-rollouts/- Auto-format code:
autopep8 --in-place --recursive fog-rollouts/fog-rollouts/
βββ fog-rollouts/ # Main application code
β βββ api.py # FastAPI REST endpoints
β βββ clients.py # Kubernetes and API clients
β βββ handlers.py # Kopf event handlers
β βββ models.py # Data models and CRD definitions
β βββ watcher.py # Main synchronization logic
βββ chart/ # Helm chart for deployment
β βββ crds/ # Custom Resource Definitions
β βββ templates/ # Kubernetes manifests
β βββ Chart.yaml # Chart metadata
β βββ values.yaml # Default configuration
βββ examples/ # Example rollout configurations
βββ Dockerfile # Container build configuration
βββ Makefile # Build and deployment automation
βββ Pipfile # Python dependencies
βββ Pipfile.lock # Locked dependency versions
Build the Docker image:
make buildImport to k3d:
make k3d/importDeploy with Helm:
make helmClean up deployment:
make cleanThe application is containerized using a Python 3.8 slim base image. The Dockerfile:
- Uses
python:3.8-slim-busteras base - Installs pipenv for dependency management
- Sets up the application in
/fog-rolloutsdirectory - Configures the watcher as the default command
The system extends Kubernetes with a custom FogRollout resource that defines:
- Application version tracking
- Multi-layer deployment specifications
- Container configurations per layer
- Readiness and health check configurations
Built using the kopf framework, the operator:
- Watches for FogRollout resource changes
- Synchronizes state across layers
- Handles create, update, and delete operations
- Maintains desired state reconciliation
- Uses Kubernetes RBAC for access control
- Service-to-service communication within cluster
- Environment-based configuration for sensitive data
- Namespace isolation between layers
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 conventions
- Use meaningful variable and function names
- Add docstrings to functions and classes
- Maintain test coverage
This project is licensed under the terms specified in the repository.
- Designed for Linux and macOS environments
- Requires specific k3s version (v1.18.2-k3s1)
- Currently in experimental stage
For questions, issues, or contributions, please use the GitHub issue tracker.
Note: This project is experimental and designed for fog computing research and development. Use in production environments should be carefully evaluated.