haproxy

by eMAGTechLabs

Helm chartv1.4.1App 2.5-alpine

HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications

About this chart

haproxy

HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications

Source code can be found here

How to use it

# add emagtechlabs repository
helm repo add emagtechlabs  https://emagtechlabs.github.io/helm-charts/

# install haproxy chart
helm install emagtechlabs/haproxy

Prerequisites

  • Helm v3
  • Kubernetes 1.12+
  • haproxy 2.1
KeyTypeDefaultDescription
annotationsobject{}annotations
affinityobject{}
configFilesobject{"global.cfg": {}, "defaults.cfg": {}, "metrics.cfg": {}}List of haproxy config files
checksumConfigMap.enabledbooltruedoc
dnsPolicystring""docs
dnsConfigobject{}docs
extraVolumeslist[]volumes
extraVolumeMountslist[]
fullnameOverridestring""
image.repositorystringhaproxydocker image to be used
image.tagstring2.2-alpinedocker image tag to be used
image.pullPolicystringIfNotPresentImage pull policy
imagePullSecretslist[]
ingress.annotations."kubernetes.io/ingress.class"string"nginx"
ingress.enabledboolfalseEnable ingress for stats interface
ingress.hoststring"host.example.com"
ingress.pathstring"/"
ingress.portstring"metrics"usually stats port should be exposed
ingress.tlslist[]
livenessProbeobject{}
nameOverridestring""
nodeSelectorobject{}
podAnnotationsobject{}
podSecurityContextobject{}
portsobject{"metrics":{"containerPort":8404,"protocol":"TCP"}}Every port that should be exposed to others apps should be listed here
readinessProbeobject{}
replicaCountint1Number of pods to be deployed
resourcesobject{}resource limits and request for container
securityContextobject{}
service.annotationsobject{}
service.typestring"ClusterIP"
service.clusterIPstring""
service.loadBalancerIPstring""
service.loadBalancerSourceRangeslist[]
serviceAccount.annotationsobject{}
serviceAccount.createbooltrue
serviceMonitor.additionalLabelsobject{}
serviceMonitor.enabledboolfalseIf the operator is installed in your cluster, set to true to create a ServiceMonitor
serviceMonitor.intervalstring"15s"
serviceMonitor.metricsPathstring"/metrics"the path where metrics can be found
serviceMonitor.metricsPortstring"metrics"metrics port defined in ports section. Can be name of port or port itself
serviceMonitor.podTargetLabelslist[]
serviceMonitor.targetLabelslist[]
tolerationslist[]

Default configuration

Default configuration for haproxy:

configFiles:
  global.cfg: |-
    global
      maxconn   10000
      log       127.0.0.1 local0
      nbproc    1
      nbthread  1

  defaults.cfg: |-
    defaults
      backlog   2000
      timeout   connect 10s
      timeout   client 30s
      timeout   server 30s
      timeout   check 10s
      log       global
      mode      tcp
      option    httplog
      maxconn   3000

  metrics.cfg: |-
    frontend metrics
      mode          http
      log           global
      maxconn       10
      bind          *:8404
      option        http-use-htx
      http-request  use-service prometheus-exporter if { path /metrics }
      stats         enable
      stats         uri /
      stats         refresh 10s
      stats         admin if LOCALHOST

Deploy haproxy with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has haproxy on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthaproxy is pinned at v1.4.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply