Skip to content

Commit 0d792a9

Browse files
feat: including support-bundle binary (#81)
we are including support-bundle binary from now on. this commit also renames the `preflight` binary to `kubectl-preflight` so it properly behaves as a kubectl plugin (same for support-bundle binary).
1 parent 11f0392 commit 0d792a9

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

Makefile

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ K0SCTL_VERSION = v0.15.5
77
TERRAFORM_VERSION = 1.5.4
88
OPENEBS_VERSION = 3.7.0
99
K0S_VERSION = v1.27.5+k0s.0
10-
PREFLIGHT_VERSION = v0.71.1
10+
TROUBLESHOOT_VERSION = v0.72.0
1111
LD_FLAGS = -X github.com/replicatedhq/helmvm/pkg/defaults.K0sVersion=$(K0S_VERSION) -X main.Version=$(VERSION)
1212

1313
default: helmvm-linux-amd64
@@ -95,28 +95,49 @@ pkg/goods/bins/helmvm/k0sctl-darwin-arm64:
9595
curl -L -o pkg/goods/bins/helmvm/k0sctl-darwin-arm64 "https://github.com/k0sproject/k0sctl/releases/download/$(K0SCTL_VERSION)/k0sctl-darwin-arm64"
9696
chmod +x pkg/goods/bins/helmvm/k0sctl-darwin-arm64
9797

98-
pkg/goods/bins/helmvm/preflight:
98+
pkg/goods/bins/helmvm/kubectl-support_bundle-linux-amd64:
99+
mkdir -p pkg/goods/bins/helmvm
100+
mkdir -p output/tmp/support-bundle
101+
curl -L -o output/tmp/support-bundle/support-bundle.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/support-bundle_linux_amd64.tar.gz
102+
tar -xzf output/tmp/support-bundle/support-bundle.tar.gz -C output/tmp/support-bundle
103+
mv output/tmp/support-bundle/support-bundle pkg/goods/bins/helmvm/kubectl-support_bundle-linux-amd64
104+
105+
pkg/goods/bins/helmvm/kubectl-support_bundle-darwin-amd64:
106+
mkdir -p pkg/goods/bins/helmvm
107+
mkdir -p output/tmp/support-bundle
108+
curl -L -o output/tmp/support-bundle/support-bundle.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/support-bundle_darwin_amd64.tar.gz
109+
tar -xzf output/tmp/support-bundle/support-bundle.tar.gz -C output/tmp/support-bundle
110+
mv output/tmp/support-bundle/support-bundle pkg/goods/bins/helmvm/kubectl-support_bundle-darwin-amd64
111+
112+
pkg/goods/bins/helmvm/kubectl-support_bundle-darwin-arm64:
113+
mkdir -p pkg/goods/bins/helmvm
114+
mkdir -p output/tmp/support-bundle
115+
curl -L -o output/tmp/support-bundle/support-bundle.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/support-bundle_darwin_arm64.tar.gz
116+
tar -xzf output/tmp/support-bundle/support-bundle.tar.gz -C output/tmp/support-bundle
117+
mv output/tmp/support-bundle/support-bundle pkg/goods/bins/helmvm/kubectl-support_bundle-darwin-arm64
118+
119+
pkg/goods/bins/helmvm/kubectl-preflight:
99120
mkdir -p pkg/goods/bins/helmvm
100121
mkdir -p output/tmp/preflight
101-
curl -L -o output/tmp/preflight/preflight.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(PREFLIGHT_VERSION)/preflight_linux_amd64.tar.gz
122+
curl -L -o output/tmp/preflight/preflight.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/preflight_linux_amd64.tar.gz
102123
tar -xzf output/tmp/preflight/preflight.tar.gz -C output/tmp/preflight
103-
mv output/tmp/preflight/preflight pkg/goods/bins/helmvm/preflight
124+
mv output/tmp/preflight/preflight pkg/goods/bins/helmvm/kubectl-preflight
104125

105126
.PHONY: static
106127
static: pkg/addons/adminconsole/charts/adminconsole-$(ADMIN_CONSOLE_CHART_VERSION).tgz \
107128
output/bin/yq \
108-
pkg/goods/bins/helmvm/preflight \
129+
pkg/goods/bins/helmvm/kubectl-preflight \
109130
pkg/goods/bins/k0sctl/k0s-$(K0S_VERSION) \
110131
pkg/goods/images/list.txt
111132

112133
.PHONY: static-darwin-arm64
113-
static-darwin-arm64: pkg/goods/bins/helmvm/kubectl-darwin-arm64 pkg/goods/bins/helmvm/k0sctl-darwin-arm64 pkg/goods/bins/helmvm/terraform-darwin-arm64
134+
static-darwin-arm64: pkg/goods/bins/helmvm/kubectl-darwin-arm64 pkg/goods/bins/helmvm/k0sctl-darwin-arm64 pkg/goods/bins/helmvm/terraform-darwin-arm64 pkg/goods/bins/helmvm/kubectl-support_bundle-darwin-arm64
114135

115136
.PHONY: static-darwin-amd64
116-
static-darwin-amd64: pkg/goods/bins/helmvm/kubectl-darwin-amd64 pkg/goods/bins/helmvm/k0sctl-darwin-amd64 pkg/goods/bins/helmvm/terraform-darwin-amd64
137+
static-darwin-amd64: pkg/goods/bins/helmvm/kubectl-darwin-amd64 pkg/goods/bins/helmvm/k0sctl-darwin-amd64 pkg/goods/bins/helmvm/terraform-darwin-amd64 pkg/goods/bins/helmvm/kubectl-support_bundle-darwin-amd64
117138

118139
.PHONY: static-linux-amd64
119-
static-linux-amd64: pkg/goods/bins/helmvm/kubectl-linux-amd64 pkg/goods/bins/helmvm/k0sctl-linux-amd64 pkg/goods/bins/helmvm/terraform-linux-amd64
140+
static-linux-amd64: pkg/goods/bins/helmvm/kubectl-linux-amd64 pkg/goods/bins/helmvm/k0sctl-linux-amd64 pkg/goods/bins/helmvm/terraform-linux-amd64 pkg/goods/bins/helmvm/kubectl-support_bundle-linux-amd64
120141

121142
.PHONY: helmvm-linux-amd64
122143
helmvm-linux-amd64: static static-linux-amd64

pkg/goods/goods.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func Materialize() error {
5050
suffix := fmt.Sprintf("-%s-%s", runtime.GOOS, runtime.GOARCH)
5151
for _, entry := range entries {
5252
if entry.IsDir() || !strings.HasSuffix(entry.Name(), suffix) {
53-
// we always materialize 'preflight' binary because
53+
// we always materialize 'kubectl-preflight' binary because
5454
// we run it remotely in the configured cluster nodes.
55-
if entry.Name() != "preflight" {
55+
if entry.Name() != "kubectl-preflight" {
5656
continue
5757
}
5858
}

pkg/preflights/preflights.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"io"
1010
"os"
1111
"os/exec"
12+
"path"
13+
"path/filepath"
1214
"runtime"
1315

1416
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
@@ -68,7 +70,7 @@ func RunLocal(ctx context.Context, spec *v1beta2.HostPreflightSpec) (*Output, er
6870
return nil, fmt.Errorf("unable to save preflight locally: %w", err)
6971
}
7072
defer os.Remove(fpath)
71-
binpath := defaults.PathToHelmVMBinary("preflight")
73+
binpath := defaults.PathToHelmVMBinary("kubectl-preflight")
7274
stdout := bytes.NewBuffer(nil)
7375
cmd := exec.Command(binpath, "--interactive=false", "--format=json", fpath)
7476
cmd.Stdout, cmd.Stderr = stdout, io.Discard
@@ -97,8 +99,9 @@ func Run(ctx context.Context, host *cluster.Host, spec *v1beta2.HostPreflightSpe
9799
if err := uploadFile(host, fpath, "/tmp/helmvm-preflight.yaml", 0600); err != nil {
98100
return nil, err
99101
}
100-
binpath := defaults.PathToHelmVMBinary("preflight")
101-
if err := uploadFile(host, binpath, "/tmp/preflight", 0755); err != nil {
102+
src := defaults.PathToHelmVMBinary("kubectl-preflight")
103+
dst := path.Join("/tmp", filepath.Base(src))
104+
if err := uploadFile(host, src, dst, 0755); err != nil {
102105
return nil, err
103106
}
104107
return execute(host)
@@ -134,7 +137,7 @@ func execute(host *cluster.Host) (*Output, error) {
134137
}
135138
defer host.Disconnect()
136139
arg := "--interactive=false --format=json"
137-
cmd := fmt.Sprintf("/tmp/preflight %s /tmp/helmvm-preflight.yaml 2>/dev/null", arg)
140+
cmd := fmt.Sprintf("/tmp/kubectl-preflight %s /tmp/helmvm-preflight.yaml 2>/dev/null", arg)
138141
var err error
139142
out := bytes.NewBuffer(nil)
140143
opts := []rexec.Option{rexec.Sudo(host), rexec.Writer(out)}

0 commit comments

Comments
 (0)