generated from edwardtheharris/ansible-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
121 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
abstract: >- | ||
This role creates and installs a Kube-VIP manifest onto all control planes. | ||
authors: | ||
- name: Xander Harris | ||
email: [email protected] | ||
date: 2024-07-24 | ||
title: HA K8S Kube-VIP | ||
--- | ||
|
||
Deployment of HA K8S Clusters with Kubeadm is helped with use of the tool | ||
{term}`kube-vip`. This role uses the static pods version of the network, | ||
which is best for bare metal deployments. | ||
|
||
## Tasks | ||
|
||
This role enables {term}`kube-vip` for cluster networking. This role should | ||
be run after the join role. | ||
|
||
```{literalinclude} /roles/kv/tasks/main.yml | ||
:language: yaml | ||
``` | ||
|
||
```{sectionauthor} Xander Harris <[email protected]> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- 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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,10 @@ | |
- role: join | ||
tags: | ||
- join | ||
- name: Kube VIP | ||
hosts: kcp | ||
become: true | ||
roles: | ||
- role: kv | ||
tags: | ||
- kv |