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

View File

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