Browse Source
Add support for kube-vip (#8669)
Add support for kube-vip (#8669)
Signed-off-by: Mathieu Parent <math.parent@gmail.com>pull/8698/head
Mathieu Parent
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 194 additions and 3 deletions
Unified View
Diff Options
-
1docs/_sidebar.md
-
1docs/ansible.md
-
4docs/ha-mode.md
-
52docs/kube-vip.md
-
11roles/download/defaults/main.yml
-
20roles/kubernetes/node/defaults/main.yml
-
6roles/kubernetes/node/tasks/loadbalancer/kube-vip.yml
-
7roles/kubernetes/node/tasks/main.yml
-
93roles/kubernetes/node/templates/manifests/kube-vip.manifest.j2
-
2roles/kubespray-defaults/defaults/main.yaml
@ -0,0 +1,52 @@ |
|||||
|
# kube-vip |
||||
|
|
||||
|
kube-vip provides Kubernetes clusters with a virtual IP and load balancer for both the control plane (for building a highly-available cluster) and Kubernetes Services of type LoadBalancer without relying on any external hardware or software. |
||||
|
|
||||
|
## Install |
||||
|
|
||||
|
You have to explicitly enable the kube-vip extension: |
||||
|
|
||||
|
```yaml |
||||
|
kube_vip_enabled: true |
||||
|
``` |
||||
|
|
||||
|
You also need to enable |
||||
|
[kube-vip as HA, Load Balancer, or both](https://kube-vip.chipzoller.dev/docs/installation/static/#kube-vip-as-ha-load-balancer-or-both): |
||||
|
|
||||
|
```yaml |
||||
|
# HA for control-plane, requires a VIP |
||||
|
kube_vip_controlplane_enabled: true |
||||
|
kube_vip_address: 10.42.42.42 |
||||
|
loadbalancer_apiserver: |
||||
|
address: "{{ kube_vip_address }}" |
||||
|
port: 6443 |
||||
|
# kube_vip_interface: ens160 |
||||
|
|
||||
|
# LoadBalancer for services |
||||
|
kube_vip_services_enabled: false |
||||
|
# kube_vip_services_interface: ens320 |
||||
|
``` |
||||
|
|
||||
|
> Note: When using `kube-vip` as LoadBalancer for services, |
||||
|
[additionnal manual steps](https://kube-vip.chipzoller.dev/docs/usage/cloud-provider/) |
||||
|
are needed. |
||||
|
|
||||
|
If using [ARP mode](https://kube-vip.chipzoller.dev/docs/installation/static/#arp) : |
||||
|
|
||||
|
```yaml |
||||
|
kube_vip_arp_enabled: true |
||||
|
``` |
||||
|
|
||||
|
If using [BGP mode](https://kube-vip.chipzoller.dev/docs/installation/static/#bgp) : |
||||
|
|
||||
|
```yaml |
||||
|
kube_vip_bgp_enabled: true |
||||
|
kube_vip_local_as: 65000 |
||||
|
kube_vip_bgp_routerid: 192.168.0.2 |
||||
|
kube_vip_bgppeers: |
||||
|
- 192.168.0.10:65000::false |
||||
|
- 192.168.0.11:65000::false |
||||
|
# kube_vip_bgp_peeraddress: |
||||
|
# kube_vip_bgp_peerpass: |
||||
|
# kube_vip_bgp_peeras: |
||||
|
``` |
@ -0,0 +1,6 @@ |
|||||
|
--- |
||||
|
- name: kube-vip | Write static pod |
||||
|
template: |
||||
|
src: manifests/kube-vip.manifest.j2 |
||||
|
dest: "{{ kube_manifest_dir }}/kube-vip.yml" |
||||
|
mode: 0640 |
@ -0,0 +1,93 @@ |
|||||
|
# Inspired by https://github.com/kube-vip/kube-vip/blob/v0.4.2/pkg/kubevip/config_generator.go#L13 |
||||
|
apiVersion: v1 |
||||
|
kind: Pod |
||||
|
metadata: |
||||
|
creationTimestamp: null |
||||
|
name: kube-vip |
||||
|
namespace: kube-system |
||||
|
spec: |
||||
|
containers: |
||||
|
- args: |
||||
|
- manager |
||||
|
env: |
||||
|
- name: vip_arp |
||||
|
value: {{ kube_vip_arp_enabled | string | to_json }} |
||||
|
- name: port |
||||
|
value: "6443" |
||||
|
{% if kube_vip_interface %} |
||||
|
- name: vip_interface |
||||
|
value: "{{ kube_vip_interface | string | to_json }}" |
||||
|
{% endif %} |
||||
|
{% if kube_vip_services_interface %} |
||||
|
- name: vip_servicesinterface |
||||
|
value: {{ kube_vip_services_interface | string | to_json }} |
||||
|
{% endif %} |
||||
|
{% if kube_vip_cidr %} |
||||
|
- name: vip_cidr |
||||
|
value: {{ kube_vip_cidr | string | to_json }} |
||||
|
{% endif %} |
||||
|
{% if kube_vip_controlplane_enabled %} |
||||
|
- name: cp_enable |
||||
|
value: "true" |
||||
|
- name: cp_namespace |
||||
|
value: kube-system |
||||
|
- name: vip_ddns |
||||
|
value: {{ kube_vip_ddns_enabled | string | to_json }} |
||||
|
{% endif %} |
||||
|
{% if kube_vip_services_enabled %} |
||||
|
- name: svc_enable |
||||
|
value: "true" |
||||
|
{% endif %} |
||||
|
{% if kube_vip_leader_election_enabled %} |
||||
|
- name: vip_leaderelection |
||||
|
value: "true" |
||||
|
- name: vip_leaseduration |
||||
|
value: "5" |
||||
|
- name: vip_renewdeadline |
||||
|
value: "3" |
||||
|
- name: vip_retryperiod |
||||
|
value: "1" |
||||
|
{% endif %} |
||||
|
{% if kube_vip_bgp_enabled %} |
||||
|
- name: bgp_enable |
||||
|
value: "true" |
||||
|
- name: bgp_routerid |
||||
|
value: {{ kube_vip_bgp_routerid | string | to_json }} |
||||
|
- name: bgp_as |
||||
|
value: {{ kube_vip_local_as | string | to_json }} |
||||
|
- name: bgp_peeraddress |
||||
|
value: {{ kube_vip_bgp_peeraddress | to_json }} |
||||
|
- name: bgp_peerpass |
||||
|
value: {{ kube_vip_bgp_peerpass | to_json }} |
||||
|
- name: bgp_peeras |
||||
|
value: {{ kube_vip_bgp_peeras | to_json }} |
||||
|
{% if kube_vip_bgppeers %} |
||||
|
- name: bgp_peers |
||||
|
value: {{ kube_vip_bgp_peeras | join(',') | to_json }} |
||||
|
{% endif %} |
||||
|
{% endif %} |
||||
|
- name: address |
||||
|
value: {{ kube_vip_address | to_json }} |
||||
|
image: {{ kube_vip_image_repo }}:{{ kube_vip_image_tag }} |
||||
|
imagePullPolicy: {{ k8s_image_pull_policy }} |
||||
|
name: kube-vip |
||||
|
resources: {} |
||||
|
securityContext: |
||||
|
capabilities: |
||||
|
add: |
||||
|
- NET_ADMIN |
||||
|
- NET_RAW |
||||
|
volumeMounts: |
||||
|
- mountPath: /etc/kubernetes/admin.conf |
||||
|
name: kubeconfig |
||||
|
hostAliases: |
||||
|
- hostnames: |
||||
|
- kubernetes |
||||
|
ip: 127.0.0.1 |
||||
|
hostNetwork: true |
||||
|
volumes: |
||||
|
- hostPath: |
||||
|
path: /etc/kubernetes/admin.conf |
||||
|
name: kubeconfig |
||||
|
status: {} |
||||
|
|
Write
Preview
Loading…
Cancel
Save