Update k3s role to allow for multiple clusters

This commit is contained in:
Amarpreet Minhas 2022-11-23 00:43:04 -05:00
parent 6251f33740
commit d68fefe9a4
7 changed files with 16 additions and 2 deletions

View file

@ -5,3 +5,4 @@ nomad_arch: arm64
docker_arch: arm64 docker_arch: arm64
k3s_version: v1.24.1+k3s1 k3s_version: v1.24.1+k3s1
k3s_role: 'client' k3s_role: 'client'
k3s_server_hostname: hardtack1.minhas.io

View file

@ -1,3 +1,6 @@
--- ---
hashi_arch: arm hashi_arch: arm
consul_arch: arm64 consul_arch: arm64
k3s_version: v1.25.4+k3s1
k3s_role: 'client'
k3s_server_hostname: teapot01.minhas.io

View file

@ -0,0 +1,3 @@
---
k3s_role: server
...

View file

@ -22,6 +22,7 @@ teapot[01:06].minhas.io
[k3s] [k3s]
hardtack[1:7].minhas.io hardtack[1:7].minhas.io
teapot[01:06].minhas.io
[lnd] [lnd]
redwingcherokee.minhas.io redwingcherokee.minhas.io

View file

@ -23,6 +23,7 @@
- kitty-terminfo - kitty-terminfo
- make - make
- ncdu - ncdu
- neovim
- netcat-openbsd - netcat-openbsd
- ntp - ntp
- screen - screen
@ -31,7 +32,6 @@
- tmux - tmux
- tree - tree
- unzip - unzip
- vim
state: present state: present
- name: apt autoremove - name: apt autoremove

View file

@ -22,4 +22,10 @@
- name: set k3s token var - name: set k3s token var
set_fact: set_fact:
k3s_node_token: "{{ registered_k3s_node_token.content | b64decode | trim }}" k3s_node_token: "{{ registered_k3s_node_token.content | b64decode | trim }}"
- name: set kubectl symlink
file:
state: link
src: /usr/local/bin/k3s
dest: /usr/local/bin/kubectl
... ...

View file

@ -8,7 +8,7 @@ ExecReload=/bin/kill -HUP $MAINPID
{% if k3s_role == 'server' %} {% if k3s_role == 'server' %}
ExecStart=/usr/local/bin/k3s server --write-kubeconfig-mode 644 --disable servicelb --disable traefik ExecStart=/usr/local/bin/k3s server --write-kubeconfig-mode 644 --disable servicelb --disable traefik
{% else %} {% else %}
ExecStart=/usr/local/bin/k3s agent --server https://hardtack1.minhas.io:6443 --token {{ hostvars['hardtack1.minhas.io'].k3s_node_token }} ExecStart=/usr/local/bin/k3s agent --server https://{{ k3s_server_hostname }}:6443 --token {{ hostvars[k3s_server_hostname].k3s_node_token }}
{% endif %} {% endif %}
KillMode=process KillMode=process
KillSignal=SIGINT KillSignal=SIGINT