-
-
Notifications
You must be signed in to change notification settings - Fork 32
[WIP] refactor haproxy role #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,23 @@ | ||
| --- | ||
| # This role implements the Software Load Balancing approach described at this location | ||
| # https://github.com/kubernetes/kubeadm/blob/master/docs/ha-considerations.md#options-for-software-load-balancing | ||
| --- | ||
| - name: 'haproxy | preflight checks' | ||
| - name: 'preflight checks' | ||
| ansible.builtin.include_tasks: 'pre_checks.yml' | ||
|
|
||
| - name: configure necessary keepalived sysctl configuration | ||
| - name: 'configure necessary haproxy sysctl configuration' | ||
| ansible.builtin.sysctl: | ||
| name: 'net.ipv4.ip_nonlocal_bind' | ||
| value: 1 | ||
| value: '1' | ||
| state: 'present' | ||
| sysctl_file: '/etc/sysctl.d/55-haproxy.conf' | ||
| sysctl_set: true | ||
|
|
||
| - name: 'haproxy | configure haproxy on control plane nodes' | ||
| - name: 'packages | configure haproxy on control plane nodes' | ||
| ansible.builtin.include_tasks: 'packages.yml' | ||
| when: | ||
| - haproxy_install_mode == 'package' | ||
|
|
||
| - name: 'haproxy | configure haproxy as a static pod within the cluster' | ||
| - name: 'manifests | configure haproxy as a static pod within the cluster' | ||
| ansible.builtin.include_tasks: 'manifests.yml' | ||
| when: | ||
| - haproxy_install_mode == 'manifest' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| --- | ||
| - name: 'validate variable : keepalived_vip' | ||
| assert: | ||
| ansible.builtin.assert: | ||
| that: | ||
| - keepalived_vip | ipaddr | ||
| fail_msg: | ||
| - "Variable 'keepalived_vip' should be a valid ip address" | ||
| - 'Variable "keepalived_vip" should be a valid ip address' | ||
| - 'Type is: {{ keepalived_vip | type_debug }}' | ||
| - "Value is: {{ keepalived_vip | default('undefined') }}" | ||
| - 'Value is: {{ keepalived_vip | default("undefined") }}' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,59 @@ | ||
| #################### | ||
| # api-proxy config # | ||
| #################### | ||
| {{ ansible_managed | comment }} | ||
|
|
||
| frontend front-api-proxy | ||
| bind {{ keepalived_vip }}:8443 | ||
| bind 127.0.0.1:8443 | ||
| # This configuration provides some sensible defaults - modeled on the default configuration found here | ||
| # https://github.com/haproxytech/haproxy-docker-alpine/blob/master/2.3/haproxy.cfg | ||
| global | ||
| log stdout format raw local0 | ||
| stats socket /var/run/haproxy.stat | ||
| user haproxy | ||
| group haproxy | ||
| chroot /var/empty | ||
| daemon | ||
|
|
||
| defaults | ||
| mode http | ||
| log global | ||
| option httplog | ||
| option dontlognull | ||
| option http-server-close | ||
| option redispatch | ||
| retries 5 | ||
| timeout http-request 5m | ||
| timeout queue 5m | ||
| timeout connect 30s | ||
| timeout client {{ haproxy_keepalive_timeout }} | ||
| timeout server 15m | ||
| timeout http-keep-alive 30s | ||
| timeout check 30s | ||
| maxconn 4000 | ||
|
|
||
| frontend stats | ||
| bind *:8404 | ||
| mode http | ||
| stats enable | ||
| stats uri /stats | ||
| stats refresh 10s | ||
| stats admin if TRUE | ||
|
|
||
| {% if haproxy_healthcheck_port is defined -%} | ||
| frontend healthz | ||
| bind *:{{ haproxy_healthcheck_port }} | ||
| mode http | ||
| monitor-uri /healthz | ||
| {% endif -%} | ||
|
|
||
| frontend apiserver | ||
| bind {{ cluster_apiserver_frontend_ip }}:{{ cluster_apiserver_frontend_port }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| mode tcp | ||
| option tcplog | ||
| timeout client 4h | ||
| default_backend kube-api | ||
| default_backend apiserver | ||
|
|
||
| backend kube-api | ||
| backend apiserver | ||
| mode tcp | ||
| option tcplog | ||
| option tcp-check | ||
| timeout connect 10s | ||
| timeout server 4h | ||
| balance roundrobin | ||
| default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100 | ||
| {% for host in groups['masters'] %} | ||
| server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_host'] }}:6443 check | ||
| {% endfor %} | ||
| balance leastconn | ||
| default-server inter 15s downinter 15s rise 2 fall 2 slowstart 60s maxconn 1000 maxqueue 256 weight 100 | ||
| option httpchk GET /healthz | ||
| http-check expect status 200 | ||
| {% for host in groups['controlplane'] -%} | ||
| server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_default_ipv4'].address }}:{{ cluster_apiserver_port }} check check-ssl verify none | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| {% endfor -%} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cluster_kubernetes_manifests_pathisn't being initialized in defaults or the group vars