Skip to content

Commit dc884e9

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-28-9
2 parents 124d8db + aeb9d05 commit dc884e9

File tree

9 files changed

+166
-77
lines changed

9 files changed

+166
-77
lines changed

.github/workflows/pull-request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run: |
2020
make vet
2121
- name: Lint
22-
uses: golangci/golangci-lint-action@v5
22+
uses: golangci/golangci-lint-action@v6
2323
with:
2424
version: v1.54
2525
tests:

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ADMIN_CONSOLE_IMAGE_OVERRIDE =
99
ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE =
1010
EMBEDDED_OPERATOR_CHART_URL = oci://registry.replicated.com/library
1111
EMBEDDED_OPERATOR_CHART_NAME = embedded-cluster-operator
12-
EMBEDDED_OPERATOR_CHART_VERSION = 0.30.5
12+
EMBEDDED_OPERATOR_CHART_VERSION = 0.31.1
1313
EMBEDDED_OPERATOR_UTILS_IMAGE = busybox:1.36.1
1414
EMBEDDED_CLUSTER_OPERATOR_IMAGE_OVERRIDE =
1515
OPENEBS_CHART_URL = https://openebs.github.io/openebs
@@ -22,14 +22,14 @@ REGISTRY_CHART_VERSION = 2.2.3
2222
REGISTRY_IMAGE_VERSION = 2.8.3
2323
VELERO_CHART_URL = https://vmware-tanzu.github.io/helm-charts
2424
VELERO_CHART_NAME = vmware-tanzu/velero
25-
VELERO_CHART_VERSION = 6.0.0
25+
VELERO_CHART_VERSION = 6.3.0
2626
VELERO_IMAGE_VERSION = v1.13.2
2727
VELERO_AWS_PLUGIN_IMAGE_VERSION = v1.9.2
2828
KUBECTL_VERSION = v1.28.9
2929
K0S_VERSION = v1.28.9+k0s.0
3030
PREVIOUS_K0S_VERSION ?= v1.28.8+k0s.0
3131
K0S_BINARY_SOURCE_OVERRIDE =
32-
TROUBLESHOOT_VERSION = v0.92.0
32+
TROUBLESHOOT_VERSION = v0.92.1
3333
KOTS_VERSION = v$(shell echo $(ADMIN_CONSOLE_CHART_VERSION) | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/')
3434
LD_FLAGS = -X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sVersion=$(K0S_VERSION) \
3535
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.Version=$(VERSION) \

cmd/embedded-cluster/restore.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,19 @@ var restoreCommand = &cli.Command{
684684
if err := waitForK0s(); err != nil {
685685
return fmt.Errorf("unable to wait for node: %w", err)
686686
}
687+
688+
kcli, err := kubeutils.KubeClient()
689+
if err != nil {
690+
return fmt.Errorf("unable to create kube client: %w", err)
691+
}
692+
errCh := kubeutils.WaitForKubernetes(c.Context, kcli)
693+
defer func() {
694+
for len(errCh) > 0 {
695+
err := <-errCh
696+
logrus.Error(fmt.Errorf("infrastructure failed to become ready: %w", err))
697+
}
698+
}()
699+
687700
logrus.Debugf("running outro")
688701
if err := runOutroForRestore(c); err != nil {
689702
return fmt.Errorf("unable to run outro: %w", err)

e2e/scripts/unsupported-overrides.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ spec:
5151
name: admin-console
5252
namespace: kotsadm
5353
order: 3
54-
version: 1.108.0-build.1
54+
version: 1.109.3
5555
values: |
5656
isHelmManaged: false
5757
minimalRBAC: false
5858
service:
5959
nodePort: 30000
6060
type: NodePort
61+
passwordSecretRef:
62+
name: kotsadm-password
63+
key: passwordBcrypt
6164
- chartname: oci://registry-1.docker.io/bitnamicharts/memcached
6265
name: memcached
6366
namespace: embedded-cluster

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/canonical/lxd v0.0.0-20230814092713-c77ee90f5032
99
github.com/coreos/go-systemd/v22 v22.5.0
1010
github.com/creack/pty v1.1.21
11-
github.com/fatih/color v1.16.0
11+
github.com/fatih/color v1.17.0
1212
github.com/google/uuid v1.6.0
1313
github.com/gosimple/slug v1.14.0
1414
github.com/jedib0t/go-pretty v4.3.0+incompatible
@@ -18,7 +18,7 @@ require (
1818
github.com/replicatedhq/embedded-cluster-operator v0.31.1
1919
github.com/replicatedhq/embedded-cluster-utils v1.0.0
2020
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe
21-
github.com/replicatedhq/troubleshoot v0.92.0
21+
github.com/replicatedhq/troubleshoot v0.92.1
2222
github.com/sirupsen/logrus v1.9.3
2323
github.com/stretchr/testify v1.9.0
2424
github.com/urfave/cli/v2 v2.27.2
@@ -28,7 +28,7 @@ require (
2828
gopkg.in/yaml.v2 v2.4.0
2929
gopkg.in/yaml.v3 v3.0.1
3030
k8s.io/api v0.30.0
31-
k8s.io/apimachinery v0.30.0
31+
k8s.io/apimachinery v0.30.1
3232
oras.land/oras-go/v2 v2.5.0
3333
sigs.k8s.io/controller-runtime v0.18.2
3434
sigs.k8s.io/yaml v1.4.0

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lSh
4444
github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
4545
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
4646
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
47-
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
48-
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
47+
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
48+
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
4949
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 h1:fmFk0Wt3bBxxwZnu48jqMdaOR/IZ4vdtJFuaFV8MpIE=
5050
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3/go.mod h1:bJWSKrZyQvfTnb2OudyUjurSG4/edverV7n82+K3JiM=
5151
github.com/frankban/quicktest v1.0.0/go.mod h1:R98jIehRai+d1/3Hv2//jOVCTJhW1VBavT6B6CuGq2k=
@@ -259,8 +259,8 @@ github.com/replicatedhq/embedded-cluster-utils v1.0.0 h1:Axdni1nYfl5zeOP9g5U79yv
259259
github.com/replicatedhq/embedded-cluster-utils v1.0.0/go.mod h1:4JmMC2CwMCLxq05GEW3XSPPVotqyamAF/omrbB3pH+c=
260260
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe h1:3AJInd06UxzqHmgy8+24CPsT2tYSE0zToJZyuX9q+MA=
261261
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe/go.mod h1:QjhIUu3+OmHZ09u09j3FCoTt8F3BYtQglS+OLmftu9I=
262-
github.com/replicatedhq/troubleshoot v0.92.0 h1:hi0uA/1lO7h8DPOwXqzXNC8g8h7bvVgu3n4gPU+VZ/4=
263-
github.com/replicatedhq/troubleshoot v0.92.0/go.mod h1:ZKwwgdoe9SQFNBAzkJGzslnKy2hN4o7gp36UMY54+Lw=
262+
github.com/replicatedhq/troubleshoot v0.92.1 h1:TjO/NGM/TZRim2chVbW2mGbVbyOZ/qV8KBeApJwdqUc=
263+
github.com/replicatedhq/troubleshoot v0.92.1/go.mod h1:aPdpP2+V8HCHt3V6ozdeAcMAifzOQqN1siQ5Pc5XY0w=
264264
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
265265
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
266266
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@@ -489,8 +489,8 @@ k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA=
489489
k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE=
490490
k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs=
491491
k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y=
492-
k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA=
493-
k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
492+
k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U=
493+
k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
494494
k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ=
495495
k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY=
496496
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=

pkg/addons/adminconsole/adminconsole.go

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1414
"github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1515
"github.com/sirupsen/logrus"
16+
"golang.org/x/crypto/bcrypt"
1617
"gopkg.in/yaml.v3"
1718
corev1 "k8s.io/api/core/v1"
1819
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -42,6 +43,7 @@ var (
4243
ImageOverride = ""
4344
MigrationsImageOverride = ""
4445
CounterRegex = regexp.MustCompile(`(\d+)/(\d+)`)
46+
Password = ""
4547
)
4648

4749
// protectedFields are helm values that are not overwritten when upgrading the addon.
@@ -64,6 +66,10 @@ var helmValues = map[string]interface{}{
6466
"replicated.com/disaster-recovery": "infra",
6567
"replicated.com/disaster-recovery-chart": "kotsadm",
6668
},
69+
"passwordSecretRef": map[string]interface{}{
70+
"name": "kotsadm-password",
71+
"key": "passwordBcrypt",
72+
},
6773
}
6874

6975
func init() {
@@ -160,31 +166,16 @@ func (a *AdminConsole) GetCurrentChartConfig() *v1beta1.Chart {
160166
return nil
161167
}
162168

163-
// addPasswordToHelmValues adds the adminconsole password to the helm values.
164-
func (a *AdminConsole) addPasswordToHelmValues() error {
165-
curconfig := a.GetCurrentChartConfig()
166-
if curconfig == nil {
167-
pass, err := a.askPassword()
168-
if err != nil {
169-
return fmt.Errorf("unable to ask password: %w", err)
170-
}
171-
helmValues["password"] = pass
172-
return nil
173-
}
174-
pass, err := getPasswordFromConfig(curconfig)
175-
if err != nil {
176-
return fmt.Errorf("unable to get password from current config: %w", err)
177-
}
178-
helmValues["password"] = pass
179-
return nil
180-
}
181-
182169
// GenerateHelmConfig generates the helm config for the adminconsole and writes the charts to
183170
// the disk.
184171
func (a *AdminConsole) GenerateHelmConfig(onlyDefaults bool) ([]v1beta1.Chart, []v1beta1.Repository, error) {
185172
if !onlyDefaults {
186-
if err := a.addPasswordToHelmValues(); err != nil {
187-
return nil, nil, fmt.Errorf("unable to add password to helm values: %w", err)
173+
if Password == "" {
174+
var err error
175+
Password, err = a.askPassword()
176+
if err != nil {
177+
return nil, nil, fmt.Errorf("unable to set kotsadm-password: %w", err)
178+
}
188179
}
189180
helmValues["embeddedClusterID"] = metrics.ClusterID().String()
190181
if a.airgapBundle != "" {
@@ -218,6 +209,10 @@ func (a *AdminConsole) Outro(ctx context.Context, cli client.Client) error {
218209
loading.Infof("Waiting for Admin Console to deploy")
219210
defer loading.Close()
220211

212+
if err := createKotsPasswordSecret(ctx, cli, a.namespace, Password); err != nil {
213+
return fmt.Errorf("unable to create kots password secret: %w", err)
214+
}
215+
221216
if a.airgapBundle != "" {
222217
err := createRegistrySecret(ctx, cli, a.namespace)
223218
if err != nil {
@@ -330,10 +325,47 @@ func createRegistrySecret(ctx context.Context, cli client.Client, namespace stri
330325
},
331326
Type: "kubernetes.io/dockerconfigjson",
332327
}
328+
333329
err := cli.Create(ctx, &registryCreds)
334330
if err != nil {
335331
return fmt.Errorf("unable to create registry-auth secret: %w", err)
336332
}
337333

338334
return nil
339335
}
336+
337+
func createKotsPasswordSecret(ctx context.Context, cli client.Client, namespace string, password string) error {
338+
if err := kubeutils.WaitForNamespace(ctx, cli, namespace); err != nil {
339+
return err
340+
}
341+
342+
passwordBcrypt, err := bcrypt.GenerateFromPassword([]byte(password), 10)
343+
if err != nil {
344+
return fmt.Errorf("unable to generate bcrypt from password: %w", err)
345+
}
346+
347+
kotsPasswordSecret := corev1.Secret{
348+
TypeMeta: metav1.TypeMeta{
349+
Kind: "Secret",
350+
APIVersion: "v1",
351+
},
352+
ObjectMeta: metav1.ObjectMeta{
353+
Name: "kotsadm-password",
354+
Namespace: namespace,
355+
Labels: map[string]string{
356+
"kots.io/kotsadm": "true",
357+
"replicated.com/disaster-recovery": "infra",
358+
},
359+
},
360+
Data: map[string][]byte{
361+
"passwordBcrypt": []byte(passwordBcrypt),
362+
},
363+
}
364+
365+
err = cli.Create(ctx, &kotsPasswordSecret)
366+
if err != nil {
367+
return fmt.Errorf("unable to create kotsadm-password secret: %w", err)
368+
}
369+
370+
return nil
371+
}

pkg/addons/applier.go

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ package addons
66
import (
77
"context"
88
"fmt"
9-
"time"
10-
119
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1210
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1311
embeddedclusterv1beta1 "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1"
1412
"github.com/replicatedhq/embedded-cluster-kinds/types"
1513
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1614
"github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1715
"github.com/sirupsen/logrus"
18-
corev1 "k8s.io/api/core/v1"
1916
"sigs.k8s.io/controller-runtime/pkg/client"
2017

2118
"github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole"
@@ -62,6 +59,15 @@ func (a *Applier) Outro(ctx context.Context) error {
6259
if err != nil {
6360
return fmt.Errorf("unable to load addons: %w", err)
6461
}
62+
63+
errCh := kubeutils.WaitForKubernetes(ctx, kcli)
64+
defer func() {
65+
for len(errCh) > 0 {
66+
err := <-errCh
67+
logrus.Error(fmt.Errorf("infrastructure failed to become ready: %w", err))
68+
}
69+
}()
70+
6571
for _, addon := range addons {
6672
if err := addon.Outro(ctx, kcli); err != nil {
6773
return err
@@ -319,39 +325,6 @@ func (a *Applier) Versions(additionalCharts []v1beta1.Chart) (map[string]string,
319325
return versions, nil
320326
}
321327

322-
// waitForKubernetes waits until we manage to make a successful connection to the
323-
// Kubernetes API server.
324-
func (a *Applier) waitForKubernetes(ctx context.Context) error {
325-
loading := spinner.Start()
326-
defer func() {
327-
loading.Closef("Kubernetes API server is ready")
328-
}()
329-
kcli, err := kubeutils.KubeClient()
330-
if err != nil {
331-
return fmt.Errorf("unable to create kubernetes client: %w", err)
332-
}
333-
ticker := time.NewTicker(3 * time.Second)
334-
defer ticker.Stop()
335-
counter := 1
336-
loading.Infof("1/n Waiting for Kubernetes API server to be ready")
337-
for {
338-
select {
339-
case <-ticker.C:
340-
case <-ctx.Done():
341-
return ctx.Err()
342-
}
343-
counter++
344-
if err := kcli.List(ctx, &corev1.NamespaceList{}); err != nil {
345-
loading.Infof(
346-
"%d/n Waiting for Kubernetes API server to be ready.",
347-
counter,
348-
)
349-
continue
350-
}
351-
return nil
352-
}
353-
}
354-
355328
func spinForInstallation(ctx context.Context, cli client.Client) error {
356329
installSpin := spinner.Start()
357330
installSpin.Infof("Waiting for additional components to be ready")

0 commit comments

Comments
 (0)