Skip to content

Commit

Permalink
Fix kube-vip bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaser committed Oct 14, 2024
1 parent e828df9 commit 64c0f3c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions roles/kube_vip/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.

# Inventory group containing controllers
kube_vip_control_plane_group: "{{ kubernetes_control_plane_group | default('controllers') }}"

# Image to use for kube-vip
kube_vip_image: ghcr.io/kube-vip/kube-vip:v0.6.4

Expand Down
26 changes: 26 additions & 0 deletions roles/kube_vip/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@
notify:
- Restart "kubelet" service

- name: Check if super-admin.conf exists
ansible.builtin.stat:
path: /etc/kubernetes/super-admin.conf
failed_when: false
changed_when: false
register: kube_vip_stat_super_admin

- name: Check if kubeadm has already run
ansible.builtin.stat:
path: /var/lib/kubelet/config.yaml
get_attributes: false
get_checksum: false
get_mime: false
register: kube_vip_stat_kubelet_config

- name: Set fact with KUBECONFIG path
ansible.builtin.set_fact:
kube_vip_kubeconfig_path: /etc/kubernetes/admin.conf

- name: Set fact with KUBECONFIG path (with super-admin.conf)
ansible.builtin.set_fact:
kube_vip_kubeconfig_path: /etc/kubernetes/super-admin.conf
when:
- inventory_hostname == groups[kube_vip_control_plane_group] | first
- (kube_vip_stat_super_admin.stat.exists and kube_vip_stat_super_admin.stat.isreg) or (not kube_vip_stat_kubelet_config.stat.exists)

- name: Upload Kubernetes manifest
ansible.builtin.template:
src: kube-vip.yaml.j2
Expand Down
2 changes: 1 addition & 1 deletion roles/kube_vip/templates/kube-vip.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ spec:
hostNetwork: true
volumes:
- hostPath:
path: /etc/kubernetes/admin.conf
path: "{{ kube_vip_kubeconfig_path }}"
name: kubeconfig
status: {}

0 comments on commit 64c0f3c

Please sign in to comment.