kube-conditioner is a Kubernetes controller that allows you to define custom Kubernetes Pod conditions based on your own logic.
After installing kube-controller (see below) in your Kubernetes cluster, create a CRD like:
apiVersion: conditioner.itaysk.com/v1alpha1 kind: PodCondition metadata: name: conditiontest spec: interval: 5000 labelSelector: matchLabels: itaysk: test prometheusSource: serverUrl: "http://my.prom.server:9090" rule: "myimportantmetric<50"
(see ./config/samples for sample yaml files)
- Add a new Pod condition called
- To all Pods with label
- Determine the status of the by querying
- with the query
- expecting the query to succeed (result is non empty)
- Evaluate the condition every
Pod conditions are standard part of the Pod status section. They are described as:
Conditions represent the latest available observations of an object's state. They are an extension mechanism intended to be used when the details of an observation are not a priori known or would not apply to all instances of a given Kind source
- As a handy customizable sub-status on your pods that you can query manually or from scripts.
- To determine the Pod readiness state using Readiness Gate.
- For automatic remediation scenarios.
For more context and information, please see this blog post: http://blog.itaysk.com/2019/03/27/kube-conditioner-custom-pod-conditions-for-everyone
The controller is pluggable by design in regards to how to determin the status of the condition. The current implementation supports running queries against Prometheus in a pretty basic way. This area needs work and additional datasources may be added.
The Prometheus datasource is documented under ./pkg/datasource/prometheus/Readme.md
There's an image in docker hub and generated deployment files for easy experimentation but the process is not yet automated to get the latest bits it's better to build from source and generate deployment files.
kubectl apply -f config/crds kubectl apply -f https://raw.githubusercontent.com/itaysk/kube-conditioner/master/kube-deploy.yaml
#clone git clone https://github.com/itaysk/kube-conditioner.git cd kube-conditioner #build make IMG=mydocker/kube-builder:latest make docker-build #deploy make docker-push make deploy
PRs/issues are welcome!
- go 1.11.5
- kube-builder 1.0.8
- Kubernetes 1.13.2 (minikube)