Skip to content

Commit f5f74fb

Browse files
authored
feat: no longer ship kubectl, instead alias k0s, use /var/lib/embedded-cluster (#378)
* no longer export kubeconfig, instead alias k0s * fix shell command * simple * conf dir? * undo go changes * reinclude kubeconfig, do not ship kubectl * use /usr/local/bin/k0s kubectl directly in scripts * use symlink method * update ln * undo reset change * ln only required after install * fix shell alias * move bins to /var/lib/embedded-cluster/bin * panic for stack traces * move call to defaults.BinaryName out of compile time constants * remove unused config dir, lazy init bins dir * remove the new bins dir on reset * link k0s during install * link kubectl -> k0s on join * remove alias from shell command * reinclude bins dir in test * move logs to /var/lib/embedded-cluster too * use the helpful helper function * add info to sudo test * run version test command as non-root * non-root handling * better non-root handling * do not include embedded cluster ID in metadata output * ensure embeddedClusterID is not in metadata output * ensure embeddedClusterID is not in metadata _values_ output * don't include embeddedBinaryName in default metadata output either
1 parent 563c586 commit f5f74fb

20 files changed

+72
-89
lines changed

.github/workflows/dependencies.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ jobs:
2323
run: |
2424
export VERSION=`curl https://api.github.com/repos/openebs/charts/releases/latest | jq -r .name | tr -d openebs-`
2525
sed -i "/^OPENEBS_CHART_VERSION/c\OPENEBS_CHART_VERSION = $VERSION" Makefile
26-
- name: Kubectl
27-
run: |
28-
export VERSION=`curl -L -s https://dl.k8s.io/release/stable.txt`
29-
sed -i "/^KUBECTL_VERSION/c\KUBECTL_VERSION = $VERSION" Makefile
3026
- name: K0s
3127
run: |
3228
# Remove the '-ec.X' suffix and only update if the prefix (upstream k0s release) has changed.

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ EMBEDDED_OPERATOR_CHART_VERSION = 0.22.7
1313
OPENEBS_CHART_URL = https://openebs.github.io/charts
1414
OPENEBS_CHART_NAME = openebs/openebs
1515
OPENEBS_CHART_VERSION = 3.10.0
16-
KUBECTL_VERSION = v1.29.2
1716
K0S_VERSION = v1.29.1+k0s.1
1817
K0S_BINARY_SOURCE_OVERRIDE =
1918
TROUBLESHOOT_VERSION = v0.83.0
@@ -45,12 +44,6 @@ pkg/goods/bins/k0s: Makefile
4544
chmod +x pkg/goods/bins/k0s
4645
touch pkg/goods/bins/k0s
4746

48-
pkg/goods/bins/kubectl: Makefile
49-
mkdir -p pkg/goods/bins
50-
curl -L -o pkg/goods/bins/kubectl "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
51-
chmod +x pkg/goods/bins/kubectl
52-
touch pkg/goods/bins/kubectl
53-
5447
pkg/goods/bins/kubectl-support_bundle: Makefile
5548
mkdir -p pkg/goods/bins
5649
mkdir -p output/tmp/support-bundle
@@ -82,7 +75,6 @@ embedded-release: embedded-cluster-linux-amd64 output/tmp/release.tar.gz output/
8275
.PHONY: static
8376
static: pkg/goods/bins/k0s \
8477
pkg/goods/bins/kubectl-preflight \
85-
pkg/goods/bins/kubectl \
8678
pkg/goods/bins/kubectl-support_bundle
8779

8880
.PHONY: embedded-cluster-linux-amd64

cmd/embedded-cluster/install.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ func runOutro(c *cli.Context) error {
257257
return addons.NewApplier(opts...).Outro(c.Context)
258258
}
259259

260+
// linkK0s is a helper function that links the k0s binary to the embedded cluster bins dir as 'kubectl'.
261+
func linkK0s() error {
262+
if err := os.Symlink(defaults.K0sBinaryPath(), defaults.PathToEmbeddedClusterBinary("kubectl")); err != nil {
263+
return fmt.Errorf("unable to create symlink: %w", err)
264+
}
265+
266+
return nil
267+
}
268+
260269
// installCommands executes the "install" command. This will ensure that a k0s.yaml file exists
261270
// and then run `k0s install` to apply the cluster. Once this is finished then a "kubeconfig"
262271
// file is created. Resulting kubeconfig is stored in the configuration dir.
@@ -339,6 +348,11 @@ var installCommand = &cli.Command{
339348
metrics.ReportApplyFinished(c, err)
340349
return err
341350
}
351+
logrus.Debugf("linking k0s binary")
352+
if err := linkK0s(); err != nil {
353+
metrics.ReportApplyFinished(c, err)
354+
return err
355+
}
342356
metrics.ReportApplyFinished(c, nil)
343357
return nil
344358
},

cmd/embedded-cluster/join.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ var joinCommand = &cli.Command{
182182
return err
183183
}
184184

185+
logrus.Debugf("linking k0s binary")
186+
if err := linkK0s(); err != nil {
187+
metrics.ReportJoinFailed(c.Context, jcmd.MetricsBaseURL, jcmd.ClusterID, err)
188+
return err
189+
}
190+
185191
metrics.ReportJoinSucceeded(c.Context, jcmd.MetricsBaseURL, jcmd.ClusterID)
186192
logrus.Infof("Join finished")
187193
return nil

e2e/scripts/check-installation-state.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ main() {
3838

3939
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
4040
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
41-
export PATH=$PATH:/root/.config/embedded-cluster/bin
41+
export PATH=$PATH:/var/lib/embedded-cluster/bin
4242
main

e2e/scripts/check-nodes-removed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ main() {
3232

3333
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
3434
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
35-
export PATH=$PATH:/root/.config/embedded-cluster/bin
35+
export PATH=$PATH:/var/lib/embedded-cluster/bin
3636
main "$@"

e2e/scripts/check-postupgrade-state.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ main() {
7878

7979
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
8080
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
81-
export PATH=$PATH:/root/.config/embedded-cluster/bin
81+
export PATH=$PATH:/var/lib/embedded-cluster/bin
8282
main "$@"

e2e/scripts/default-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ main() {
8585

8686
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
8787
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
88-
export PATH=$PATH:/root/.config/embedded-cluster/bin
88+
export PATH=$PATH:/var/lib/embedded-cluster/bin
8989
main

e2e/scripts/embedded-preflight.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,5 @@ main() {
189189

190190
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
191191
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
192-
export PATH=$PATH:/root/.config/embedded-cluster/bin
192+
export PATH=$PATH:/var/lib/embedded-cluster/bin
193193
main

e2e/scripts/single-node-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,5 @@ main() {
164164

165165
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
166166
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
167-
export PATH=$PATH:/root/.config/embedded-cluster/bin
167+
export PATH=$PATH:/var/lib/embedded-cluster/bin
168168
main

0 commit comments

Comments
 (0)