Create the k3s package using the upstream installer script (#335)

* Create the k3s package using the upstream installer script

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Move provider to different category and fix k3s

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Add 3 versions of k3s

Though the autobumper will be confused:
https://github.com/kairos-io/kairos/issues/1624

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Fix how we set up env vars

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Fix the k3s building script

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Build the requisted k3s version

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Remove checksum checks because the scripts already handles that

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Fix usage of "default" function

because the default argument comes first, then the value to check

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

---------

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
Dimitris Karakasilis 2023-07-24 17:52:22 +03:00 committed by GitHub
parent 3adbb8ae16
commit 764c3b9ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 86 additions and 81 deletions

View File

@ -1,22 +0,0 @@
{{ if eq .Values.init "systemd" }}
image: golang:1.20
prelude:
- apt-get update
- apt-get install -y git curl systemd
{{ else }}
image: golang:1.20-alpine
prelude:
- apk add git curl openrc bash
{{ end }}
- curl -sfL https://get.k3s.io > installer.sh
steps:
- PACKAGE_VERSION=${PACKAGE_VERSION%\-*} && export INSTALL_K3S_VERSION=$PACKAGE_VERSION && bash installer.sh
- PACKAGE_VERSION=${PACKAGE_VERSION%\-*} && export INSTALL_K3S_VERSION=$PACKAGE_VERSION && bash installer.sh agent
- mkdir -p /etc/rancher/k3s/ && touch /etc/rancher/k3s/.keep
exclude:
- etc/rancher/k3s/k3s.env
- etc/rancher/k3s/k3s-agent.env
env:
- INSTALL_K3S_SKIP_START="true"
- INSTALL_K3S_SKIP_ENABLE="true"

View File

@ -1,9 +0,0 @@
packages:
- name: "k3s-systemd"
category: "osbuilder-bundles"
version: "v1.21.14+k3s1-1"
init: systemd
- name: "k3s-openrc"
category: "osbuilder-bundles"
version: "v1.21.14+k3s1-1"
init: openrc

View File

@ -1,24 +0,0 @@
requires:
- name: "toolchain-go"
category: "development"
version: ">=0"
prelude:
{{$arch:=(default .Values.arch "amd64")}}
{{ if eq $arch "amd64" }}
- wget https://github.com/k3s-io/k3s/releases/download/v{{.Values.version}}+k3s{{.Values.k3s_version}}/k3s
{{ else }}
{{ if eq $arch "arm" }}
{{$arch:="arm64"}}
{{end}}
- wget https://github.com/k3s-io/k3s/releases/download/v{{.Values.version}}+k3s{{.Values.k3s_version}}/k3s-{{$arch}}
{{ end }}
- /bin/bash -c 'echo "{{ ( index .Values (print "checksum-" $arch) ) }} k3s" | sha256sum -c'
steps:
- |
mv {{.Values.name}} /usr/local/bin/
- chmod +x /usr/local/bin/{{.Values.name}}
includes:
- /usr/local/bin/{{.Values.name}}
# TODO: service files for openrc/systemd

View File

@ -1,13 +0,0 @@
packages:
- name: k3s
category: bundle
checksum-amd64: "c3c816290461dc0e8e632e70ceb0f771382629860a851ae88545c816beb9797c"
version: "1.24.2"
k3s_version: "2"
labels:
github.repo: "k3s-io"
github.owner: "k3s"
uri:
- https://github.com/k3s-io/k3s
license: "APL-2"
description: " Lightweight Kubernetes "

View File

@ -3,7 +3,7 @@ requires:
category: "development"
version: ">=0"
prelude:
{{$arch:=(default .Values.arch "amd64")}}
{{$arch:=(default "amd64" .Values.arch)}}
{{ if eq $arch "arm" }}
{{$arch:="arm64"}}
{{end}}

View File

@ -0,0 +1,37 @@
requires:
- name: "toolchain-go"
category: "development"
version: ">=0"
env:
- INSTALL_K3S_BIN_DIR="/usr/bin"
- INSTALL_K3S_SELINUX_WARN=true
- INSTALL_K3S_SKIP_START="true"
- INSTALL_K3S_SKIP_ENABLE="true"
- INSTALL_K3S_SKIP_SELINUX_RPM="true"
- INSTALL_K3S_VERSION=v{{.Values.version}}+k3s1
{{$arch:=(default "amd64" .Values.arch)}}
{{ if eq $arch "arm" }}
- ARCH=arm64
{{ else }}
- ARCH={{ $arch }}
{{ end }}
steps:
- curl -sfL https://get.k3s.io > installer.sh
# Let the installer script install service files both for openrc and systemd:
# https://github.com/k3s-io/k3s/blob/36645e7311e9bdbbf2adb79ecd8bd68556bc86f6/install.sh#L114-L122
- touch /bin/systemctl && chmod +x /bin/systemctl
- mkdir -p /etc/systemd/system/
- bash installer.sh
- bash installer.sh agent
# Run again to create the openrc service files
- rm /bin/systemctl
- rm -rf /etc/systemd/system/
- touch /sbin/openrc-run && chmod +x /sbin/openrc-run
- bash installer.sh
- rm -rf installer.sh
- chmod +x /usr/bin/{{.Values.name}}
includes:
- /usr/bin/{{.Values.name}}
- /etc/systemd/system/k3s*.service
- /etc/init.d/k3s*

View File

@ -0,0 +1,36 @@
packages:
- name: k3s
category: k8s
version: "1.25.11"
k3s_version: "2"
labels:
github.owner: "k3s-io"
github.repo: "k3s"
uri:
- https://github.com/k3s-io/k3s
license: "APL-2"
description: " Lightweight Kubernetes "
- name: k3s
category: k8s
version: "1.26.6"
k3s_version: "2"
labels:
github.owner: "k3s-io"
github.repo: "k3s"
uri:
- https://github.com/k3s-io/k3s
license: "APL-2"
description: " Lightweight Kubernetes "
- name: k3s
category: k8s
version: "1.27.3"
k3s_version: "2"
labels:
github.owner: "k3s-io"
github.repo: "k3s"
uri:
- https://github.com/k3s-io/k3s
license: "APL-2"
description: " Lightweight Kubernetes "

View File

@ -1,21 +1,22 @@
{{ if .Values.init }}
{{ if eq .Values.init "systemd" }}
image: golang:1.20
env:
- CGO_ENABLED=0
- LDFLAGS="-s -w -X 'github.com/kairos-io/provider-kairos/v2/internal/cli.VERSION={{ .Values.version }}'"
prelude:
- apt-get update
- apt-get install -y git
{{ else }}
image: golang:1.20-alpine
prelude:
- apk add git
{{ end }}
- git clone https://github.com/kairos-io/provider-kairos
- |
PACKAGE_VERSION=${PACKAGE_VERSION%\-*} && \
cd provider-kairos && git checkout v$PACKAGE_VERSION
steps:
- mkdir -p /system/providers
- cd provider-kairos && go build -o agent-provider-kairos
- cd provider-kairos && go build -ldflags "${LDFLAGS}" -o agent-provider-kairos
- mv provider-kairos/agent-provider-kairos /system/providers/agent-provider-kairos
- ln -s /system/providers/agent-provider-kairos /usr/bin/kairos
{{ end }}
includes:
- ^/system$
- ^/system/providers$
- ^/system/providers/agent-provider-kairos$
- ^/usr/bin/kairos$

View File

@ -1,6 +1,6 @@
packages:
- name: "provider-kairos"
category: "bundles"
category: "system"
version: "2.3.0"
labels:
github.repo: "provider-kairos"

View File

@ -3,8 +3,7 @@ requires:
category: "development"
version: ">=0"
prelude:
{{$arch:=(default .Values.arch "amd64")}}
{{$arch:=(default "amd64" .Values.arch)}}
{{ if eq $arch "arm" }}
{{$arch:="arm64"}}