KronoPost is a lightweight Kubernetes Operator designed to simplify the recurrent, scheduled invocation of endpoints on services deployed within your cluster. Instead of managing complex CronJob resources, KronoPost allows you to define a simple Custom Resource Definition (CRD) to handle scheduled HTTP/HTTPS requests to your services.
It's built using Java and the Micronaut framework.
- Simplified Scheduling: Define scheduled calls directly on a target service using a familiar cron expression.
- Lightweight Alternative: A more streamlined and efficient alternative to creating
CronJobresources that require dedicated containers runningcurlor similar tools. - Targeted Service Invocation: Directly targets internal Kubernetes Services, making it ideal for microservices that need external, recurring triggers.
- Multiple Instances Support: Perfectly suited for applications where multiple instances require recurrent invocation (e.g., triggering a cleanup endpoint on various services).
You need a running Kubernetes cluster and kubectl configured to interact with it.
KronoPost is deployed as a single Kubernetes Operator deployment.
-
Apply CRD and RBAC: (Note: You must first apply the required CRD and RBAC configuration files.)
kubectl apply -f crd.yaml kubectl apply -f rbac.yaml
-
Deploy the Operator: Use the following manifest to deploy the KronoPost operator. This example assumes the operator will watch the
defaultnamespace.apiVersion: apps/v1 kind: Deployment metadata: labels: app: kronopost-operator name: kronopost-operator spec: replicas: 1 selector: matchLabels: app: kronopost-operator template: metadata: labels: app: kronopost-operator spec: serviceAccountName: kronopost-operator-sa # Replace with your created SA name containers: - image: incsteps/kronopost:0.0.1 name: kronopost-operator imagePullPolicy: Always env: # Set the namespaces the operator should watch (comma-separated list) - name: KRONOPOST_NAMESPACES value: "default" resources: requests: memory: "1024Mi" limits: memory: "1024Mi"
Apply the deployment:
kubectl apply -f operator-deployment.yaml
Once the operator is running, create a Kronopost custom resource to define your scheduled call.
Here is an example Kronopost resource:
apiVersion: [incsteps.com/v1](https://incsteps.com/v1)
kind: Kronopost
metadata:
name: kronopost-example
spec:
# REQUIRED: The name of the Kubernetes Service to invoke.
serviceSelector: example-service
# OPTIONAL: The protocol (http or https). Defaults to 'http'.
protocol: http
# OPTIONAL: The path on the service to call. Defaults to '/'.
path: /
# REQUIRED: The cron expression defining the schedule.
cron: "*/1 * * * *" # Every minute
# OPTIONAL: The HTTP method (GET, POST, PUT, DELETE, etc.). Defaults to 'GET'.
method: GETThe KronoPost operator watches for this Kronopost object. According to the cron expression (e.g., "Every minute"), the operator will perform the specified HTTP request (e.g., GET) to the targeted service (example-service) at the defined path (/).
Apply the resource:
kubectl apply -f kronopost-resource.yaml
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
serviceSelector |
string | Yes | N/A | Name of the target Kubernetes Service. |
cron |
string | Yes | N/A | Standard Cron expression (e.g., */5 * * * *). |
protocol |
string | No | http |
The protocol to use (http or https). |
path |
string | No | / |
The URL path to call on the service. |
method |
string | No | GET |
The HTTP method (e.g., GET, POST). |
If you wish to build the operator from source:
-
Clone the repository:
git clone [Your Repository URL] cd KronoPost -
Build the project (using Micronaut/Java):
./gradlew clean build
-
Develop in a K3d local cluster: (Make sure you have Docker installed and configured.)
k3d registry create registry.local --port 5000 k3d cluster create --registry-config k3d-registry.yml
where k3d-registry.yml contains:
mirrors: "k3d-registry.local:5000": endpoint: - http://k3d-registry.local:5000
You can use skaffold to deploy/debug
skaffold debug
We welcome contributions! Please feel free to submit issues and pull requests to help improve KronoPost.
- Fork the repository.
- Create a new branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add some amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
KronoPost is open-source software licensed under the MIT License.