Skip to content

Commit b6f2e17

Browse files
emosbaughsgalsalehlaverya
authored
feat: ability to upgrade the cluster via the new binary (#684)
* feat: ability to upgrade the cluster via the new binary --------- Co-authored-by: Salah Al Saleh <[email protected]> Co-authored-by: Andrew Lavery <[email protected]>
1 parent 0bf7437 commit b6f2e17

35 files changed

+640
-242
lines changed

.github/actions/e2e/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ runs:
8989
- name: E2E
9090
shell: bash
9191
run: |
92-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
92+
SHA=${{ github.event.pull_request.head.sha || github.sha }}
93+
export SHORT_SHA=dev-${SHA::7}
9394
export LICENSE_ID=${{ inputs.license-id }}
9495
export AIRGAP_LICENSE_ID=${{ inputs.airgap-license-id }}
9596
export SNAPSHOT_LICENSE_ID=${{ inputs.snapshot-license-id }}
@@ -109,7 +110,7 @@ runs:
109110
if: ${{ failure() }}
110111
with:
111112
name: ${{ inputs.test-name }}-support-bundle-host.tar.gz
112-
path: ./e2e/support-bundle-host.tar.gz
113+
path: ./e2e/support-bundle-host-*.tar.gz
113114
- name: Upload Cluster Support Bundle
114115
uses: actions/upload-artifact@v4
115116
if: ${{ failure() }}

.github/workflows/pull-request.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ jobs:
6363

6464
- name: Build and push local-artifact-mirror image
6565
run: |
66-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
66+
SHA=${{ github.event.pull_request.head.sha }}
67+
export SHORT_SHA=dev-${SHA::7}
6768
export LOCAL_ARTIFACT_MIRROR_IMAGE=registry.staging.replicated.com/library/embedded-cluster-local-artifact-mirror
6869
make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}"
6970
make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}-previous-k0s"
7071
make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}-upgrade"
7172
7273
- name: Build Linux AMD64 and Output Metadata
7374
run: |
74-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
75+
SHA=${{ github.event.pull_request.head.sha }}
76+
export SHORT_SHA=dev-${SHA::7}
7577
export LOCAL_ARTIFACT_MIRROR_IMAGE=registry.staging.replicated.com/library/embedded-cluster-local-artifact-mirror
7678
make -B embedded-cluster-linux-amd64 K0S_VERSION=$(make print-PREVIOUS_K0S_VERSION) K0S_BINARY_SOURCE_OVERRIDE=$(make print-PREVIOUS_K0S_BINARY_SOURCE_OVERRIDE) VERSION="${SHORT_SHA}-previous-k0s"
7779
tar -C output/bin -czvf embedded-cluster-linux-amd64-previous-k0s.tgz embedded-cluster
@@ -98,7 +100,8 @@ jobs:
98100
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
99101
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
100102
run: |
101-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
103+
SHA=${{ github.event.pull_request.head.sha }}
104+
export SHORT_SHA=dev-${SHA::7}
102105
echo "${SHORT_SHA}"
103106
sed -i "s/__version_string__/${SHORT_SHA}/g" e2e/kots-release-install/cluster-config.yaml
104107
sed -i "s/__version_string__/${SHORT_SHA}-upgrade/g" e2e/kots-release-upgrade/cluster-config.yaml
@@ -107,10 +110,12 @@ jobs:
107110
replicated release promote 807 2cHXb1RCttzpR0xvnNWyaZCgDBP --version "appver-${SHORT_SHA}-pre-minio-removal"
108111
109112
replicated release create --yaml-dir e2e/kots-release-install --promote CI --version "appver-${SHORT_SHA}"
113+
replicated release create --yaml-dir e2e/kots-release-install --promote CI --version "appver-${SHORT_SHA}-noop"
110114
replicated release create --yaml-dir e2e/kots-release-upgrade --promote CI --version "appver-${SHORT_SHA}-upgrade"
111115
- name: Build CI binary
112116
run: |
113-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
117+
SHA=${{ github.event.pull_request.head.sha }}
118+
export SHORT_SHA=dev-${SHA::7}
114119
export LOCAL_ARTIFACT_MIRROR_IMAGE=registry.staging.replicated.com/library/embedded-cluster-local-artifact-mirror
115120
echo "# channel release object" > e2e/kots-release-install/release.yaml
116121
echo 'channelID: "2cHXb1RCttzpR0xvnNWyaZCgDBP"' >> e2e/kots-release-install/release.yaml
@@ -129,7 +134,8 @@ jobs:
129134
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
130135
AWS_REGION: "us-east-1"
131136
run: |
132-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
137+
SHA=${{ github.event.pull_request.head.sha }}
138+
export SHORT_SHA=dev-${SHA::7}
133139
export EC_VERSION="v${SHORT_SHA}"
134140
./scripts/cache-files.sh
135141
./scripts/create-upgrade-release.sh
@@ -141,7 +147,8 @@ jobs:
141147
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
142148
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
143149
run: |
144-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
150+
SHA=${{ github.event.pull_request.head.sha }}
151+
export SHORT_SHA=dev-${SHA::7}
145152
echo "${SHORT_SHA}"
146153
rm e2e/kots-release-install/release.yaml
147154
replicated release create --yaml-dir e2e/kots-release-install --promote CI-airgap --version "appver-${SHORT_SHA}"
@@ -154,7 +161,8 @@ jobs:
154161
155162
- name: Create download link message text
156163
run: |
157-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
164+
SHA=${{ github.event.pull_request.head.sha }}
165+
export SHORT_SHA=dev-${SHA::7}
158166
159167
echo "This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app [license ID](https://vendor.staging.replicated.com/apps/embedded-cluster-smoke-test-staging-app/customers?sort=name-asc)." > download-link.txt
160168
echo "" >> download-link.txt
@@ -227,6 +235,7 @@ jobs:
227235
- TestMultiNodeAirgapHADisasterRecovery
228236
- TestCustomCIDR
229237
- TestProxiedCustomCIDR
238+
- TestSingleNodeInstallationNoopUpgrade
230239
include:
231240
- test: TestMultiNodeAirgapUpgrade
232241
runner: embedded-cluster

.github/workflows/release-dev.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ jobs:
3030

3131
- name: Build and push local-artifact-mirror image
3232
run: |
33-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
33+
export SHORT_SHA=dev-${GITHUB_SHA::7}
3434
export LOCAL_ARTIFACT_MIRROR_IMAGE=registry.staging.replicated.com/library/embedded-cluster-local-artifact-mirror
3535
make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}"
3636
make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}-previous-k0s"
3737
make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}-upgrade"
3838
3939
- name: Build Linux AMD64 and Output Metadata
4040
run: |
41-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
41+
export SHORT_SHA=dev-${GITHUB_SHA::7}
4242
export LOCAL_ARTIFACT_MIRROR_IMAGE=registry.staging.replicated.com/library/embedded-cluster-local-artifact-mirror
4343
make -B embedded-cluster-linux-amd64 K0S_VERSION=$(make print-PREVIOUS_K0S_VERSION) K0S_BINARY_SOURCE_OVERRIDE=$(make print-PREVIOUS_K0S_BINARY_SOURCE_OVERRIDE) VERSION="${SHORT_SHA}-previous-k0s"
4444
tar -C output/bin -czvf embedded-cluster-linux-amd64-previous-k0s.tgz embedded-cluster
@@ -74,7 +74,7 @@ jobs:
7474
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
7575
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
7676
run: |
77-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
77+
export SHORT_SHA=dev-${GITHUB_SHA::7}
7878
echo "${SHORT_SHA}"
7979
sed -i "s/__version_string__/${SHORT_SHA}/g" e2e/kots-release-install/cluster-config.yaml
8080
sed -i "s/__version_string__/${SHORT_SHA}-upgrade/g" e2e/kots-release-upgrade/cluster-config.yaml
@@ -83,10 +83,11 @@ jobs:
8383
replicated release promote 807 2cHXb1RCttzpR0xvnNWyaZCgDBP --version "appver-${SHORT_SHA}-pre-minio-removal"
8484
8585
replicated release create --yaml-dir e2e/kots-release-install --promote CI --version "appver-${SHORT_SHA}"
86+
replicated release create --yaml-dir e2e/kots-release-install --promote CI --version "appver-${SHORT_SHA}-noop"
8687
replicated release create --yaml-dir e2e/kots-release-upgrade --promote CI --version "appver-${SHORT_SHA}-upgrade"
8788
- name: Build CI binary
8889
run: |
89-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
90+
export SHORT_SHA=dev-${GITHUB_SHA::7}
9091
export LOCAL_ARTIFACT_MIRROR_IMAGE=registry.staging.replicated.com/library/embedded-cluster-local-artifact-mirror
9192
echo "# channel release object" > e2e/kots-release-install/release.yaml
9293
echo 'channelID: "2cHXb1RCttzpR0xvnNWyaZCgDBP"' >> e2e/kots-release-install/release.yaml
@@ -105,7 +106,7 @@ jobs:
105106
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
106107
AWS_REGION: "us-east-1"
107108
run: |
108-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
109+
export SHORT_SHA=dev-${GITHUB_SHA::7}
109110
export EC_VERSION="v${SHORT_SHA}"
110111
./scripts/cache-files.sh
111112
./scripts/create-upgrade-release.sh
@@ -116,7 +117,7 @@ jobs:
116117
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
117118
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
118119
run: |
119-
export SHORT_SHA=dev-$(git rev-parse --short=7 HEAD)
120+
export SHORT_SHA=dev-${GITHUB_SHA::7}
120121
echo "${SHORT_SHA}"
121122
rm e2e/kots-release-install/release.yaml
122123
replicated release create --yaml-dir e2e/kots-release-install --promote CI-airgap --version "appver-${SHORT_SHA}"
@@ -179,6 +180,7 @@ jobs:
179180
- TestMultiNodeAirgapHADisasterRecovery
180181
- TestCustomCIDR
181182
- TestProxiedCustomCIDR
183+
- TestSingleNodeInstallationNoopUpgrade
182184
include:
183185
- test: TestMultiNodeAirgapUpgrade
184186
runner: embedded-cluster

Makefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ UNAME := $(shell uname)
33
ARCH := $(shell uname -m)
44
APP_NAME = embedded-cluster
55
ADMIN_CONSOLE_CHART_REPO_OVERRIDE =
6-
ADMIN_CONSOLE_CHART_VERSION = 1.111.0
6+
ADMIN_CONSOLE_CHART_VERSION = 1.112.1
77
ADMIN_CONSOLE_IMAGE_OVERRIDE =
88
ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE =
9-
EMBEDDED_OPERATOR_CHART_URL = oci://registry.replicated.com/library
10-
EMBEDDED_OPERATOR_CHART_NAME = embedded-cluster-operator
11-
EMBEDDED_OPERATOR_CHART_VERSION = 0.36.5
9+
ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE =
10+
EMBEDDED_OPERATOR_CHART_VERSION = 0.40.2
11+
EMBEDDED_OPERATOR_BINARY_URL_OVERRIDE =
1212
EMBEDDED_OPERATOR_UTILS_IMAGE = busybox:1.36.1
1313
EMBEDDED_CLUSTER_OPERATOR_IMAGE_OVERRIDE =
1414
OPENEBS_CHART_VERSION = 4.1.0
@@ -22,7 +22,7 @@ VELERO_AWS_PLUGIN_IMAGE_VERSION = v1.9.2
2222
KUBECTL_VERSION = v1.30.1
2323
K0S_VERSION = v1.29.5+k0s.0-ec.0
2424
K0S_GO_VERSION = v1.29.5+k0s.0
25-
PREVIOUS_K0S_VERSION ?= v1.28.8+k0s.0
25+
PREVIOUS_K0S_VERSION ?= v1.28.10+k0s.0
2626
K0S_BINARY_SOURCE_OVERRIDE = https://ec-k0s-binaries.s3.amazonaws.com/k0s-v1.29.5%2Bk0s.0-ec.0
2727
PREVIOUS_K0S_BINARY_SOURCE_OVERRIDE =
2828
TROUBLESHOOT_VERSION = v0.93.1
@@ -39,6 +39,7 @@ LD_FLAGS = -X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sVersion=$
3939
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.Version=$(ADMIN_CONSOLE_CHART_VERSION) \
4040
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ImageOverride=$(ADMIN_CONSOLE_IMAGE_OVERRIDE) \
4141
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.MigrationsImageOverride=$(ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE) \
42+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.KurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE) \
4243
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.KotsVersion=$(KOTS_VERSION) \
4344
-X github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator.Version=$(EMBEDDED_OPERATOR_CHART_VERSION) \
4445
-X github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator.UtilsImage=$(EMBEDDED_OPERATOR_UTILS_IMAGE) \
@@ -181,7 +182,7 @@ print-%:
181182

182183
.PHONY: build-local-artifact-mirror-image
183184
build-local-artifact-mirror-image:
184-
docker build -t $(LOCAL_ARTIFACT_MIRROR_IMAGE_LOCATION) -f Dockerfile .
185+
docker build --platform linux/amd64 -t $(LOCAL_ARTIFACT_MIRROR_IMAGE_LOCATION) -f deploy/local-artifact-mirror/Dockerfile .
185186

186187
.PHONY: push-local-artifact-mirror-image
187188
push-local-artifact-mirror-image:
@@ -193,3 +194,8 @@ build-and-push-local-artifact-mirror-image: build-local-artifact-mirror-image pu
193194
.PHONY: buildtools
194195
buildtools:
195196
go build -o ./output/bin/buildtools ./cmd/buildtools
197+
198+
.PHONY: cache-files
199+
cache-files: export EMBEDDED_OPERATOR_BINARY_URL_OVERRIDE
200+
cache-files:
201+
./scripts/cache-files.sh

cmd/embedded-cluster/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var updateCommand = &cli.Command{
4646
return fmt.Errorf("no channel release found")
4747
}
4848

49-
if err := kotscli.UpstreamUpgrade(kotscli.UpstreamUpgradeOptions{
49+
if err := kotscli.AirgapUpdate(kotscli.AirgapUpdateOptions{
5050
AppSlug: rel.AppSlug,
5151
Namespace: defaults.KotsadmNamespace,
5252
AirgapBundle: c.String("airgap-bundle"),

cmd/local-artifact-mirror/pull.go

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ package main
33
import (
44
"bytes"
55
"context"
6+
"encoding/base64"
67
"fmt"
78
"os"
89
"os/exec"
910
"path/filepath"
1011

1112
"github.com/sirupsen/logrus"
1213
"github.com/urfave/cli/v2"
14+
"k8s.io/apimachinery/pkg/runtime"
15+
"k8s.io/apimachinery/pkg/runtime/serializer"
1316
"k8s.io/apimachinery/pkg/types"
1417
"sigs.k8s.io/controller-runtime/pkg/client"
1518

@@ -197,14 +200,15 @@ var binariesCommand = &cli.Command{
197200
},
198201
}
199202

200-
// fetchAndValidateInstallation fetches an Installation object from its name and
201-
// checks if it is valid for an airgap cluster deployment.
203+
// fetchAndValidateInstallation fetches an Installation object from its name or directly decodes it
204+
// and checks if it is valid for an airgap cluster deployment.
202205
func fetchAndValidateInstallation(ctx context.Context, iname string) (*v1beta1.Installation, error) {
203-
logrus.Infof("reading installation %q", iname)
204-
nsn := types.NamespacedName{Name: iname}
205-
var in v1beta1.Installation
206-
if err := kubecli.Get(ctx, nsn, &in); err != nil {
207-
return nil, fmt.Errorf("unable to get installation: %w", err)
206+
in, err := decodeInstallation(ctx, iname)
207+
if err != nil {
208+
in, err = fetchInstallationFromCluster(ctx, iname)
209+
if err != nil {
210+
return nil, err
211+
}
208212
}
209213

210214
if !in.Spec.AirGap {
@@ -213,5 +217,47 @@ func fetchAndValidateInstallation(ctx context.Context, iname string) (*v1beta1.I
213217
return nil, fmt.Errorf("installation has no artifacts")
214218
}
215219

220+
return in, nil
221+
}
222+
223+
// fetchInstallationFromCluster fetches an Installation object from the cluster.
224+
func fetchInstallationFromCluster(ctx context.Context, iname string) (*v1beta1.Installation, error) {
225+
logrus.Infof("reading installation from cluster %q", iname)
226+
227+
nsn := types.NamespacedName{Name: iname}
228+
var in v1beta1.Installation
229+
if err := kubecli.Get(ctx, nsn, &in); err != nil {
230+
return nil, fmt.Errorf("unable to get installation: %w", err)
231+
}
232+
216233
return &in, nil
217234
}
235+
236+
// decodeInstallation decodes an Installation object from a string.
237+
func decodeInstallation(ctx context.Context, data string) (*v1beta1.Installation, error) {
238+
logrus.Info("decoding installation")
239+
240+
decoded, err := base64.StdEncoding.DecodeString(data)
241+
if err != nil {
242+
return nil, fmt.Errorf("base64 decode: %w", err)
243+
}
244+
245+
scheme := runtime.NewScheme()
246+
err = v1beta1.AddToScheme(scheme)
247+
if err != nil {
248+
return nil, fmt.Errorf("add to scheme: %w", err)
249+
}
250+
251+
decode := serializer.NewCodecFactory(scheme).UniversalDeserializer().Decode
252+
obj, _, err := decode(decoded, nil, nil)
253+
if err != nil {
254+
return nil, fmt.Errorf("decode: %w", err)
255+
}
256+
257+
in, ok := obj.(*v1beta1.Installation)
258+
if !ok {
259+
return nil, fmt.Errorf("unexpected object type: %T", obj)
260+
}
261+
262+
return in, nil
263+
}
File renamed without changes.

0 commit comments

Comments
 (0)