Avoid kube-vip;Reduce clustersize
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Danny Bessems 2022-04-29 11:55:51 +02:00
parent 6bfed584b0
commit 215586ddb5
2 changed files with 40 additions and 38 deletions

View File

@ -108,7 +108,8 @@
- name: Initial node -- Install K3s binary
ansible.builtin.shell:
cmd: "curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage --tls-san {{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
cmd: curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage
# cmd: "curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage --tls-san {{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
- name: Initial node -- Retrieve token
ansible.builtin.slurp:
@ -124,41 +125,41 @@
ansible.builtin.set_fact:
cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) }, { 'kubeconfig': ( k3s_kubeconfig.stdout ) } ) }}"
- block:
# - block:
- name: Install 'kube-vip' -- Retrieve RBAC-manifest
ansible.builtin.uri:
url: https://kube-vip.io/manifests/rbac.yaml
return_content: yes
register: manifest_rbac
# - name: Install 'kube-vip' -- Retrieve RBAC-manifest
# ansible.builtin.uri:
# url: https://kube-vip.io/manifests/rbac.yaml
# return_content: yes
# register: manifest_rbac
- name: Install 'kube-vip' -- Pull image
ansible.builtin.shell:
cmd: ctr image pull ghcr.io/kube-vip/kube-vip:latest
# - name: Install 'kube-vip' -- Pull image
# ansible.builtin.shell:
# cmd: ctr image pull ghcr.io/kube-vip/kube-vip:latest
- name: Install 'kube-vip' -- Generate daemonSet-manifest
ansible.builtin.shell:
cmd: "ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:latest vip /kube-vip manifest daemonset --interface {{ ansible_default_ipv4.interface }} --address {{ cluster.virtualip | ansible.utils.ipaddr('address') }} --inCluster --taint --controlplane --services --arp --leaderElection"
register: manifest_daemonset
# - name: Install 'kube-vip' -- Generate daemonSet-manifest
# ansible.builtin.shell:
# cmd: "ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:latest vip /kube-vip manifest daemonset --interface {{ ansible_default_ipv4.interface }} --address {{ cluster.virtualip | ansible.utils.ipaddr('address') }} --inCluster --taint --controlplane --services --arp --leaderElection"
# register: manifest_daemonset
- name: Install 'kube-vip' -- Inject manifest
ansible.builtin.template:
src: kube-vip.j2
dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml
# - name: Install 'kube-vip' -- Inject manifest
# ansible.builtin.template:
# src: kube-vip.j2
# dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml
delegate_to: "{{ ansible_play_hosts[0] }}"
run_once: true
# delegate_to: "{{ ansible_play_hosts[0] }}"
# run_once: true
- name: All nodes -- Ensure API availability
ansible.utils.cli_parse:
command: "curl -k https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443/livez?verbose"
parser:
name: ansible.utils.json
set_fact: api_readycheck
ignore_errors: yes
until: api_readycheck.apiVersion is defined
retries: 3
delay: 30
# - name: All nodes -- Ensure API availability
# ansible.utils.cli_parse:
# command: "curl -k https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443/livez?verbose"
# parser:
# name: ansible.utils.json
# set_fact: api_readycheck
# ignore_errors: yes
# until: api_readycheck.apiVersion is defined
# retries: 3
# delay: 30
- block:
@ -193,13 +194,13 @@
dest: "{{ kubeconfig.path }}"
content: "{{ ( lookup('dict', hostvars) )[0].value.cluster.kubeconfig }}"
mode: 0600
- ansible.builtin.debug:
msg: "{{ servers[0].ip | ansible.utils.ipaddr('address') }}"
- name: Replace API url
ansible.builtin.replace:
path: "{{ kubeconfig.path }}"
regexp: 'server: https:\/\/127\.0\.0\.1:6443$'
replace: "server: https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443"
replace: "server: https://{{ servers[0].ip | ansible.utils.ipaddr('address') }}:6443"
# replace: "server: https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443"
- name: Add Helm chart repositories
kubernetes.core.helm_repository:
@ -214,7 +215,7 @@
chart_ref: "{{ item.ref }}"
namespace: "{{ item.namespace }}"
create_namespace: yes
wait: yes
# wait: yes
kubeconfig: "{{ kubeconfig.path }}"
values: "{{ item.setvalues | default(omit) }}"
loop: "{{ helm.charts }}"

View File

@ -1,7 +1,7 @@
---
cluster:
name: k3s-dev
virtualip: 192.168.11.120/24
# virtualip: 192.168.11.120/24
image:
deployment_option: large
ova_url: sn.itch.fyi/Repository/rel/Ubuntu-Server-20.04.ova
@ -10,6 +10,7 @@ network:
dnsserver: 192.168.11.220
gateway: 192.168.11.1
servers:
- ip: 192.168.11.121/24
- ip: 192.168.11.122/24
- ip: 192.168.11.123/24
- ip: 192.168.11.120/24
# - ip: 192.168.11.121/24
# - ip: 192.168.11.122/24
# - ip: 192.168.11.123/24