All Projects → penglongli → haproxy-keepalived

penglongli / haproxy-keepalived

Licence: MIT License
HAProxy & Keepalived for Docker and kubernetes

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to haproxy-keepalived

consul-vault
HashiCorp Vault service running on Consul cluster backend with HAProxy frontend
Stars: ✭ 27 (-6.9%)
Mutual labels:  haproxy, keepalived
gafka
A full ecosystem that is built around kafka powered by golang
Stars: ✭ 96 (+231.03%)
Mutual labels:  haproxy
keepalived-formula
docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Stars: ✭ 13 (-55.17%)
Mutual labels:  keepalived
swarm-router
Scalable stateless «zero config» service-name ingress for docker swarm mode with a fresh more secure approach
Stars: ✭ 58 (+100%)
Mutual labels:  haproxy
torpool
Containerized pool of multiple Tor instances with load balancing and HTTP proxy.
Stars: ✭ 42 (+44.83%)
Mutual labels:  haproxy
micro-service-practice
OpenStack+Docker+RestAPI+OAuth/HMAC+RabbitMQ/ZMQ+OpenResty/HAProxy/Nginx/APIGateway+Bootstrap/AngularJS+Ansible+K8S/Mesos/Marathon构建/探索微服务最佳实践。
Stars: ✭ 25 (-13.79%)
Mutual labels:  haproxy
rabbitmq-cluster-docker-compose
No description or website provided.
Stars: ✭ 24 (-17.24%)
Mutual labels:  haproxy
capistrano-docker-compose
Docker Compose specific tasks for Capistrano
Stars: ✭ 17 (-41.38%)
Mutual labels:  haproxy
keepalived
Alpine based container for keepalived
Stars: ✭ 38 (+31.03%)
Mutual labels:  keepalived
ansible-haproxy
Installs and configures HAProxy
Stars: ✭ 19 (-34.48%)
Mutual labels:  haproxy
kube-template
Watches Kubernetes for updates, writing output of a series of templates to files
Stars: ✭ 27 (-6.9%)
Mutual labels:  haproxy
letsencrypt-dcos
Let's Encrypt DC/OS!
Stars: ✭ 39 (+34.48%)
Mutual labels:  haproxy
one-wsap
Образ Apache 2.4 + веб-сервисы/веб-клиент 1С. Автоматическое конфигурирование дескрипторов из каталога. HAProxy.
Stars: ✭ 15 (-48.28%)
Mutual labels:  haproxy
docker-redis-haproxy-cluster
A Redis Replication Cluster accessible through HAProxy running across a Docker Composed-Swarm with Supervisor and Sentinel
Stars: ✭ 44 (+51.72%)
Mutual labels:  haproxy
ansible-haproxy
Ansible HAproxy role for Unified OpenStack Installer and others.
Stars: ✭ 35 (+20.69%)
Mutual labels:  haproxy
esa-httpclient
An asynchronous event-driven HTTP client based on netty.
Stars: ✭ 82 (+182.76%)
Mutual labels:  haproxy
ptw
Pooling TLS Wrapper
Stars: ✭ 20 (-31.03%)
Mutual labels:  haproxy
charts
HAProxy Ingress helm charts
Stars: ✭ 24 (-17.24%)
Mutual labels:  haproxy
ansible-pihole
Bootstrap a Raspberry Pi with Ansible and install Docker + Pi-hole
Stars: ✭ 52 (+79.31%)
Mutual labels:  keepalived
pyhaproxy
Python library to parse haproxy configurations
Stars: ✭ 50 (+72.41%)
Mutual labels:  haproxy

haproxy-keepalived [v1.0.0]

中文

Refactored, make it great again. And add support for Kubernetes

HAProxy with Keepalived for Docker and Kubernetes

DockerHub: https://hub.docker.com/r/pelin/haproxy-keepalived/

Version HAProxy Keepalived
v1.0.0 v2.3.4 v1.3.9

For Docker

For Docker, you need to set HAProxy and Keepalived config file in host.

Below is an example, you should change Keepalived.conf for yourself.

~$ cat /root/haproxy-keepalived/haproxy/haproxy.cfg
global
    daemon
    maxconn 30000
    log 127.0.0.1 local0 debug

defaults
    log global
    option tcplog
    maxconn 30000
    timeout connect 30000
    timeout client 1800000
    timeout server 1800000
    timeout check 1000
    log-format %ci\ [id=%ID]\ [%t]\ %f\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ {%hrl}\ {%hsl}\ %{+Q}r

listen test
    bind *:6666
    mode http
    maxconn 10000
    balance roundrobin
    server server1 127.0.0.1:1080 maxconn 10000 check

listen stats
    bind *:1080
    mode http
    stats refresh 30s
    stats uri /stats

~$ cat /root/haproxy-keepalived/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state MASTER                 # Keepalived state.
    interface eth0               # Please replace this interface for yourself
    virtual_router_id 40         # Please replace this id for yourself
    priority 110                 # Please replace this value for yourself
    virtual_ipaddress {
        172.20.10.16             # Please replace this VIP for yourself
    }
    nopreempt
}

And then, you can run a container with Docker

docker run -it -d --name haproxy-keepalived --net=host --privileged \
    -v /root/haproxy-keepalived/haproxy/:/usr/local/etc/haproxy/ \
    -v /root/haproxy-keepalived/keepalived/:/etc/keepalived/ \
    pelin/haproxy-keepalived:v1.0.0

You can use docker logs -f haproxy-keepalived to see if any errors has occurred.

If everything is ok, you can ping 172.20.10.16.

After start the first node, you can change keepalived.conf and start another node.

For Kubernetes

If you want it for Kubernetes, you should confirm that the Keepalived config is different between nodes.

There is an example in deploy/kubernetes

You can see the data of keepalived-conf ConfigMap is dynamic with NODE_NAME

---
...
metadata:
  name: keepalived-conf
  namespace: default
data:
  keepalived.conf-localhost.localdomain: |    # The name is dynamic with NODE_NAME
...

In daemonset.yaml, the volumeMount subPath is dynamic with NODE_NAME too.

volumeMounts:
  - name: keepalivedconf
    mountPath: /etc/keepalived/keepalived.conf
    subPathExpr: keepalived.conf-$(NODE_NAME)        # The subpath is dynamic

Dynamic Reload HAProxy

Users can reload HAProxy in trhee ways as below

OS Signal

We can change HAProxy config with ConfigMap(Kubernetes) or HostFile(Docker)

If config is changed, user can use the below command to reload HAProxy:

docker kill -s HUP haproxy-keepalived

Reload Command

Exec to the container, and then reload.

[root@localhost ~]# kubectl exec -it haproxy-keepalived-6zrjz sh
/ # /haproxy-keepalived reload
I0122 23:38:40.769526      36 server.go:79] HAProxy Reloaded.
/ #

Kill Signal

Exec to the container, and execute the velow command:

kill -SIGUSR2 $(pidof haproxy)

Logging

The HAProxy log path: /var/log/haproxy.log

Discuss

If you have some problem about useage or some suggestion, welcome to create an ISSUE

LICENSE

Based on MIT LICENSE

You can fork it or reference it for custom your own haproxy-keepalived image.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].