Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Created June 10, 2022 17:33
Show Gist options
  • Save haproxytechblog/301baef264bed186e09b724b2919ece1 to your computer and use it in GitHub Desktop.
Save haproxytechblog/301baef264bed186e09b724b2919ece1 to your computer and use it in GitHub Desktop.
Custom Resources with HAProxy Kubernetes Ingress Controller
$ kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
bindings v1 true Binding
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true ConfigMap
endpoints ep v1 true Endpoints
events ev v1 true Event
limitranges limits v1 true LimitRange
namespaces ns v1 false Namespace
nodes no v1 false Node
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
$ kubectl apply -f https://cdn.haproxy.com/documentation/kubernetes/1.8/crd/backend.yaml
$ kubectl apply -f https://cdn.haproxy.com/documentation/kubernetes/1.8/crd/defaults.yaml
$ kubectl apply -f https://cdn.haproxy.com/documentation/kubernetes/1.8/crd/global.yaml
$ kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
...
backends core.haproxy.org/v1alpha1 true Backend
defaults core.haproxy.org/v1alpha1 true Defaults
globals core.haproxy.org/v1alpha1 true Global
$ kubectl get crd
NAME CREATED AT
backends.core.haproxy.org 2022-06-01T16:09:57Z
defaults.core.haproxy.org 2022-06-01T16:56:57Z
globals.core.haproxy.org 2022-06-01T16:56:57Z
apiVersion: "core.haproxy.org/v1alpha1"
kind: Global
metadata:
name: example-global
namespace: default
spec:
config:
maxconn: 60000
$ kubectl apply -f example-global.yaml
$ kubectl get globals
NAME AGE
example-global 6d17h
$ kubectl describe global example-global
Name: example-global
Namespace: default
Labels: <none>
Annotations: <none>
API Version: core.haproxy.org/v1alpha1
Kind: Global
...
apiVersion: v1
kind: ConfigMap
metadata:
name: kubernetes-ingress
namespace: haproxy-controller
data:
cr-global: default/example-global
$ kubectl apply -f myconfigmap.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment