Configuration reference
ValidationRules CRD
Selected version
ValidationRules CRD Configuration reference
Available since version 3.2
With user-defined annotations, you can extend the functionality of HAProxy Kubernetes Ingress Controller in custom ways. User-defined annotations attach to the metadata of your Kubernetes resources and are translated into one or many lines of HAProxy configuration. They can be simple, but they can also enable advanced use cases through templating expressions. You can restrict which namespaces, resource kinds, and configuration sections your annotations are available to; and you can define validation logic that ensures users set your annotations correctly.
On-demand webinar
Prerequisites Jump to heading
Info
If you installed the ingress controller with Helm, this CRD is installed and updated automatically. If you installed with kubectl, follow these instructions for installation. Once installed, to perform updates on this CRD see: Update CRDs.
Before you can use the ValidationRules custom resource, you must install its definition into your Kubernetes cluster.
-
Download the v3-2 Validationrules custom resource file.
-
Install the custom resource definition with
kubectl apply:Community ingress controller
nixkubectl apply -f ingress.v3.haproxy.org_validationrules.yamlnixkubectl apply -f ingress.v3.haproxy.org_validationrules.yaml -
Verify that the installation worked by listing custom resources defined in your cluster:
nixkubectl get crdnixkubectl get crdoutputtextNAME CREATED ATvalidationrules.ingress.v3.haproxy.org 2022-01-21T20:00:31ZoutputtextNAME CREATED ATvalidationrules.ingress.v3.haproxy.org 2022-01-21T20:00:31Z -
When deploying the ingress controller, add the startup argument
--custom-validation-rules=<namespace>/<validationrules-name>, wherevalidationrules-nameis the name you’ll assign to your ValidationRules custom resource. With Helm, you can set it withextraArgs. In this example, we set it tohaproxy-controller/example-annotations.myvals.yamlyamlcontroller:extraArgs:- --custom-validation-rules=haproxy-controller/example-annotationsmyvals.yamlyamlcontroller:extraArgs:- --custom-validation-rules=haproxy-controller/example-annotations -
Continue on to the full tutorial, Add user-defined annotations.
Properties
-
CRD version:
3.2 -
API version:
ingress.v3.haproxy.org/v3
ingresses
[array]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
ingresses: Array of String
namespaces
[array]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
namespaces: Array of String
order_priority
[integer]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
order_priority: Integer
resources
[array]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
resources: Array of String
rule
[string]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
rule: String
section
[string]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
section: String # Allowed values are frontend, backend, all
template
[string]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
template: String
type
[string]
apiVersion: "ingress.v3.haproxy.org/v3"
kind: ValidationRules
metadata:
name: example-annotations
namespace: haproxy-controller
spec:
prefix: "example.com"
validation_rules:
example-annotation:
type: String # Allowed values are duration, int, uint, bool, string, float, json
Do you have any suggestions on how we can improve the content of this page?