Skip to content

Commit da71887

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-28-7
2 parents 43a133f + 63539b6 commit da71887

22 files changed

+540
-125
lines changed

.github/workflows/dependencies.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
steps:
1212
- name: Check out repo
1313
uses: actions/checkout@v4
14+
- name: Set up Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: "1.21"
1418
- name: AdminConsole
1519
run: |
1620
export VERSION=`curl https://api.github.com/repos/replicatedhq/kots-helm/tags | jq -r .[].name | grep -v alpha | head -1 | tr -d v`
@@ -35,6 +39,7 @@ jobs:
3539
if [ "$CURVERSION" != "$VERSION" ]; then
3640
sed -i "/^K0S_VERSION/c\K0S_VERSION = $VERSION" Makefile
3741
sed -i "/^K0S_BINARY_SOURCE_OVERRIDE/c\K0S_BINARY_SOURCE_OVERRIDE =" Makefile
42+
go get github.com/k0sproject/k0s@${VERSION}
3843
fi
3944
- name: Troubleshoot
4045
run: |

.github/workflows/pull-request.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Pull request
22
on:
33
- pull_request
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
6+
cancel-in-progress: true
47
jobs:
58
sanitize:
69
name: Sanitize
@@ -50,6 +53,8 @@ jobs:
5053
- name: Build Linux AMD64
5154
run: |
5255
make embedded-cluster-linux-amd64 VERSION=dev-$SHORT_SHA
56+
- name: Output Metadata
57+
run: |
5358
./output/bin/embedded-cluster version metadata > metadata.json
5459
- name: Install Replicated CLI
5560
run: |
@@ -61,7 +66,6 @@ jobs:
6166
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
6267
mv replicated /usr/local/bin/replicated
6368
- name: Create CI Releases
64-
if: github.actor != 'dependabot[bot]'
6569
env:
6670
REPLICATED_APP: "embedded-cluster-smoke-test-staging-app"
6771
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
@@ -72,10 +76,12 @@ jobs:
7276
sed -i "s/__version_string__/${SHORT_SHA}/g" e2e/kots-release-install/cluster-config.yaml
7377
sed -i "s/__version_string__/${SHORT_SHA}-upgrade/g" e2e/kots-release-upgrade/cluster-config.yaml
7478
79+
# re-promote a release containing an old version of embedded-cluster to test upgrades
80+
replicated release promote 807 2cHXb1RCttzpR0xvnNWyaZCgDBP --version "${SHORT_SHA}-pre-minio-removal"
81+
7582
replicated release create --yaml-dir e2e/kots-release-install --promote CI --version "${SHORT_SHA}"
7683
replicated release create --yaml-dir e2e/kots-release-upgrade --promote CI --version "${SHORT_SHA}-upgrade"
7784
- name: Build CI binary
78-
if: github.actor != 'dependabot[bot]'
7985
run: |
8086
export SHORT_SHA=$(git rev-parse --short=7 HEAD)
8187
echo "# channel release object" > e2e/kots-release-install/release.yaml
@@ -86,7 +92,6 @@ jobs:
8692
cp output/bin/embedded-cluster output/bin/embedded-cluster-original
8793
make embedded-release # this is done after the metadata.json is generated so as to not include additional charts
8894
- name: Cache files for integration test
89-
if: github.actor != 'dependabot[bot]'
9095
env:
9196
S3_BUCKET: "tf-staging-embedded-cluster-bin"
9297
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
@@ -128,6 +133,7 @@ jobs:
128133
- TestInstallWithoutEmbed
129134
- TestResetAndReinstall
130135
- TestCollectSupportBundle
136+
- TestOldVersionUpgrade
131137
steps:
132138
- name: Checkout
133139
uses: actions/checkout@v4
@@ -137,7 +143,6 @@ jobs:
137143
name: embedded-release
138144
path: output/bin
139145
- uses: ./.github/actions/e2e
140-
if: github.actor != 'dependabot[bot]'
141146
with:
142147
test-name: '${{ matrix.tests }}'
143148
license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE_ID }}

.github/workflows/release-dev.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
run: |
2222
make embedded-cluster-linux-amd64
2323
tar -C output/bin -czvf embedded-cluster-linux-amd64.tgz embedded-cluster
24+
- name: Output Metadata
25+
run: |
2426
./output/bin/embedded-cluster version metadata > metadata.json
2527
- name: Publish development release
2628
uses: marvinpinto/action-automatic-releases@latest
@@ -42,7 +44,6 @@ jobs:
4244
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
4345
mv replicated /usr/local/bin/replicated
4446
- name: Create CI Releases
45-
if: github.actor != 'dependabot[bot]'
4647
env:
4748
REPLICATED_APP: "embedded-cluster-smoke-test-staging-app"
4849
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
@@ -52,11 +53,13 @@ jobs:
5253
echo "${SHORT_SHA}"
5354
sed -i "s/__version_string__/${SHORT_SHA}/g" e2e/kots-release-install/cluster-config.yaml
5455
sed -i "s/__version_string__/${SHORT_SHA}-upgrade/g" e2e/kots-release-upgrade/cluster-config.yaml
56+
57+
# re-promote a release containing an old version of embedded-cluster to test upgrades
58+
replicated release promote 807 2cHXb1RCttzpR0xvnNWyaZCgDBP --version "${SHORT_SHA}-pre-minio-removal"
5559
5660
replicated release create --yaml-dir e2e/kots-release-install --promote CI --version "${SHORT_SHA}"
5761
replicated release create --yaml-dir e2e/kots-release-upgrade --promote CI --version "${SHORT_SHA}-upgrade"
5862
- name: Build CI binary
59-
if: github.actor != 'dependabot[bot]'
6063
run: |
6164
export SHORT_SHA=$(git rev-parse --short=7 HEAD)
6265
echo "# channel release object" > e2e/kots-release-install/release.yaml
@@ -67,7 +70,6 @@ jobs:
6770
cp output/bin/embedded-cluster output/bin/embedded-cluster-original
6871
make embedded-release # this is done after the metadata.json is generated so as to not include additional charts
6972
- name: Cache files for integration test
70-
if: github.actor != 'dependabot[bot]'
7173
env:
7274
S3_BUCKET: "tf-staging-embedded-cluster-bin"
7375
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
@@ -109,6 +111,7 @@ jobs:
109111
- TestInstallFromReplicatedApp
110112
- TestResetAndReinstall
111113
- TestCollectSupportBundle
114+
- TestOldVersionUpgrade
112115
steps:
113116
- name: Checkout
114117
uses: actions/checkout@v4

.github/workflows/release-prod.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
run: |
2424
make embedded-cluster-linux-amd64 VERSION=$TAG_NAME
2525
tar -C output/bin -czvf embedded-cluster-linux-amd64.tgz embedded-cluster
26+
- name: Output Metadata
27+
run: |
2628
./output/bin/embedded-cluster version metadata > metadata.json
2729
- name: Cache Staging Files
2830
env:

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARCH := $(shell uname -m)
44
APP_NAME = embedded-cluster
55
ADMIN_CONSOLE_CHART_URL = oci://registry.replicated.com/library
66
ADMIN_CONSOLE_CHART_NAME = admin-console
7-
ADMIN_CONSOLE_CHART_VERSION = 1.107.8
7+
ADMIN_CONSOLE_CHART_VERSION = 1.108.0-build.1
88
ADMIN_CONSOLE_IMAGE_OVERRIDE =
99
ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE =
1010
EMBEDDED_OPERATOR_CHART_URL = oci://registry.replicated.com/library
@@ -20,6 +20,8 @@ TROUBLESHOOT_VERSION = v0.83.0
2020
LD_FLAGS = -X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sVersion=$(K0S_VERSION) \
2121
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.Version=$(VERSION) \
2222
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sBinaryURL=$(K0S_BINARY_SOURCE_OVERRIDE) \
23+
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.TroubleshootVersion=$(TROUBLESHOOT_VERSION) \
24+
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.KubectlVersion=$(KUBECTL_VERSION) \
2325
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ChartURL=$(ADMIN_CONSOLE_CHART_URL) \
2426
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ChartName=$(ADMIN_CONSOLE_CHART_NAME) \
2527
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.Version=$(ADMIN_CONSOLE_CHART_VERSION) \
@@ -79,20 +81,24 @@ output/bin/embedded-cluster-release-builder:
7981
embedded-release: embedded-cluster-linux-amd64 output/tmp/release.tar.gz output/bin/embedded-cluster-release-builder
8082
./output/bin/embedded-cluster-release-builder output/bin/embedded-cluster output/tmp/release.tar.gz output/bin/embedded-cluster
8183

84+
go.mod: Makefile
85+
go get github.com/k0sproject/k0s@$(K0S_VERSION)
86+
go mod tidy
87+
8288
.PHONY: static
8389
static: pkg/goods/bins/k0s \
8490
pkg/goods/bins/kubectl-preflight \
8591
pkg/goods/bins/kubectl \
8692
pkg/goods/bins/kubectl-support_bundle
8793

8894
.PHONY: embedded-cluster-linux-amd64
89-
embedded-cluster-linux-amd64: static
95+
embedded-cluster-linux-amd64: static go.mod
9096
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LD_FLAGS)" -o ./output/bin/$(APP_NAME) ./cmd/embedded-cluster
9197

9298
# for testing
93-
.PHONY: embedded-cluster-darwin-amd64
94-
embedded-cluster-darwin-amd64:
95-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LD_FLAGS)" -o ./output/bin/$(APP_NAME) ./cmd/embedded-cluster
99+
.PHONY: embedded-cluster-darwin-arm64
100+
embedded-cluster-darwin-arm64: go.mod
101+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$(LD_FLAGS)" -o ./output/bin/$(APP_NAME) ./cmd/embedded-cluster
96102

97103
.PHONY: unit-tests
98104
unit-tests:

cmd/embedded-cluster/install.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,15 @@ func checkLicenseMatches(c *cli.Context) error {
162162
// createK0sConfig creates a new k0s.yaml configuration file. The file is saved in the
163163
// global location (as returned by defaults.PathToK0sConfig()). If a file already sits
164164
// there, this function returns an error.
165-
func ensureK0sConfig(c *cli.Context, useprompt bool) error {
165+
func ensureK0sConfig(c *cli.Context) error {
166166
cfgpath := defaults.PathToK0sConfig()
167167
if _, err := os.Stat(cfgpath); err == nil {
168168
return fmt.Errorf("configuration file already exists")
169169
}
170170
if err := os.MkdirAll(filepath.Dir(cfgpath), 0755); err != nil {
171171
return fmt.Errorf("unable to create directory: %w", err)
172172
}
173-
cfg, err := config.RenderK0sConfig(c.Context)
174-
if err != nil {
175-
return fmt.Errorf("unable to render config: %w", err)
176-
}
173+
cfg := config.RenderK0sConfig()
177174
opts := []addons.Option{}
178175
if c.Bool("no-prompt") {
179176
opts = append(opts, addons.WithoutPrompt())
@@ -188,6 +185,7 @@ func ensureK0sConfig(c *cli.Context, useprompt bool) error {
188185
if err := config.UpdateHelmConfigs(cfg, opts...); err != nil {
189186
return fmt.Errorf("unable to update helm configs: %w", err)
190187
}
188+
var err error
191189
if cfg, err = applyUnsupportedOverrides(c, cfg); err != nil {
192190
return fmt.Errorf("unable to apply unsupported overrides: %w", err)
193191
}
@@ -320,9 +318,10 @@ var installCommand = &cli.Command{
320318
Hidden: true,
321319
},
322320
&cli.StringFlag{
323-
Name: "license",
324-
Usage: "Path to the application license file",
325-
Hidden: false,
321+
Name: "license",
322+
Aliases: []string{"l"},
323+
Usage: "Path to the application license file",
324+
Hidden: false,
326325
},
327326
},
328327
Action: func(c *cli.Context) error {
@@ -356,7 +355,7 @@ var installCommand = &cli.Command{
356355
return err
357356
}
358357
logrus.Debugf("creating k0s configuration file")
359-
if err := ensureK0sConfig(c, !c.Bool("no-prompt")); err != nil {
358+
if err := ensureK0sConfig(c); err != nil {
360359
err := fmt.Errorf("unable to create config file: %w", err)
361360
metrics.ReportApplyFinished(c, err)
362361
return err
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package types
2+
3+
import "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
4+
5+
// ReleaseMetadata holds the metadata about a specific release, including addons and
6+
// their versions.
7+
type ReleaseMetadata struct {
8+
Versions map[string]string
9+
K0sSHA string
10+
K0sBinaryURL string
11+
K0sImages []string
12+
Configs v1beta1.HelmExtensions
13+
Protected map[string][]string
14+
}

cmd/embedded-cluster/version.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"strings"
88

99
"github.com/jedib0t/go-pretty/table"
10+
"github.com/k0sproject/k0s/pkg/airgap"
11+
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1012
"github.com/urfave/cli/v2"
1113

12-
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
14+
"github.com/replicatedhq/embedded-cluster/cmd/embedded-cluster/types"
1315
"github.com/replicatedhq/embedded-cluster/pkg/addons"
1416
"github.com/replicatedhq/embedded-cluster/pkg/config"
1517
"github.com/replicatedhq/embedded-cluster/pkg/defaults"
@@ -53,16 +55,6 @@ var versionCommand = &cli.Command{
5355
},
5456
}
5557

56-
// ReleaseMetadata holds the metadata about a specific release, including addons and
57-
// their versions.
58-
type ReleaseMetadata struct {
59-
Versions map[string]string
60-
K0sSHA string
61-
K0sBinaryURL string
62-
Configs k0sconfig.HelmExtensions
63-
Protected map[string][]string
64-
}
65-
6658
var metadataCommand = &cli.Command{
6759
Name: "metadata",
6860
Usage: "Print metadata about this release",
@@ -75,6 +67,8 @@ var metadataCommand = &cli.Command{
7567
}
7668
versions["Kubernetes"] = defaults.K0sVersion
7769
versions["Installer"] = defaults.Version
70+
versions["Troubleshoot"] = defaults.TroubleshootVersion
71+
versions["Kubectl"] = defaults.KubectlVersion
7872
channelRelease, err := release.GetChannelRelease()
7973
if err == nil && channelRelease != nil {
8074
versions[defaults.BinaryName()] = channelRelease.VersionLabel
@@ -83,7 +77,7 @@ var metadataCommand = &cli.Command{
8377
if err != nil {
8478
return fmt.Errorf("unable to get k0s binary sha256: %w", err)
8579
}
86-
meta := ReleaseMetadata{
80+
meta := types.ReleaseMetadata{
8781
Versions: versions,
8882
K0sSHA: sha,
8983
K0sBinaryURL: defaults.K0sBinaryURL,
@@ -103,6 +97,14 @@ var metadataCommand = &cli.Command{
10397
return fmt.Errorf("unable to get protected fields: %w", err)
10498
}
10599
meta.Protected = protectedFields
100+
101+
// Render k0s config to get the images contained within
102+
k0sConfig := config.RenderK0sConfig()
103+
if err != nil {
104+
return fmt.Errorf("unable to render k0s config: %w", err)
105+
}
106+
meta.K0sImages = airgap.GetImageURIs(k0sConfig.Spec, true)
107+
106108
data, err := json.MarshalIndent(meta, "", "\t")
107109
if err != nil {
108110
return fmt.Errorf("unable to marshal versions: %w", err)

docs/resources.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Embedded Cluster Custom Resources
2+
Controlling resources utilized inside embedded cluster
3+
4+
## ClusterConfig
5+
- **Owner**: k0s
6+
- **Namespace**: kube-system
7+
8+
The `ClusterConfig` object contains the ingested k0s config from `/etc/k0s/k0s.yaml`
9+
10+
This ingestion happens at k0s daemon startup on controller nodes.
11+
12+
It can be dynamically updated, and the k0s config reconciliation process will apply any changes to the cluster except from `spec.api` and `spec.storage`.
13+
14+
The [embedded cluster operator](https://github.com/replicatedhq/embedded-cluster-operator/) reconciles helm chart updates against the `ClusterConfig` object to initiate helm chart upgrades via the k0s helm reconciler.
15+
16+
## Chart
17+
- **Owner**: k0s
18+
- **Namespace**: kube-system
19+
20+
The `Chart` object contains the spec, values and tracking information for helm charts installed by the [k0s helm reconciler](https://docs.k0sproject.io/head/helm-charts/); they can be created, deleted and updated. Deleting a `Chart` object will uninstall the related helm chart from the cluster, however if the helm chart configuration is still present in the `ClusterConfig` the k0s reconciliation process will recreate/reinstall it.
21+
22+
`Chart` Objects are currently only managed by the k0s helm reconciler, and it’s best to leave it that way for now as the API / schema for these resources is not documented.
23+
24+
`Chart` Objects are monitored by the Embedded Cluster Operator in order to track and surface helm installation processes and errors.
25+
26+
## Plan
27+
- **Owner**: k0s
28+
- **Cluster scoped object**
29+
30+
`Plan` objects are used to configure the k0s autopilot operator, the autopilot operator controls cluster version upgrades via distributing and installing new k0s binaries and airgap bundles.
31+
32+
The `Plan` resource is created by the Embedded Cluster Operator using details from the `Installation` object.
33+
34+
## Installation
35+
- **Owner**: Replicated
36+
- **Cluster scoped object**
37+
38+
The `Installation` object is used by the Embedded Cluster Operator to both initiate and track cluster and helm chart upgrades. they are created by [KOTS](https://github.com/replicatedhq/kots), and are marked as `Obsolete` when superseded by a newer `Installation` object.
39+
40+
The `Installation` object can contain errors surfaced from the `Plan` and `Chart` resources.
41+
42+
Possible Installation statuses can be found here: https://github.com/replicatedhq/embedded-cluster-operator/blob/e4fbb42919ad3b58cdc563dca77471cf76099393/api/v1beta1/installation_types.go#L24

0 commit comments

Comments
 (0)