Skip to content

Commit

Permalink
Add Kube VIP to cluster
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
edwardtheharris committed Jul 25, 2024
1 parent 80727e3 commit 52eafa7
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ profile: null
# :end-before: "###\n"
# ```
skip_list:
- command-instead-of-module
- command-instead-of-shell
- loop-var-prefix[missing]
- no-changed-when
Expand Down
Empty file added roles/kv/index.md
Empty file.
54 changes: 54 additions & 0 deletions roles/kv/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
- name: Ensure manifests directory
ansible.builtin.file:
state: directory
recurse: true
dest: /etc/kubernetes/manifests
owner: kube
group: kube
mode: ug+rw,o+r
- name: Install prerequisites for creating the manifest
community.general.pacman:
name: "{{ item }}"
state: present
loop:
- curl
- jq
- name: Fetch the Kube-VIP version
ansible.builtin.shell:
cmd: >-
curl -sL https://api.github.com/repos/kube-vip/kube-vip/releases | jq -r ".[0].name"
register: init_kvv
- name: Output registered value
ansible.builtin.debug:
var: init_kvv.stdout
- name: Check if alias is already defined
ansible.builtin.lineinfile:
state: absent
path: "/root/.bashrc"
regexp: "^alias\ kube-vip="
check_mode: true
changed_when: false # This just makes things look prettier in the logs
register: check
- name: Add an alias to bash rc files.
ansible.builtin.lineinfile:
state: present
path: /root/.bashrc
line: >-
alias kube-vip="ctr image pull ghcr.io/kube-vip/kube-vip:$KVVERSION; ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:$KVVERSION vip /kube-vip"
environment:
KVVERSION: "{{ init_kvv.stdout }}"
when: check.found == 0
- name: Deploy the manifest
ansible.builtin.shell:
cmd: |-
kube-vip manifest pod \
--interface $INTERFACE \
--address $VIP \
--controlplane \
--services \
--arp \
--leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml
environment:
INTERFACE: "{{ kv_interface }}"
KVVERSION: "{{ init_kvv.stdout }}"
VIP: "{{ kv_aa }}"
7 changes: 7 additions & 0 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@
- role: join
tags:
- join
- name: Kube VIP
hosts: kcp
become: true
roles:
- role: kv
tags:
- kv

0 comments on commit 52eafa7

Please sign in to comment.