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.
Merge pull request #12 from edwardtheharris/11-integrate-kube-vip
Add Kube VIP to cluster Closes #11
- Loading branch information
Showing
12 changed files
with
171 additions
and
21 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
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,39 @@ | ||
--- | ||
- 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: Update the bash rc file | ||
ansible.builtin.template: | ||
src: bashrc.j2 | ||
dest: /root/.bashrc | ||
owner: root | ||
group: root | ||
mode: ug+rw,o-rwx | ||
- name: Deploy the manifest | ||
ansible.builtin.shell: | ||
cmd: |- | ||
source /root/.bashrc | ||
kube-vip | ||
kube-vip manifest pod \ | ||
--interface "{{ kv_interface }}" \ | ||
--address "{{ kv_aa }}" \ | ||
--controlplane \ | ||
--services \ | ||
--arp \ | ||
--leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml | ||
register: kv_manifest | ||
- name: Output kube-vip | ||
ansible.builtin.debug: | ||
var: kv_manifest |
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,62 @@ | ||
#!/bin/bash | ||
|
||
CLICOLOR=1 | ||
INTERFACE=enp0s20f0u4 | ||
KVVERSION=$(curl -sL https://api.github.com/repos/kube-vip/kube-vip/releases | jq -r ".[0].name") | ||
# shellcheck disable=SC2016 | ||
LESS='-R --use-color -Dd+r$Du+b$' | ||
LSCOLORS="Ea" | ||
PS1='[\[\e[38;5;196;1m\]\u\[\e[0m\]@\[\e[38;5;213;1m\]\H\[\e[0m\]:\w]{$?}\$ ' | ||
PATH="$PATH:/root/.local/bin" | ||
VIP=192.168.5.30 | ||
|
||
# shellcheck disable=SC1091 | ||
if [ -f /usr/share/bash-completion/bash_completion ]; then | ||
source /usr/share/bash-completion/bash_completion | ||
fi | ||
|
||
export CLICOLOR | ||
export INTERFACE | ||
export KVVERSION | ||
export LESS | ||
export LSCOLORS | ||
export PATH | ||
export PS1 | ||
export VIP | ||
|
||
|
||
if [ ! -f "$HOME/.vim/autoload/plug.vim" ]; then | ||
if [ -f /usr/bin/pacman ]; then | ||
if [ ! -f /usr/bin/node ]; then | ||
pacman -S npm | ||
fi | ||
if [ ! -f /usr/bin/xsel ]; then | ||
pacman -Sy --noconfirm xsel | ||
fi | ||
|
||
if [ -f /usr/bin/xsel ]; then | ||
alias pbcopy='xsel --clipboard --input' | ||
alias pbpaste='xsel --clipboard --output' | ||
fi | ||
fi | ||
if [ -f /usr/bin/apt-get ]; then | ||
sudo apt-get -y update | ||
sudo apt-get -y install curl git npm | ||
fi | ||
git clone [email protected]:bryant/neovim.git "$HOME/Documents/src/github.com/bryant/neovim" | ||
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ | ||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | ||
vim +PlugInstall +qall | ||
fi | ||
|
||
eval "$(direnv hook bash)" | ||
|
||
alias diff='diff --color=auto' | ||
alias grep='grep --color=auto' | ||
alias h='helm' | ||
alias ip='ip -color=auto' | ||
alias k='kubectl' | ||
# shellcheck disable=SC2139 | ||
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" | ||
alias ls='ls --color' | ||
|
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: kcp01_init | ||
become: true | ||
roles: | ||
- role: kv | ||
tags: | ||
- kv |