Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

WIP: Add the environment variable config mode #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions playbooks/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
---
- hosts: masters
tasks:
- name: Create kube-vip config directory
file:
path: /etc/kube-vip
state: directory
mode: 0755
- name: Initalize config variables
set_fact:
kube_vip_config_mode: "{{ kube_vip_config_mode | default('file') }}"
kube_vip_port: "{{ kube_vip_port | default(10000) }}"

- name: Write kube-vip config file"
template:
src: ../templates/config.yaml.j2
dest: /etc/kube-vip/config.yaml
- when: kube_vip_config_mode == "file"
block:
- name: Create kube-vip config directory
file:
path: /etc/kube-vip
state: directory
mode: 0755

- name: Write kube-vip config file
template:
src: ../templates/config.yaml.j2
dest: /etc/kube-vip/config.yaml

- name: Create kubelet static pod manifest directory
file:
Expand Down
33 changes: 33 additions & 0 deletions templates/kube-vip.yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,54 @@ spec:
containers:
- args:
- start
{% if kube_vip_config_mode == "file" %}
- -c
- /etc/kube-vip/config.yaml
{% endif %}
{% if kube_vip_config_mode == "env" %}
env:
- name: vip_localpeer
value: "{{ inventory_hostname }}:{{ ansible_default_ipv4.address }}:{{ kube_vip_port | default(10000) }}"
- name: vip_remotepeers
value: "{% for name in groups.masters | difference(inventory_hostname) %}{{ name }}:{{ hostvars[name].ansible_default_ipv4.address }}:{{ kube_vip_port | default(10000) }}{% if not loop.last %},{% endif %}{% endfor %}"
- name: vip_address
value: "{{ kube_vip_vip_address_ipv4 | default('') }}"
- name: vip_arp
value: "{{ kube_vip_gratuitous_arp | default('false') }}"
- name: vip_singenode
value: "false"
- name: vip_startleader
value: "{{ inventory_hostname == groups.masters.0 | ternary('true', 'false') }}"
- name: vip_interface
value: "{{ ansible_default_ipv4.interface }}"
- name: lb_name
value: "OpenShift Control Plane"
- name: lb_type
value: "tcp"
- name: lb_port
value: "9443"
- name: lb_bindtovip
value: "true"
- name: lb_backends
value: "{% for name in [inventory_hostname] + (groups.masters | difference(inventory_hostname)) %}{{ name }}:{{ hostvars[name].ansible_default_ipv4.address }}:8443{% if not loop.last %},{% endif %}{% endfor %}"
{% endif %}
image: docker.io/plndr/kube-vip:0.1.5
name: kube-vip
securityContext:
capabilities:
add:
- NET_ADMIN
- SYS_TIME
{% if kube_vip_config_mode == "file" %}
volumeMounts:
- mountPath: /etc/kube-vip/
name: config
{% endif %}
hostNetwork: true
priorityClassName: system-node-critical
{% if kube_vip_config_mode == "file" %}
volumes:
- hostPath:
path: /etc/kube-vip/
name: config
{% endif %}