techno-tim / k3s-ansible

The easiest way to bootstrap a self-hosted High Availability Kubernetes cluster. A fully automated HA k3s etcd install with kube-vip, MetalLB, and more. Build. Destroy. Repeat.
https://technotim.live/posts/k3s-etcd-ansible/
Apache License 2.0
2.41k stars 1.05k forks source link

TASK [k3s/master : Copy vip manifest to first master fails on Ubuntu 22.04/20.04 #83

Closed runbgp closed 2 years ago

runbgp commented 2 years ago

Expected Behavior

The task should proceed. I attempted this both on Ubuntu 22.04 and Ubuntu 20.04 with identical results. The task "Copy vip manifest to first master" fails on both, causing the VIP to never come up.

Current Behavior

TASK [k3s/master : Copy vip rbac manifest to first master] **************************************************************************************************************************************************************************************************
Wednesday 14 September 2022  03:57:30 +0000 (0:00:00.308)       0:00:08.720 *** 
skipping: [10.0.30.22]
skipping: [10.0.30.23]
ok: [10.0.30.21]

TASK [k3s/master : Copy vip manifest to first master] *******************************************************************************************************************************************************************************************************
Wednesday 14 September 2022  03:57:31 +0000 (0:00:00.566)       0:00:09.287 *** 
skipping: [10.0.30.22]
skipping: [10.0.30.23]
[WARNING]: an unexpected error occurred during Jinja2 environment setup: unable to locate collection ansible.utils
fatal: [10.0.30.21]: FAILED! => {"changed": false, "msg": "AnsibleError: template error while templating string: unable to locate collection ansible.utils. String: apiVersion: apps/v1\nkind: DaemonSet\nmetadata:\n  name: kube-vip-ds\n  namespace: kube-system\nspec:\n  selector:\n    matchLabels:\n      name: kube-vip-ds\n  template:\n    metadata:\n      labels:\n        name: kube-vip-ds\n    spec:\n      affinity:\n        nodeAffinity:\n          requiredDuringSchedulingIgnoredDuringExecution:\n            nodeSelectorTerms:\n            - matchExpressions:\n              - key: node-role.kubernetes.io/master\n                operator: Exists\n            - matchExpressions:\n              - key: node-role.kubernetes.io/control-plane\n                operator: Exists\n      containers:\n      - args:\n        - manager\n        env:\n        - name: vip_arp\n          value: \"true\"\n        - name: port\n          value: \"6443\"\n        - name: vip_interface\n          value: {{ flannel_iface }}\n        - name: vip_cidr\n          value: \"{{ apiserver_endpoint | ansible.utils.ipsubnet | ansible.utils.ipaddr('prefix') }}\"\n        - name: cp_enable\n          value: \"true\"\n        - name: cp_namespace\n          value: kube-system\n        - name: vip_ddns\n          value: \"false\"\n        - name: svc_enable\n          value: \"false\"\n        - name: vip_leaderelection\n          value: \"true\"\n        - name: vip_leaseduration\n          value: \"15\"\n        - name: vip_renewdeadline\n          value: \"10\"\n        - name: vip_retryperiod\n          value: \"2\"\n        - name: address\n          value: {{ apiserver_endpoint }}\n        image: ghcr.io/kube-vip/kube-vip:{{ kube_vip_tag_version }}\n        imagePullPolicy: Always\n        name: kube-vip\n        resources: {}\n        securityContext:\n          capabilities:\n            add:\n            - NET_ADMIN\n            - NET_RAW\n            - SYS_TIME\n      hostNetwork: true\n      serviceAccountName: kube-vip\n      tolerations:\n      - effect: NoSchedule\n        operator: Exists\n      - effect: NoExecute\n        operator: Exists\n  updateStrategy: {}\nstatus:\n  currentNumberScheduled: 0\n  desiredNumberScheduled: 0\n  numberMisscheduled: 0\n  numberReady: 0\n"}

TASK [k3s/master : Copy metallb namespace to first master] **************************************************************************************************************************************************************************************************
Wednesday 14 September 2022  03:57:31 +0000 (0:00:00.106)       0:00:09.393 *** 
skipping: [10.0.30.22]
skipping: [10.0.30.23]

Steps to Reproduce

  1. Deploy 5 brand new Ubuntu 22.04/Ubuntu 20.04 VM's using the Ubuntu cloud images & cloud-init.
  2. Configure the appropriate ansible options.
  3. Run the ansible playbook.

Context (variables)

Operating system: Ubuntu 22.04 & Ubuntu 20.04

Hardware: Proxmox VMs running on AMD EPYC CPUs, CPU in host passthrough.

Variables Used

all.yml

k3s_version: v1.25.0+k3s1
# this is the user that has ssh access to these machines
ansible_user: ubuntu
systemd_dir: /etc/systemd/system

system_timezone: "America/Chicago"

flannel_iface: "eth0"

apiserver_endpoint: "10.0.30.40"

k3s_node_ip: '{{ ansible_facts[flannel_iface]["ipv4"]["address"] }}'

extra_args: >-
  --flannel-iface={{ flannel_iface }}
  --node-ip={{ k3s_node_ip }}

extra_server_args: >-
  {{ extra_args }}
  --disable servicelb
  --disable traefik
extra_agent_args: >-
  {{ extra_args }}

kube_vip_tag_version: "v0.5.0"

metal_lb_speaker_tag_version: "v0.13.5"
metal_lb_controller_tag_version: "v0.13.5"

metal_lb_ip_range: "10.0.30.50-10.0.30.60"

Hosts

host.ini

[master]
10.0.30.21
10.0.30.22
10.0.30.23

[node]
10.0.30.31
10.0.30.32

[k3s_cluster:children]
master
node
synosol commented 2 years ago

you need to install ansible.utils with

ansible-galaxy collection install ansible.utils

https://galaxy.ansible.com/ansible/utils

runbgp commented 2 years ago

you need to install ansible.utils with

ansible-galaxy collection install ansible.utils

https://galaxy.ansible.com/ansible/utils

Silly oversight on my end. Worked flawlessly, thank you!

timothystewart6 commented 2 years ago

added docs https://github.com/techno-tim/k3s-ansible/pull/89