k3s role
parent
63abc810ce
commit
8fe7c11617
|
@ -0,0 +1,28 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
depend() {
|
||||
after network-online
|
||||
want cgroups
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
rm -f /tmp/k3s.*
|
||||
}
|
||||
|
||||
supervisor=supervise-daemon
|
||||
name=k3s
|
||||
command="/usr/local/bin/k3s"
|
||||
command_args="server \
|
||||
>>/var/log/k3s.log 2>&1"
|
||||
|
||||
output_log=/var/log/k3s.log
|
||||
error_log=/var/log/k3s.log
|
||||
|
||||
pidfile="/var/run/k3s.pid"
|
||||
respawn_delay=5
|
||||
respawn_max=0
|
||||
|
||||
set -o allexport
|
||||
if [ -f /etc/environment ]; then source /etc/environment; fi
|
||||
if [ -f /etc/rancher/k3s/k3s.env ]; then source /etc/rancher/k3s/k3s.env; fi
|
||||
set +o allexport
|
|
@ -0,0 +1,70 @@
|
|||
---
|
||||
|
||||
- name: set k3s download suffix
|
||||
set_fact:
|
||||
k3s_suffix: "{{ k3s_suffix_lookup[ansible_architecture] }}"
|
||||
|
||||
- name: download k3s binary
|
||||
get_url:
|
||||
url: "{{ k3s_download_base_url }}/k3s{{ k3s_suffix }}"
|
||||
dest: /usr/local/bin/k3s
|
||||
checksum: "sha256:{{ k3s_download_base_url }}/sha256sum{{ k3s_suffix }}.txt"
|
||||
mode: '0755'
|
||||
|
||||
- name: create k3s symlinks
|
||||
file:
|
||||
state: link
|
||||
src: /usr/local/bin/k3s
|
||||
dest: "/usr/local/bin/{{ item }}"
|
||||
loop:
|
||||
- kubectl
|
||||
- crictl
|
||||
- ctr
|
||||
|
||||
- name: create /etc/rancher/k3s directory
|
||||
file:
|
||||
path: /etc/rancher/k3s
|
||||
state: directory
|
||||
|
||||
- name: create k3s.env
|
||||
file:
|
||||
state: touch
|
||||
path: /etc/rancher/k3s/k3s.env
|
||||
mode: '0600'
|
||||
modification_time: preserve
|
||||
access_time: preserve
|
||||
|
||||
- name: copy service file
|
||||
copy:
|
||||
src: init.d/k3s
|
||||
dest: /etc/init.d
|
||||
mode: '0755'
|
||||
when: ansible_distribution == "Alpine"
|
||||
|
||||
- name: enable and start k3s
|
||||
service:
|
||||
name: k3s
|
||||
state: started
|
||||
enabled: true
|
||||
when: ansible_distribution == "Alpine"
|
||||
|
||||
- name: add cgroup options cmdline.txt
|
||||
replace:
|
||||
path: /media/mmcblk0p1/cmdline.txt
|
||||
regexp: '^([\w](?!.*\b{{ item }}\b).*)$'
|
||||
replace: '\1 {{ item }}'
|
||||
loop:
|
||||
- "cgroup_memory=1"
|
||||
- "cgroup_enable=memory"
|
||||
- "cgroup_enable=cpuset"
|
||||
|
||||
- name: add k3s files to lbu
|
||||
lbu:
|
||||
include:
|
||||
- /usr/local/bin/k3s
|
||||
- /usr/local/bin/kubectl
|
||||
- /usr/local/bin/crictl
|
||||
- /usr/local/bin/ctr
|
||||
- /etc/rancher/k3s/k3s.env
|
||||
- /etc/init.d/k3s
|
||||
when: ansible_distribution == "Alpine" and alpine_mode in ["diskless", "data"]
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
|
||||
# The version for a given channel can be found with
|
||||
#
|
||||
# ```sh
|
||||
# CHANNEL_URL=${CHANNEL_URL:-'https://update.k3s.io/v1-release/channels'}
|
||||
# CHANNEL=${CHANNEL:-'stable'}
|
||||
# curl \
|
||||
# --write-out '%{url_effective}' \
|
||||
# --location \
|
||||
# --silent \
|
||||
# --show-error \
|
||||
# "${CHANNEL_URL}/${CHANNEL}" \
|
||||
# -o /dev/null |
|
||||
# sed -e 's|.*/||'
|
||||
# ```
|
||||
k3s_version: v1.24.6+k3s1
|
||||
|
||||
k3s_suffix_lookup:
|
||||
amd64: ""
|
||||
x86_64: ""
|
||||
arm64: "-arm64"
|
||||
aarch64: "-arm64"
|
||||
armv7l: "-armhf" # any other arm* should be `-armhf` too
|
||||
s390x: "-s390x"
|
||||
|
||||
k3s_releases_url: "https://github.com/k3s-io/k3s/releases/download"
|
||||
|
||||
k3s_download_base_url: "{{ k3s_releases_url }}/{{ k3s_version }}"
|
Loading…
Reference in New Issue