dyrnq/local-haproxy

By dyrnq

Updated 4 months ago

https://github.com/dyrnq/local-haproxy/

Image
Networking
0

1.6K

dyrnq/local-haproxy repository overview

local-haproxy

use bash and env generate /usr/local/etc/haproxy/local.cfg and append -f /usr/local/etc/haproxy/local.cfg to haproxy

Dockerfile

features

  • keepalived-free
  • update host /etc/hosts if set FQDN and FQDN_IP
  • healthcheck

envs

namedescribedefault
IPfronted ipautodetect
IP_AUTODETECTION_METHODfronted ip autodetectionfirst-found
PORTfronted port8443
FRONTEND_NAMEfronted namefrontend_${PORT}
BACKEND_NAMEbackend namebackend_${PORT}
MODEmodetcp
FRONTEND_MODEfronted mode${MODE}
BACKEND_MODEbackend mode${MODE}
BALANCEbalanceroundrobin
ADV_CHECKadv_checkhttpchk
HTTP_CHECKhttp_checkhttp-check expect status 200
HTTPCHK_PARAMShttpcheck_paramsGET /livez
BACKEND_SERVERbackend_server comma separated
FQDN_IPfqdn_ipautodetect
FQDN_IP_AUTODETECTION_METHODfqdn_ip autodetection${IP_AUTODETECTION_METHOD}
FQDNfqdn
HOSTS_FILEhosts file path/host/etc/hosts
VRRBOSEverbose

run

docker
docker \
run \
-d \
--name local-haproxy \
--restart always \
--privileged \
--network host \
--env "IP_AUTODETECTION_METHOD=interface=eth1" \
--env "BACKEND_SERVER=192.168.55.111:6443 check check-ssl verify none,192.168.55.112:6443 check check-ssl verify none,192.168.55.113:6443 check check-ssl verify none" \
--env "FQDN=demo.local" \
--env "FQDN_IP_AUTODETECTION_METHOD=interface=eth1" \
--volume /etc/hosts:/host/etc/hosts:rw \
dyrnq/local-haproxy:latest
kubernetes static-pod
cat > /etc/kubernetes/manifests/local-haproxy.yaml <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: local-haproxy
  namespace: kube-system
spec:
  hostNetwork: true
  nodeSelector:
    kubernetes.io/os: linux
  containers:
  - name: haproxy
    resources:
      requests:
        cpu: 250m
    image: dyrnq/local-haproxy:latest
    imagePullPolicy: IfNotPresent
    env:
    - name: IP_AUTODETECTION_METHOD
      value: "interface=eth1"
    - name: PORT
      value: "8443"
    - name: BACKEND_SERVER
      value: "192.168.55.111:6443 check check-ssl verify none,192.168.55.112:6443 check check-ssl verify none,192.168.55.113:6443 check check-ssl verify none"
    - name: FQDN
      value: "demo.local"
    volumeMounts:
    - mountPath: /host/etc/hosts
      name: etc-hosts-dir
      readOnly: false
    - mountPath: /etc/localtime
      name: localtime
      readOnly: true
    - mountPath: /usr/local/share/ca-certificates
      name: usr-local-share-ca-certificates
      readOnly: true
    - mountPath: /usr/share/ca-certificates
      name: usr-share-ca-certificates
      readOnly: true
  volumes:
  - hostPath:
      path: /etc/hosts
      type: ""
    name: etc-hosts-dir
  - hostPath:
      path: /etc/localtime
      type: ""
    name: localtime
  - hostPath:
      path: /usr/local/share/ca-certificates
      type: DirectoryOrCreate
    name: usr-local-share-ca-certificates
  - hostPath:
      path: /usr/share/ca-certificates
      type: DirectoryOrCreate
    name: usr-share-ca-certificates
EOF
kubectl logs local-haproxy-master2 -n kube-system
frontend frontend_8443
  mode tcp
  bind 192.168.55.112:8443 name frontend_8443
  default_backend backend_8443


backend backend_8443
  description backend_8443
  mode tcp
  balance roundrobin
  option httpchk GET /livez
  http-check expect status 200
  server server_0 192.168.55.111:6443 check check-ssl verify none
  server server_1 192.168.55.112:6443 check check-ssl verify none
  server server_2 192.168.55.113:6443 check check-ssl verify none
[NOTICE]   (1) : haproxy version is 3.0.2-a45a8e6
[NOTICE]   (1) : path to executable is /usr/local/sbin/haproxy
[WARNING]  (1) : config : parsing [/usr/local/etc/haproxy/haproxy.cfg:46] : 'option httplog' not usable with frontend 'frontend_8443' (needs 'mode http'). Falling back to 'option tcplog'.
[WARNING]  (1) : config : 'option forwardfor' ignored for frontend 'frontend_8443' as it requires HTTP mode.
[WARNING]  (1) : config : 'option forwardfor' ignored for backend 'backend_8443' as it requires HTTP mode.
[NOTICE]   (1) : New worker (29) forked
[NOTICE]   (1) : Loading success.
curl -k https://demo.local:8443/livez

ref

Tag summary

Content type

Image

Digest

sha256:d5f0ffbe0

Size

250.5 MB

Last updated

4 months ago

docker pull dyrnq/local-haproxy:3.0.19