Skip to content

Commit 0126fb7

Browse files
committed
Merge remote-tracking branch 'origin/master' into laverya/allow-analyzing-all-files-in-dir
2 parents 079765b + 2289e00 commit 0126fb7

File tree

160 files changed

+22170
-2356
lines changed

Some content is hidden

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

160 files changed

+22170
-2356
lines changed

.github/workflows/build-test-deploy.yaml

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/setup-go@v1
1616
with:
17-
go-version: "1.12.14"
17+
go-version: "1.14"
1818

1919
- name: setup env
2020
run: |
@@ -32,7 +32,7 @@ jobs:
3232
steps:
3333
- uses: actions/setup-go@v1
3434
with:
35-
go-version: '1.12.14'
35+
go-version: '1.14'
3636
- name: setup env
3737
run: |
3838
echo "::set-env name=GOPATH::$(go env GOPATH)"
@@ -56,7 +56,42 @@ jobs:
5656
path: bin/
5757
- uses: engineerd/[email protected]
5858
- run: chmod +x bin/preflight
59-
- run: bin/preflight --interactive=false --format=json https://preflight.replicated.com
59+
- run: ./bin/preflight --interactive=false --format=json https://preflight.replicated.com
60+
61+
compile-supportbundle:
62+
runs-on: ubuntu-latest
63+
needs: build
64+
steps:
65+
- uses: actions/setup-go@v1
66+
with:
67+
go-version: '1.14'
68+
- name: setup env
69+
run: |
70+
echo "::set-env name=GOPATH::$(go env GOPATH)"
71+
echo "::add-path::$(go env GOPATH)/bin"
72+
shell: bash
73+
- uses: actions/checkout@master
74+
- run: make support-bundle
75+
- uses: actions/upload-artifact@v1
76+
with:
77+
name: support-bundle
78+
path: bin/support-bundle
79+
80+
validate-supportbundle:
81+
runs-on: ubuntu-latest
82+
needs: compile-supportbundle
83+
steps:
84+
- uses: actions/checkout@v1
85+
- name: Download support-bundle binary
86+
uses: actions/download-artifact@v1
87+
with:
88+
name: support-bundle
89+
path: bin/
90+
- uses: engineerd/[email protected]
91+
- run: chmod +x bin/support-bundle
92+
- run: ./bin/support-bundle ./examples/support-bundle/sample-collectors.yaml
93+
- run: ./bin/support-bundle ./examples/support-bundle/sample-supportbundle.yaml
94+
- run: ./bin/support-bundle https://kots.io
6095

6196
goreleaser:
6297
runs-on: ubuntu-latest
@@ -77,12 +112,22 @@ jobs:
77112

78113
- uses: actions/setup-go@v1
79114
with:
80-
go-version: "1.12.14"
115+
go-version: "1.14"
81116

82117
- name: Run GoReleaser
83-
uses: goreleaser/goreleaser-action@v1
118+
uses: goreleaser/goreleaser-action@v2
84119
with:
85120
version: latest
86121
args: release --rm-dist --config deploy/.goreleaser.yaml
87122
env:
88-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
125+
126+
- name: Update new preflight version in krew-index
127+
uses: rajatjindal/[email protected]
128+
with:
129+
krew_template_file: deploy/krew/preflight.yaml
130+
- name: Update new support-bundle version in krew-index
131+
uses: rajatjindal/[email protected]
132+
with:
133+
krew_template_file: deploy/krew/support-bundle.yaml

Makefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,39 @@ vet:
6767

6868
.PHONY: generate
6969
generate: controller-gen client-gen
70-
$(shell go env GOPATH)/bin/controller-gen object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/...
71-
$(shell go env GOPATH)/bin/client-gen \
70+
$(CONTROLLER_GEN) \
71+
object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/...
72+
$(CLIENT_GEN) \
7273
--output-package=github.com/replicatedhq/troubleshoot/pkg/client \
7374
--clientset-name troubleshootclientset \
7475
--input-base github.com/replicatedhq/troubleshoot/pkg/apis \
7576
--input troubleshoot/v1beta1 \
77+
--input troubleshoot/v1beta2 \
7678
-h ./hack/boilerplate.go.txt
7779

7880
.PHONY: openapischema
7981
openapischema: controller-gen
8082
controller-gen crd +output:dir=./config/crds paths=./pkg/apis/troubleshoot/v1beta1
83+
controller-gen crd +output:dir=./config/crds paths=./pkg/apis/troubleshoot/v1beta2
8184

8285
.PHONY: schemas
8386
schemas: fmt vet openapischema
8487
go build ${LDFLAGS} -o bin/schemagen github.com/replicatedhq/troubleshoot/cmd/schemagen
8588
./bin/schemagen --output-dir ./schemas
8689

87-
# find or download controller-gen
88-
# download controller-gen if necessary
90+
.PHONY: contoller-gen
8991
controller-gen:
9092
ifeq (, $(shell which controller-gen))
91-
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.8
93+
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0
9294
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
9395
else
9496
CONTROLLER_GEN=$(shell which controller-gen)
9597
endif
9698

97-
# find or download client-gen
99+
.PHONY: client-gen
98100
client-gen:
99101
ifeq (, $(shell which client-gen))
100-
go get k8s.io/code-generator/cmd/client-gen@kubernetes-1.16.4
102+
go get k8s.io/code-generator/cmd/client-gen@kubernetes-1.18.0
101103
CLIENT_GEN=$(shell go env GOPATH)/bin/client-gen
102104
else
103105
CLIENT_GEN=$(shell which client-gen)
@@ -128,8 +130,8 @@ run-preflight: preflight
128130

129131
.PHONY: run-troubleshoot
130132
run-troubleshoot: support-bundle
131-
./bin/support-bundle ./examples/troubleshoot/sample-troubleshoot.yaml
133+
./bin/support-bundle ./examples/support-bundle/sample-supportbundle.yaml
132134

133135
.PHONY: run-analyze
134136
run-analyze: analyze
135-
./bin/analyze --analyzers ./examples/troubleshoot/sample-analyzers.yaml ./support-bundle.tar.gz
137+
./bin/analyze --analyzers ./examples/support-bundle/sample-analyzers.yaml ./support-bundle.tar.gz

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Replicated Troubleshoot
22

3-
Replicated Troubleshoot is a framework for collecting, redacting and analyzing highly customizable diagnostic information about a Kubernetes cluster. Troubleshoot specs are created by 3rd-party application developers/maintainers and run by cluster operators in the initial and ongoing operation of those applications.
3+
Replicated Troubleshoot is a framework for collecting, redacting, and analyzing highly customizable diagnostic information about a Kubernetes cluster. Troubleshoot specs are created by 3rd-party application developers/maintainers and run by cluster operators in the initial and ongoing operation of those applications.
44

5-
Troubleshoot provides two CLI tools as kubectl plugins (using [Krew](https://krew.dev)) `kubectl preflight` and `kubectl support-bundle`. Preflight provides pre-installation cluster conformance testing and validation (preflight checks) and support-bundle provides post-installation troubleshooting and diagnostics (support bundles).
5+
Troubleshoot provides two CLI tools as kubectl plugins (using [Krew](https://krew.dev)): `kubectl preflight` and `kubectl support-bundle`. Preflight provides pre-installation cluster conformance testing and validation (preflight checks) and support-bundle provides post-installation troubleshooting and diagnostics (support bundles).
66

77
## Preflight Checks
88
Preflight checks are an easy-to-run set of conformance tests that can be written to verify that specific requirements in a cluster are met.
@@ -18,11 +18,11 @@ curl https://krew.sh/preflight | bash
1818
kubectl preflight https://preflight.replicated.com
1919
```
2020

21-
For a details on creating the custom resource files that drive preflight checks, visit [creating preflight checks](https://troubleshoot.sh/docs/preflight/creating/).
21+
For a details on creating the custom resource files that drive preflight checks, visit [creating preflight checks](https://troubleshoot.sh/docs/preflight/introduction/).
2222

2323

2424
## Support Bundle
25-
A support bundle is an archive that's created in-cluster, by collecting logs, cluster information and executing specified commands (including redaction of sensitive information). After creating a support bundle, the cluster operator will normally deliver it to the 3rd-party application vendor for analysis and disconnected debugging. Another Replicated project, [Kotsadm](https://github.com/replicatedhq/kotsadm), provides cluster operators with in-cluster UI for processing support bundles and viewing analyzers (as well as support bundle collection).
25+
A support bundle is an archive that's created in-cluster, by collecting logs and cluster information, and executing specified commands (including redaction of sensitive information). After creating a support bundle, the cluster operator will normally deliver it to the 3rd-party application vendor for analysis and disconnected debugging. Another Replicated project, [Kotsadm](https://github.com/replicatedhq/kotsadm), provides cluster operators with an in-cluster UI for processing support bundles and viewing analyzers (as well as support bundle collection).
2626

2727
To collect a sample support bundle, install the troubleshoot kubectl plugin:
2828

@@ -32,9 +32,9 @@ curl https://krew.sh/support-bundle | bash
3232
and run:
3333

3434
```shell
35-
kubectl support-bundle https://troubleshoot.replicated.com
35+
kubectl support-bundle https://support-bundle.replicated.com
3636
```
37-
For details on creating the custom resource files that drive support-bundle collection [creating collectors](https://troubleshoot.sh/reference/collectors/overview/) and for analyzers [creating analyzers](https://troubleshoot.sh/reference/analyzers/overview/).
37+
For details on creating the custom resource files that drive support-bundle collection, visit [creating collectors](https://troubleshoot.sh/docs/collect/) and [creating analyzers](https://troubleshoot.sh/docs/analyze/).
3838

3939
# Community
4040

cmd/preflight/cli/interactive_results.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import (
55
"io/ioutil"
66
"os"
77
"path"
8-
"strings"
98
"time"
109

11-
ui "github.com/gizak/termui/v3"
12-
"github.com/gizak/termui/v3/widgets"
1310
"github.com/pkg/errors"
11+
ui "github.com/replicatedhq/termui/v3"
12+
"github.com/replicatedhq/termui/v3/widgets"
1413
"github.com/replicatedhq/troubleshoot/cmd/util"
1514
analyzerunner "github.com/replicatedhq/troubleshoot/pkg/analyze"
1615
)
1716

1817
var (
1918
selectedResult = 0
19+
table = widgets.NewTable()
2020
isShowingSaved = false
2121
)
2222

@@ -64,15 +64,19 @@ func showInteractiveResults(preflightName string, analyzeResults []*analyzerunne
6464
selectedResult++
6565
} else {
6666
selectedResult = 0
67+
table.SelectedRow = 0
6768
}
69+
table.ScrollDown()
6870
ui.Clear()
6971
drawUI(preflightName, analyzeResults)
7072
case "<Up>":
7173
if selectedResult > 0 {
7274
selectedResult--
7375
} else {
7476
selectedResult = len(analyzeResults) - 1
77+
table.SelectedRow = len(analyzeResults)
7578
}
79+
table.ScrollUp()
7680
ui.Clear()
7781
drawUI(preflightName, analyzeResults)
7882
}
@@ -95,7 +99,7 @@ func drawHeader(preflightName string) {
9599
termWidth, _ := ui.TerminalDimensions()
96100

97101
title := widgets.NewParagraph()
98-
title.Text = fmt.Sprintf("%s Preflight Checks", appName(preflightName))
102+
title.Text = fmt.Sprintf("%s Preflight Checks", util.AppName(preflightName))
99103
title.TextStyle.Fg = ui.ColorWhite
100104
title.TextStyle.Bg = ui.ColorClear
101105
title.TextStyle.Modifier = ui.ModifierBold
@@ -127,7 +131,6 @@ func drawFooter() {
127131
func drawPreflightTable(analyzeResults []*analyzerunner.AnalyzeResult) {
128132
termWidth, termHeight := ui.TerminalDimensions()
129133

130-
table := widgets.NewTable()
131134
table.SetRect(0, 3, termWidth/2, termHeight-6)
132135
table.FillRow = true
133136
table.Border = true
@@ -221,7 +224,7 @@ func save(preflightName string, analyzeResults []*analyzerunner.AnalyzeResult) (
221224
os.Remove(filename)
222225
}
223226

224-
results := fmt.Sprintf("%s Preflight Checks\n\n", appName(preflightName))
227+
results := fmt.Sprintf("%s Preflight Checks\n\n", util.AppName(preflightName))
225228
for _, analyzeResult := range analyzeResults {
226229
result := ""
227230

@@ -270,19 +273,3 @@ func showSaved(filename string) {
270273

271274
isShowingSaved = true
272275
}
273-
274-
func appName(preflightName string) string {
275-
words := strings.Split(strings.Title(strings.Replace(preflightName, "-", " ", -1)), " ")
276-
casedWords := []string{}
277-
for i, word := range words {
278-
if strings.ToLower(word) == "ai" {
279-
casedWords = append(casedWords, "AI")
280-
} else if strings.ToLower(word) == "io" && i > 0 {
281-
casedWords[i-1] += ".io"
282-
} else {
283-
casedWords = append(casedWords, word)
284-
}
285-
}
286-
287-
return strings.Join(casedWords, " ")
288-
}

cmd/preflight/cli/root.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,10 @@ that a cluster meets the requirements to run an application.`,
3636

3737
cmd.Flags().Bool("interactive", true, "interactive preflights")
3838
cmd.Flags().String("format", "human", "output format, one of human, json, yaml. only used when interactive is set to false")
39-
cmd.Flags().String("preflight", "", "name of the preflight to use")
40-
cmd.Flags().String("image", "", "the full name of the preflight image to use")
41-
cmd.Flags().String("pullpolicy", "", "the pull policy of the preflight image")
4239
cmd.Flags().String("collector-image", "", "the full name of the collector image to use")
4340
cmd.Flags().String("collector-pullpolicy", "", "the pull policy of the collector image")
4441
cmd.Flags().Bool("collect-without-permissions", false, "always run preflight checks even if some require permissions that preflight does not have")
4542

46-
cmd.Flags().String("serviceaccount", "", "name of the service account to use. if not provided, one will be created")
47-
4843
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
4944

5045
KubernetesConfigFlags = genericclioptions.NewConfigFlags(false)

cmd/preflight/cli/run.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111
"github.com/fatih/color"
1212
"github.com/pkg/errors"
1313
"github.com/replicatedhq/troubleshoot/cmd/util"
14-
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
14+
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1515
troubleshootclientsetscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme"
16+
"github.com/replicatedhq/troubleshoot/pkg/docrewrite"
1617
"github.com/replicatedhq/troubleshoot/pkg/preflight"
1718
"github.com/spf13/viper"
1819
spin "github.com/tj/go-spin"
@@ -23,15 +24,15 @@ func runPreflights(v *viper.Viper, arg string) error {
2324
fmt.Print(cursor.Hide())
2425
defer fmt.Print(cursor.Show())
2526

26-
preflightContent := ""
27+
var preflightContent []byte
2728
var err error
2829
if _, err = os.Stat(arg); err == nil {
2930
b, err := ioutil.ReadFile(arg)
3031
if err != nil {
3132
return err
3233
}
3334

34-
preflightContent = string(b)
35+
preflightContent = b
3536
} else {
3637
if !util.IsURL(arg) {
3738
return fmt.Errorf("%s is not a URL and was not found (err %s)", arg, err)
@@ -41,7 +42,7 @@ func runPreflights(v *viper.Viper, arg string) error {
4142
if err != nil {
4243
return err
4344
}
44-
req.Header.Set("User-Agent", "Replicated_Preflight/v1beta1")
45+
req.Header.Set("User-Agent", "Replicated_Preflight/v1beta2")
4546
resp, err := http.DefaultClient.Do(req)
4647
if err != nil {
4748
return err
@@ -53,7 +54,12 @@ func runPreflights(v *viper.Viper, arg string) error {
5354
return err
5455
}
5556

56-
preflightContent = string(body)
57+
preflightContent = body
58+
}
59+
60+
preflightContent, err = docrewrite.ConvertToV1Beta2(preflightContent)
61+
if err != nil {
62+
return errors.Wrap(err, "failed to convert to v1beta2")
5763
}
5864

5965
troubleshootclientsetscheme.AddToScheme(scheme.Scheme)
@@ -63,7 +69,7 @@ func runPreflights(v *viper.Viper, arg string) error {
6369
return errors.Wrapf(err, "failed to parse %s", arg)
6470
}
6571

66-
preflightSpec := obj.(*troubleshootv1beta1.Preflight)
72+
preflightSpec := obj.(*troubleshootv1beta2.Preflight)
6773

6874
s := spin.New()
6975
finishedCh := make(chan bool, 1)

0 commit comments

Comments
 (0)