PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
627 stars 135 forks source link

Alpine support / help #182

Closed TobiasS1402 closed 2 years ago

TobiasS1402 commented 2 years ago

Summary

Are you planning on implementing Alpine Linux support, or can you help me hack the repository to make it work with OpenRC instead of systemd?

Issue Type

Additional Information

My current install fails with not being able to start the service, when running the curl -sfL https://get.k3s.io | sh - script from k3s.io it does check if systemd is there, or else it will use OpenRC to create the services and stuff.

Failing:

TASK [xanmanning.k3s : Check that the initial control plane server is available to accept connections] ***************************************************************************************
fatal: [gaia]: FAILED! => {"changed": false, "elapsed": 300, "msg": "Timeout when waiting for 127.0.0.1:6443"}

TASK [xanmanning.k3s : Ensure cluster token is captured from gaia] ***************************************************************************************************************************
fatal: [atlas -> gaia]: FAILED! => {"changed": false, "msg": "file not found: /var/lib/rancher/k3s/server/token"}
fatal: [hecate -> gaia]: FAILED! => {"changed": false, "msg": "file not found: /var/lib/rancher/k3s/server/token"}
fatal: [helios -> gaia]: FAILED! => {"changed": false, "msg": "file not found: /var/lib/rancher/k3s/server/token"}

Default k3s install:

helios:~$ curl -sfL https://get.k3s.io | sudo sh -
[INFO]  Finding release for channel stable
[INFO]  Using v1.22.7+k3s1 as release
[INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.22.7+k3s1/sha256sum-amd64.txt
[INFO]  Skipping binary downloaded, installed k3s matches hash
[INFO]  Skipping installation of SELinux RPM
[INFO]  Skipping /usr/local/bin/kubectl symlink to k3s, already exists
[INFO]  Skipping /usr/local/bin/crictl symlink to k3s, already exists
[INFO]  Skipping /usr/local/bin/ctr symlink to k3s, already exists
[INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
[INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO]  env: Creating environment file /etc/rancher/k3s/k3s.env
[INFO]  openrc: Creating service file /etc/init.d/k3s
[INFO]  openrc: Enabling k3s service for default runlevel
[INFO]  openrc: Starting k3s
 * Caching service dependencies ...                                                                                                                                                     [ ok ]
 * Mounting cgroup filesystem ...                                                                                                                                                       [ ok ]
 * Starting k3s ...
TobiasS1402 commented 2 years ago

I tried to install the role in the feat/alpine-support branch, it works like a charm except for one issue.

TASK [xanmanning.k3s : include_tasks] *******************************************************************************************************************************************
fatal: [gaia]: FAILED! => {"reason": "Could not find or access '/home/tobias/kubernetes-playground/ensure_control_plane_started_openrc.yml' on the Ansible Controller."}
fatal: [atlas]: FAILED! => {"reason": "Could not find or access '/home/tobias/kubernetes-playground/ensure_control_plane_started_openrc.yml' on the Ansible Controller."}
fatal: [hecate]: FAILED! => {"reason": "Could not find or access '/home/tobias/kubernetes-playground/ensure_control_plane_started_openrc.yml' on the Ansible Controller."}
fatal: [helios]: FAILED! => {"reason": "Could not find or access '/home/tobias/kubernetes-playground/ensure_control_plane_started_openrc.yml' on the Ansible Controller."}

It is looking for include_tasks: ensure_control_plane_started_{{ ansible_service_mgr }}.yml and searched for openrc, while the yaml file you created is called ensure_control_plane_started_sysvinit.yml. I tried to hardcode this locally inside the Role and this works like a charm. Thanks!👍

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.