From 45e0cf17884e4eca0e353d8e74b98a3d43888134 Mon Sep 17 00:00:00 2001 From: caiyixiang Date: Thu, 6 Apr 2017 09:31:38 +0800 Subject: [PATCH] add a example for haproxy_custom_configuration --- .../custom-configuration/haproxy/README.md | 39 +++++++++++++++++++ .../haproxy/haproxy-custom-configuration.yaml | 39 +++++++++++++++++++ .../haproxy/haproxy-load-balancer-conf.yaml | 8 ++++ 3 files changed, 86 insertions(+) create mode 100644 examples/customization/custom-configuration/haproxy/README.md create mode 100644 examples/customization/custom-configuration/haproxy/haproxy-custom-configuration.yaml create mode 100644 examples/customization/custom-configuration/haproxy/haproxy-load-balancer-conf.yaml diff --git a/examples/customization/custom-configuration/haproxy/README.md b/examples/customization/custom-configuration/haproxy/README.md new file mode 100644 index 000000000..f357d39a6 --- /dev/null +++ b/examples/customization/custom-configuration/haproxy/README.md @@ -0,0 +1,39 @@ +# Customize the HAProxy configuration + +This example use a [ConfigMap](https://kubernetes.io/docs/user-guide/configmap/) to customize the HAProxy configuration. + +## Prerequisites + +This document has the following prerequisites: + +* Deploy a service named `ingress-default-backend` to be used as default backend service +* Create a [TLS secret](/examples/PREREQUISITES.md#tls-certificates) named `tls-secret` to be used as default TLS certificate + +As mentioned in the deployment instructions, you MUST turn down any existing +ingress controllers before running HAProxy Ingress. + +## Customize the HAProxy configuration + +Using a [ConfigMap](https://kubernetes.io/docs/user-guide/configmap/) is possible to customize the HAProxy configuration + +For example, if we want to change the timeouts we need to create a ConfigMap: + +``` +$ cat haproxy-load-balancer-conf.yaml +apiVersion: v1 +data: + timeout http-request: "10s" + timeout connect: "10s" + timeout check: "10s" +kind: ConfigMap +metadata: + name: haproxy-load-balancer-conf +``` + +``` +$ kubectl create -f haproxy-load-balancer-conf.yaml +``` + +Please check the example `haproxy-custom-configuration.yaml` + +If the Configmap it is updated, HAProxy will be reloaded with the new configuration. diff --git a/examples/customization/custom-configuration/haproxy/haproxy-custom-configuration.yaml b/examples/customization/custom-configuration/haproxy/haproxy-custom-configuration.yaml new file mode 100644 index 000000000..a7d924a55 --- /dev/null +++ b/examples/customization/custom-configuration/haproxy/haproxy-custom-configuration.yaml @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + labels: + run: haproxy-ingress + name: haproxy-ingress +spec: + replicas: 1 + selector: + matchLabels: + run: haproxy-ingress + template: + metadata: + labels: + run: haproxy-ingress + spec: + containers: + - name: haproxy-ingress + image: quay.io/jcmoraisjr/haproxy-ingress + args: + - --default-backend-service=default/ingress-default-backend + - --default-ssl-certificate=default/tls-secret + - --configmap=haproxy-custom-configuration + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + - name: stat + containerPort: 1936 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/examples/customization/custom-configuration/haproxy/haproxy-load-balancer-conf.yaml b/examples/customization/custom-configuration/haproxy/haproxy-load-balancer-conf.yaml new file mode 100644 index 000000000..f0c8b6703 --- /dev/null +++ b/examples/customization/custom-configuration/haproxy/haproxy-load-balancer-conf.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +data: + timeout http-request: "10s" + timeout connect: "10s" + timeout check: "10s" +kind: ConfigMap +metadata: + name: haproxy-custom-configuration