Skip to content

Commit 9b9a948

Browse files
feat: keep custom k0s patches in the repo
- keeps patches around so we can patch new k0s versions. - change workflow to pull directoy from the upstream repo.
1 parent c8aa436 commit 9b9a948

File tree

3 files changed

+257
-9
lines changed

3 files changed

+257
-9
lines changed

.github/workflows/release-k0s-patch.yaml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ on:
44
workflow_dispatch:
55
inputs:
66
tag:
7-
description: "The tag to build and release"
7+
description: "Upstream tag to be used as a base, patches will be applied on top of this tag, e.g. v1.30.0+k0s.0."
88
required: true
9+
patchDir:
10+
description: "The directory (in this repository) to read the patches from, e.g. 'k0s-patches/release-1.30'."
11+
required: true
12+
default: 'k0s-patches/release-1.30'
13+
versionSuffix:
14+
description: "The custom suffix for the compiled k0s version, e.g. ec.1."
15+
required: true
16+
default: 'ec.0'
917

1018
jobs:
1119
build-and-release:
@@ -20,22 +28,33 @@ jobs:
2028
steps:
2129
- name: Checkout
2230
uses: actions/checkout@v4
31+
32+
- name: Checkout Upstream
33+
uses: actions/checkout@v4
2334
with:
24-
repository: replicatedhq/k0s
35+
repository: k0sproject/k0s
2536
ref: refs/tags/${{ github.event.inputs.tag }}
2637
persist-credentials: false
38+
path: k0s
39+
40+
- name: Apply Patches
41+
run: |
42+
cd k0s && git am -3 < ../${{ github.event.inputs.patchDir }}/*.patch
43+
44+
- name: Tag Embedded Cluster Release
45+
cd k0s && git tag ${{ github.event.inputs.tag }}-${{ github.event.inputs.versionSuffix }}
2746

2847
- name: Setup Go
2948
uses: actions/setup-go@v5
3049
with:
31-
go-version-file: go.mod
32-
cache-dependency-path: go.sum
50+
go-version-file: k0s/go.mod
51+
cache-dependency-path: k0s/go.sum
3352

3453
- name: Build k0s
3554
run: |
36-
make bindata
37-
make --touch codegen
38-
make build
55+
make -C k0s bindata
56+
make -C k0s --touch codegen
57+
make -C k0s build
3958
4059
- name: Upload build
4160
env:
@@ -44,12 +63,12 @@ jobs:
4463
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
4564
AWS_REGION: us-east-1
4665
run: |
47-
object_key="custom-k0s-binaries/k0s-${{ github.event.inputs.tag }}-${{ matrix.runner.arch }}"
66+
object_key="custom-k0s-binaries/k0s-${{ github.event.inputs.tag }}-${{ github.event.inputs.versionSuffix }}-${{ matrix.runner.arch }}"
4867
# check if the file already exists
4968
if aws s3api head-object --bucket="${S3_BUCKET}" --key="${object_key}" > /dev/null 2>&1; then
5069
echo "::notice ::Binary already exists in https://${S3_BUCKET}.s3.amazonaws.com/${object_key}"
5170
exit 1
5271
fi
5372
# upload the file
54-
aws s3 cp "k0s s3://${S3_BUCKET}/${object_key}"
73+
aws s3 cp "k0s/k0s s3://${S3_BUCKET}/${object_key}"
5574
echo "::notice ::Binary uploaded to https://${S3_BUCKET}.s3.amazonaws.com/${object_key}"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From 34189a60f4821743ed33ba3c4674ce02484c0675 Mon Sep 17 00:00:00 2001
2+
From: Ethan Mosbaugh <[email protected]>
3+
Date: Fri, 4 Oct 2024 10:54:16 -0700
4+
Subject: [PATCH] fix: chart crd forceUpgrade field should be nil by default
5+
6+
---
7+
pkg/apis/helm/v1beta1/chart_types.go | 1 -
8+
pkg/apis/k0s/v1beta1/extensions.go | 1 -
9+
.../helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml | 1 -
10+
.../k0s.k0sproject.io_clusterconfigs.yaml | 1 -
11+
4 files changed, 4 deletions(-)
12+
13+
diff --git a/pkg/apis/helm/v1beta1/chart_types.go b/pkg/apis/helm/v1beta1/chart_types.go
14+
index f6832fc1..93a03c75 100644
15+
--- a/pkg/apis/helm/v1beta1/chart_types.go
16+
+++ b/pkg/apis/helm/v1beta1/chart_types.go
17+
@@ -34,7 +34,6 @@ type ChartSpec struct {
18+
Namespace string `json:"namespace,omitempty"`
19+
Timeout string `json:"timeout,omitempty"`
20+
// ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true).
21+
- // +kubebuilder:default=true
22+
// +optional
23+
ForceUpgrade *bool `json:"forceUpgrade,omitempty"`
24+
Order int `json:"order,omitempty"`
25+
diff --git a/pkg/apis/k0s/v1beta1/extensions.go b/pkg/apis/k0s/v1beta1/extensions.go
26+
index 41d2df05..768066ee 100644
27+
--- a/pkg/apis/k0s/v1beta1/extensions.go
28+
+++ b/pkg/apis/k0s/v1beta1/extensions.go
29+
@@ -97,7 +97,6 @@ type Chart struct {
30+
TargetNS string `json:"namespace"`
31+
Timeout time.Duration `json:"timeout"`
32+
// ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true).
33+
- // +kubebuilder:default=true
34+
// +optional
35+
ForceUpgrade *bool `json:"forceUpgrade,omitempty"`
36+
Order int `json:"order"`
37+
diff --git a/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml b/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml
38+
index 86edc7c5..df06c506 100644
39+
--- a/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml
40+
+++ b/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml
41+
@@ -42,7 +42,6 @@ spec:
42+
chartName:
43+
type: string
44+
forceUpgrade:
45+
- default: true
46+
description: 'ForceUpgrade when set to false, disables the use of
47+
the "--force" flag when upgrading the the chart (default: true).'
48+
type: boolean
49+
diff --git a/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml b/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml
50+
index f834da6e..32e83c9f 100644
51+
--- a/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml
52+
+++ b/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml
53+
@@ -95,7 +95,6 @@ spec:
54+
chartname:
55+
type: string
56+
forceUpgrade:
57+
- default: true
58+
description: 'ForceUpgrade when set to false, disables
59+
the use of the "--force" flag when upgrading the the
60+
chart (default: true).'
61+
--
62+
2.39.3 (Apple Git-146)
63+
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
From a85fe5f8507e1a7b349fb08f3ca1b3b69d31b4bf Mon Sep 17 00:00:00 2001
2+
From: Ricardo Maraschini <[email protected]>
3+
Date: Wed, 9 Oct 2024 09:05:37 +0200
4+
Subject: [PATCH] revert: incompatible helm timeout change
5+
6+
this commit reverts the incompatible helm timeout change that was
7+
introduced in https://github.com/k0sproject/k0s/pull/4332.
8+
---
9+
pkg/apis/k0s/v1beta1/extensions.go | 2 +-
10+
pkg/apis/k0s/v1beta1/extenstions_test.go | 11 +++--------
11+
pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go | 1 -
12+
pkg/component/controller/extensions_controller.go | 7 ++-----
13+
.../controller/extensions_controller_test.go | 9 ++-------
14+
.../v1beta1/k0s.k0sproject.io_clusterconfigs.yaml | 3 ++-
15+
6 files changed, 10 insertions(+), 23 deletions(-)
16+
17+
diff --git a/pkg/apis/k0s/v1beta1/extensions.go b/pkg/apis/k0s/v1beta1/extensions.go
18+
index 4aaaadb24..2b0bf5c31 100644
19+
--- a/pkg/apis/k0s/v1beta1/extensions.go
20+
+++ b/pkg/apis/k0s/v1beta1/extensions.go
21+
@@ -100,7 +100,7 @@ type Chart struct {
22+
// Timeout specifies the timeout for how long to wait for the chart installation to finish.
23+
// A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
24+
// +kubebuilder:validation:XIntOrString
25+
- Timeout BackwardCompatibleDuration `json:"timeout,omitempty"`
26+
+ Timeout time.Duration `json:"timeout,omitempty"`
27+
// ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true).
28+
// +optional
29+
ForceUpgrade *bool `json:"forceUpgrade,omitempty"`
30+
diff --git a/pkg/apis/k0s/v1beta1/extenstions_test.go b/pkg/apis/k0s/v1beta1/extenstions_test.go
31+
index 7e358c4c9..3521035a7 100644
32+
--- a/pkg/apis/k0s/v1beta1/extenstions_test.go
33+
+++ b/pkg/apis/k0s/v1beta1/extenstions_test.go
34+
@@ -22,7 +22,6 @@ import (
35+
36+
"github.com/stretchr/testify/assert"
37+
"github.com/stretchr/testify/require"
38+
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
39+
)
40+
41+
func TestValidation(t *testing.T) {
42+
@@ -108,9 +107,7 @@ spec:
43+
require.NoError(err)
44+
45+
chart := c.Spec.Extensions.Helm.Charts[0]
46+
- expectedDuration := BackwardCompatibleDuration(
47+
- metav1.Duration{Duration: time.Minute},
48+
- )
49+
+ expectedDuration := time.Minute
50+
require.Equal(expectedDuration, chart.Timeout)
51+
}
52+
53+
@@ -127,7 +124,7 @@ spec:
54+
- name: prometheus-stack
55+
chartname: prometheus-community/prometheus
56+
version: "14.6.1"
57+
- timeout: 20m
58+
+ timeout: 1200000000000
59+
`
60+
61+
c, err := ConfigFromString(yaml)
62+
@@ -136,8 +133,6 @@ spec:
63+
require.NoError(err)
64+
65+
chart := c.Spec.Extensions.Helm.Charts[0]
66+
- expectedDuration := BackwardCompatibleDuration(
67+
- metav1.Duration{Duration: 20 * time.Minute},
68+
- )
69+
+ expectedDuration := 20 * time.Minute
70+
require.Equal(expectedDuration, chart.Timeout)
71+
}
72+
diff --git a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go
73+
index 91ce8a541..a8a1b777f 100644
74+
--- a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go
75+
+++ b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go
76+
@@ -144,7 +144,6 @@ func (in *CalicoImageSpec) DeepCopy() *CalicoImageSpec {
77+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
78+
func (in *Chart) DeepCopyInto(out *Chart) {
79+
*out = *in
80+
- out.Timeout = in.Timeout
81+
if in.ForceUpgrade != nil {
82+
in, out := &in.ForceUpgrade, &out.ForceUpgrade
83+
*out = new(bool)
84+
diff --git a/pkg/component/controller/extensions_controller.go b/pkg/component/controller/extensions_controller.go
85+
index 4c2402794..3c0d42d2a 100644
86+
--- a/pkg/component/controller/extensions_controller.go
87+
+++ b/pkg/component/controller/extensions_controller.go
88+
@@ -46,7 +46,6 @@ import (
89+
"helm.sh/helm/v3/pkg/release"
90+
"helm.sh/helm/v3/pkg/storage/driver"
91+
apierrors "k8s.io/apimachinery/pkg/api/errors"
92+
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
93+
"k8s.io/apimachinery/pkg/runtime/schema"
94+
"k8s.io/apimachinery/pkg/types"
95+
"k8s.io/client-go/tools/clientcmd"
96+
@@ -159,9 +158,7 @@ func addOpenEBSHelmExtension(helmSpec *k0sv1beta1.HelmExtensions, storageExtensi
97+
TargetNS: "openebs",
98+
Version: constant.OpenEBSVersion,
99+
Values: values,
100+
- Timeout: k0sv1beta1.BackwardCompatibleDuration(
101+
- metav1.Duration{Duration: time.Duration(time.Minute * 30)}, // it takes a while to install openebs
102+
- ),
103+
+ Timeout: time.Minute * 30,
104+
})
105+
return helmSpec, nil
106+
}
107+
@@ -454,7 +451,7 @@ metadata:
108+
spec:
109+
chartName: {{ .ChartName }}
110+
releaseName: {{ .Name }}
111+
- timeout: {{ .Timeout.Duration }}
112+
+ timeout: {{ .Timeout }}
113+
values: |
114+
{{ .Values | nindent 4 }}
115+
version: {{ .Version }}
116+
diff --git a/pkg/component/controller/extensions_controller_test.go b/pkg/component/controller/extensions_controller_test.go
117+
index f264051fb..8317b4656 100644
118+
--- a/pkg/component/controller/extensions_controller_test.go
119+
+++ b/pkg/component/controller/extensions_controller_test.go
120+
@@ -26,7 +26,6 @@ import (
121+
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
122+
"github.com/stretchr/testify/assert"
123+
"github.com/stretchr/testify/require"
124+
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
125+
"k8s.io/utils/ptr"
126+
)
127+
128+
@@ -251,9 +250,7 @@ func TestExtensionsController_writeChartManifestFile(t *testing.T) {
129+
Version: "0.0.1",
130+
Values: "values",
131+
TargetNS: "default",
132+
- Timeout: k0sv1beta1.BackwardCompatibleDuration(
133+
- metav1.Duration{Duration: 5 * time.Minute},
134+
- ),
135+
+ Timeout: 5 * time.Minute,
136+
},
137+
fileName: "0_helm_extension_release.yaml",
138+
},
139+
@@ -285,9 +282,7 @@ spec:
140+
Values: "values",
141+
TargetNS: "default",
142+
ForceUpgrade: ptr.To(false),
143+
- Timeout: k0sv1beta1.BackwardCompatibleDuration(
144+
- metav1.Duration{Duration: 5 * time.Minute},
145+
- ),
146+
+ Timeout: 5 * time.Minute,
147+
},
148+
fileName: "0_helm_extension_release.yaml",
149+
},
150+
diff --git a/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml b/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml
151+
index c81765a2f..240855c84 100644
152+
--- a/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml
153+
+++ b/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml
154+
@@ -115,7 +115,8 @@ spec:
155+
description: |-
156+
Timeout specifies the timeout for how long to wait for the chart installation to finish.
157+
A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
158+
- type: string
159+
+ format: int64
160+
+ type: integer
161+
x-kubernetes-int-or-string: true
162+
values:
163+
type: string
164+
--
165+
2.39.3 (Apple Git-146)
166+

0 commit comments

Comments
 (0)