Skip to content

Commit e171968

Browse files
authored
Merge branch 'main' into stop-using-kots
2 parents 77358da + 29c845f commit e171968

File tree

77 files changed

+4937
-2367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4937
-2367
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,11 @@ jobs:
511511
512512
- name: Build
513513
env:
514+
APP_CHANNEL: CI
514515
APP_CHANNEL_ID: 2cHXb1RCttzpR0xvnNWyaZCgDBP
515516
APP_CHANNEL_SLUG: ci
516517
RELEASE_YAML_DIR: e2e/kots-release-install
517-
S3_BUCKET: "tf-staging-embedded-cluster-bin"
518-
USES_DEV_BUCKET: "0"
518+
S3_BUCKET: tf-staging-embedded-cluster-bin
519519
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
520520
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
521521
AWS_REGION: "us-east-1"
@@ -646,11 +646,11 @@ jobs:
646646
647647
- name: Build
648648
env:
649+
APP_CHANNEL: CI
649650
APP_CHANNEL_ID: 2cHXb1RCttzpR0xvnNWyaZCgDBP
650651
APP_CHANNEL_SLUG: ci
651652
RELEASE_YAML_DIR: e2e/kots-release-upgrade
652-
S3_BUCKET: "tf-staging-embedded-cluster-bin"
653-
USES_DEV_BUCKET: "0"
653+
S3_BUCKET: tf-staging-embedded-cluster-bin
654654
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
655655
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
656656
AWS_REGION: "us-east-1"
@@ -761,8 +761,7 @@ jobs:
761761
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
762762
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
763763
APP_CHANNEL: CI
764-
USES_DEV_BUCKET: "0"
765-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
764+
S3_BUCKET: tf-staging-embedded-cluster-bin
766765
run: |
767766
export SHORT_SHA=dev-${{ needs.output-vars.outputs.git_sha }}
768767
@@ -820,7 +819,7 @@ jobs:
820819
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
821820
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
822821
APP_CHANNEL: CI-airgap
823-
USES_DEV_BUCKET: "0"
822+
S3_BUCKET: tf-staging-embedded-cluster-bin
824823
run: |
825824
export SHORT_SHA=dev-${{ needs.output-vars.outputs.git_sha }}
826825

.github/workflows/release-prod.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ jobs:
314314
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
315315
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
316316
APP_CHANNEL: CI
317-
USES_DEV_BUCKET: "0"
317+
S3_BUCKET: tf-staging-embedded-cluster-bin
318318
run: |
319319
# re-promote a release containing an old version of embedded-cluster to test upgrades
320320
export APP_VERSION="appver-${{ github.ref_name }}-pre-minio-removal"
@@ -362,7 +362,7 @@ jobs:
362362
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
363363
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
364364
APP_CHANNEL: CI-airgap
365-
USES_DEV_BUCKET: "0"
365+
S3_BUCKET: tf-staging-embedded-cluster-bin
366366
run: |
367367
# promote a release containing the previous stable version of embedded-cluster to test upgrades
368368
export EC_VERSION="${{ needs.find-previous-stable.outputs.ec_version }}"
@@ -400,7 +400,7 @@ jobs:
400400
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
401401
REPLICATED_API_ORIGIN: "https://api.staging.replicated.com/vendor"
402402
APP_CHANNEL: Stable
403-
USES_DEV_BUCKET: "0"
403+
S3_BUCKET: tf-staging-embedded-cluster-bin
404404
run: |
405405
# create a release in the stable channel of our test app for use by CMX
406406
export EC_VERSION="${{ github.ref_name }}"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ e2e/support-bundle*.tar.gz
3939

4040
# Local Netlify folder
4141
.netlify
42+
43+
# Test web assets created during dryrun tests
44+
tests/dryrun/web/

.trivyignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ output/bin/embedded-cluster-release-builder:
183183
mkdir -p output/bin
184184
CGO_ENABLED=0 go build -o output/bin/embedded-cluster-release-builder e2e/embedded-cluster-release-builder/main.go
185185

186+
.PHONY: e2e-v3-initial-release
187+
e2e-v3-initial-release: export ARCH = amd64
188+
e2e-v3-initial-release: export UPLOAD_BINARIES = 1
189+
e2e-v3-initial-release: export ENABLE_V3 = 1
190+
e2e-v3-initial-release: initial-release
191+
186192
.PHONY: initial-release
187193
initial-release: export EC_VERSION = $(VERSION)-$(CURRENT_USER)
188194
initial-release: export APP_VERSION = appver-dev-$(call random-string)
@@ -385,8 +391,12 @@ create-node%:
385391
@$(MAKE) ssh-node$*
386392

387393
.PHONY: ssh-node%
394+
ssh-node%: CUSTOMER_LICENSE_FILE = $(shell source ./local-dev/env.sh && echo "$$CUSTOMER_LICENSE_FILE")
388395
ssh-node%:
389-
@docker exec -it -w /replicatedhq/embedded-cluster node$* bash
396+
@docker exec -it -w /replicatedhq/embedded-cluster \
397+
-e CUSTOMER_LICENSE_FILE="$(CUSTOMER_LICENSE_FILE)" \
398+
node$* \
399+
bash
390400

391401
.PHONY: delete-node%
392402
delete-node%:

README.md

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Additionally, it includes a Registry when deployed in air gap mode, and SeaweedF
2525
- jq
2626
- oras
2727
- crane
28+
- op (1Password CLI)
2829
- Kubectl (for integration tests)
2930
- Kind (for integration tests)
3031

@@ -36,36 +37,11 @@ Additionally, it includes a Registry when deployed in air gap mode, and SeaweedF
3637
cd embedded-cluster
3738
```
3839

39-
1. Set the following environment variables:
40+
1. Sign into the 1Password CLI (access to the "Developer Automation" vault is required)
4041
```bash
41-
export REPLICATED_APP=
42-
export REPLICATED_API_TOKEN=
43-
export REPLICATED_API_ORIGIN=
44-
export APP_CHANNEL=
45-
export APP_CHANNEL_ID=
46-
export APP_CHANNEL_SLUG=
47-
export AWS_ACCESS_KEY_ID=
48-
export AWS_SECRET_ACCESS_KEY=
42+
op signin
4943
```
5044

51-
| Environment Variable | Description | Default Value |
52-
|----------------------|-------------|---------------|
53-
| `REPLICATED_APP` | The application slug | `embedded-cluster-smoke-test-staging-app` |
54-
| `REPLICATED_API_TOKEN` | A vendor portal API token with write access to the application | (required) |
55-
| `REPLICATED_API_ORIGIN` | The vendor-api URL | `https://api.staging.replicated.com/vendor` |
56-
| `APP_CHANNEL` | The channel name (it's recommended to create a new channel just for your development environment.) | (required) |
57-
| `APP_CHANNEL_ID` | The channel ID | (required) |
58-
| `APP_CHANNEL_SLUG` | The channel slug | (required) |
59-
| `AWS_ACCESS_KEY_ID` | AWS access key ID with write access to the `dev-embedded-cluster-bin` bucket in Replicated's dev AWS account | (required) |
60-
| `AWS_SECRET_ACCESS_KEY` | AWS secret access key with write access to the `dev-embedded-cluster-bin` bucket in Replicated's dev AWS account | (required) |
61-
62-
Note:
63-
- To use a different AWS bucket or account, override using the `S3_BUCKET` environment variable.
64-
- To use the Replicated staging bucket used in CI, set `USES_DEV_BUCKET=0`.
65-
66-
1. In the Vendor Portal, create and download a license that is assigned to the channel.
67-
We recommend storing this license in the `local-dev/` directory, as it is gitignored and not otherwise used by the CI.
68-
6945
### V2 installs
7046

7147
**For Online:**
@@ -79,7 +55,7 @@ We recommend storing this license in the `local-dev/` directory, as it is gitign
7955
```
8056
1. Install the release:
8157
```bash
82-
output/bin/embedded-cluster install --license <license-file>
58+
output/bin/embedded-cluster install --license "$CUSTOMER_LICENSE_FILE"
8359
```
8460
1. Once that completes, you can access the admin console at http://localhost:30000
8561

@@ -140,7 +116,7 @@ Embedded Cluster supports v3 releases which provide an enhanced manager UI exper
140116
```
141117
1. Install the release:
142118
```bash
143-
ENABLE_V3=1 EC_DEV_ENV=true output/bin/embedded-cluster install --license <license-file> --target linux
119+
ENABLE_V3=1 EC_DEV_ENV=true output/bin/embedded-cluster install --license "$CUSTOMER_LICENSE_FILE" --target linux
144120
```
145121

146122
**For Airgap:**
@@ -156,7 +132,7 @@ Embedded Cluster supports v3 releases which provide an enhanced manager UI exper
156132
1. Run the download and extract commands from the install instructions on the customer page.
157133
1. Run the following command to install the EC release in airgap mode:
158134
```bash
159-
ENABLE_V3=1 sudo -E ./<app-slug> install --license <license-file> --airgap-bundle <app-slug>.airgap --target linux
135+
ENABLE_V3=1 sudo -E ./<app-slug> install --license "$CUSTOMER_LICENSE_FILE" --airgap-bundle <app-slug>.airgap --target linux
160136
```
161137

162138
**Note:** The release will be created using the manifests located in the `e2e/kots-release-install-v3` directory.
@@ -174,7 +150,7 @@ Embedded Cluster supports v3 releases which provide an enhanced manager UI exper
174150
```
175151
1. Run the following command to upgrade the EC release:
176152
```bash
177-
ENABLE_V3=1 EC_DEV_ENV=true output/bin/embedded-cluster upgrade --license <license-file> --target linux
153+
ENABLE_V3=1 EC_DEV_ENV=true output/bin/embedded-cluster upgrade --license "$CUSTOMER_LICENSE_FILE" --target linux
178154
```
179155

180156
**For Airgap:**
@@ -190,7 +166,7 @@ Embedded Cluster supports v3 releases which provide an enhanced manager UI exper
190166
1. Run the download and extract commands from the install instructions on the customer page.
191167
1. Run the following command to upgrade to the new EC release in airgap mode:
192168
```bash
193-
ENABLE_V3=1 EC_DEV_ENV=true sudo -E ./<app-slug> upgrade --license <license-file> --airgap-bundle <app-slug>.airgap --target linux
169+
ENABLE_V3=1 EC_DEV_ENV=true sudo -E ./<app-slug> upgrade --license "$CUSTOMER_LICENSE_FILE" --airgap-bundle <app-slug>.airgap --target linux
194170
```
195171

196172
**Note:** The release will be created using the manifests located in the `e2e/kots-release-upgrade-v3` directory.

api/api.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/replicatedhq/embedded-cluster/api/controllers/console"
88
kubernetesinstall "github.com/replicatedhq/embedded-cluster/api/controllers/kubernetes/install"
99
kubernetesupgrade "github.com/replicatedhq/embedded-cluster/api/controllers/kubernetes/upgrade"
10+
kurlmigration "github.com/replicatedhq/embedded-cluster/api/controllers/kurlmigration"
1011
linuxinstall "github.com/replicatedhq/embedded-cluster/api/controllers/linux/install"
1112
linuxupgrade "github.com/replicatedhq/embedded-cluster/api/controllers/linux/upgrade"
1213
"github.com/replicatedhq/embedded-cluster/api/pkg/logger"
@@ -56,6 +57,7 @@ type API struct {
5657
linuxUpgradeController linuxupgrade.Controller
5758
kubernetesInstallController kubernetesinstall.Controller
5859
kubernetesUpgradeController kubernetesupgrade.Controller
60+
kurlMigrationController kurlmigration.Controller
5961

6062
handlers handlers
6163
}
@@ -105,6 +107,13 @@ func WithKubernetesUpgradeController(kubernetesUpgradeController kubernetesupgra
105107
}
106108
}
107109

110+
// WithKURLMigrationController configures the kURL migration controller for the API.
111+
func WithKURLMigrationController(kurlMigrationController kurlmigration.Controller) Option {
112+
return func(a *API) {
113+
a.kurlMigrationController = kurlMigrationController
114+
}
115+
}
116+
108117
// WithLogger configures the logger for the API. If not provided, a default logger will be created.
109118
func WithLogger(logger logrus.FieldLogger) Option {
110119
return func(a *API) {

api/client/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ type Client interface {
4040
ProcessLinuxUpgradeAirgap(ctx context.Context) (types.Airgap, error)
4141
GetLinuxUpgradeAirgapStatus(ctx context.Context) (types.Airgap, error)
4242

43+
// kURL Migration methods
44+
GetKURLMigrationConfig(ctx context.Context) (types.LinuxInstallationConfigResponse, error)
45+
StartKURLMigration(ctx context.Context, transferMode string, config *types.LinuxInstallationConfig) (types.StartKURLMigrationResponse, error)
46+
GetKURLMigrationStatus(ctx context.Context) (types.KURLMigrationStatusResponse, error)
47+
4348
GetKubernetesInstallationConfig(ctx context.Context) (types.KubernetesInstallationConfigResponse, error)
4449
ConfigureKubernetesInstallation(ctx context.Context, config types.KubernetesInstallationConfig) (types.Status, error)
4550
GetKubernetesInstallationStatus(ctx context.Context) (types.Status, error)

api/client/kurl_migration.go

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package client
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"encoding/json"
7+
"fmt"
8+
"net/http"
9+
10+
"github.com/replicatedhq/embedded-cluster/api/types"
11+
)
12+
13+
// GetKURLMigrationConfig returns the installation configuration with kURL values, EC defaults, and resolved values.
14+
func (c *client) GetKURLMigrationConfig(ctx context.Context) (types.LinuxInstallationConfigResponse, error) {
15+
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/api/linux/kurl-migration/config", c.apiURL), nil)
16+
if err != nil {
17+
return types.LinuxInstallationConfigResponse{}, fmt.Errorf("create request: %w", err)
18+
}
19+
setAuthorizationHeader(req, c.token)
20+
21+
resp, err := c.httpClient.Do(req)
22+
if err != nil {
23+
return types.LinuxInstallationConfigResponse{}, fmt.Errorf("do request: %w", err)
24+
}
25+
defer resp.Body.Close()
26+
27+
if resp.StatusCode != http.StatusOK {
28+
return types.LinuxInstallationConfigResponse{}, errorFromResponse(resp)
29+
}
30+
31+
var result types.LinuxInstallationConfigResponse
32+
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
33+
return types.LinuxInstallationConfigResponse{}, fmt.Errorf("decode response: %w", err)
34+
}
35+
36+
return result, nil
37+
}
38+
39+
// StartKURLMigration starts a new kURL to EC migration.
40+
func (c *client) StartKURLMigration(ctx context.Context, transferMode string, config *types.LinuxInstallationConfig) (types.StartKURLMigrationResponse, error) {
41+
requestBody := types.StartKURLMigrationRequest{
42+
TransferMode: types.TransferMode(transferMode),
43+
Config: config,
44+
}
45+
46+
body, err := json.Marshal(requestBody)
47+
if err != nil {
48+
return types.StartKURLMigrationResponse{}, fmt.Errorf("marshal request: %w", err)
49+
}
50+
51+
req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("%s/api/linux/kurl-migration/start", c.apiURL), bytes.NewReader(body))
52+
if err != nil {
53+
return types.StartKURLMigrationResponse{}, fmt.Errorf("create request: %w", err)
54+
}
55+
req.Header.Set("Content-Type", "application/json")
56+
setAuthorizationHeader(req, c.token)
57+
58+
resp, err := c.httpClient.Do(req)
59+
if err != nil {
60+
return types.StartKURLMigrationResponse{}, fmt.Errorf("do request: %w", err)
61+
}
62+
defer resp.Body.Close()
63+
64+
if resp.StatusCode != http.StatusOK {
65+
return types.StartKURLMigrationResponse{}, errorFromResponse(resp)
66+
}
67+
68+
var result types.StartKURLMigrationResponse
69+
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
70+
return types.StartKURLMigrationResponse{}, fmt.Errorf("decode response: %w", err)
71+
}
72+
73+
return result, nil
74+
}
75+
76+
// GetKURLMigrationStatus returns the current status of the kURL migration.
77+
func (c *client) GetKURLMigrationStatus(ctx context.Context) (types.KURLMigrationStatusResponse, error) {
78+
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/api/linux/kurl-migration/status", c.apiURL), nil)
79+
if err != nil {
80+
return types.KURLMigrationStatusResponse{}, fmt.Errorf("create request: %w", err)
81+
}
82+
setAuthorizationHeader(req, c.token)
83+
84+
resp, err := c.httpClient.Do(req)
85+
if err != nil {
86+
return types.KURLMigrationStatusResponse{}, fmt.Errorf("do request: %w", err)
87+
}
88+
defer resp.Body.Close()
89+
90+
if resp.StatusCode != http.StatusOK {
91+
return types.KURLMigrationStatusResponse{}, errorFromResponse(resp)
92+
}
93+
94+
var result types.KURLMigrationStatusResponse
95+
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
96+
return types.KURLMigrationStatusResponse{}, fmt.Errorf("decode response: %w", err)
97+
}
98+
99+
return result, nil
100+
}

0 commit comments

Comments
 (0)