Skip to content

Commit 47656a8

Browse files
authored
feat: etcd collector (#1589)
* new schema for etcd collector * add placeholder * wip * get supported distribution * add exec implementation * wait for etcd pod to be ready * misc * update k0s etcd certs path * fix unit tests * address code reviews * update from code review * add etcdctl version
1 parent 60263ca commit 47656a8

12 files changed

+584
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ bin/analyze:
114114
bin/collect:
115115
go build ${BUILDFLAGS} ${LDFLAGS} -o bin/collect github.com/replicatedhq/troubleshoot/cmd/collect
116116

117+
build-linux: tidy
118+
@echo "Build cli binaries for Linux"
119+
GOOS=linux GOARCH=amd64 $(MAKE) -j bin/support-bundle bin/preflight bin/analyze bin/collect
120+
117121
.PHONY: fmt
118122
fmt:
119123
go fmt ${BUILDPATHS}

config/crds/troubleshoot.sh_collectors.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,17 @@ spec:
301301
timeout:
302302
type: string
303303
type: object
304+
etcd:
305+
properties:
306+
collectorName:
307+
type: string
308+
exclude:
309+
type: BoolString
310+
image:
311+
type: string
312+
required:
313+
- image
314+
type: object
304315
exec:
305316
properties:
306317
args:

config/crds/troubleshoot.sh_preflights.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,17 @@ spec:
20302030
timeout:
20312031
type: string
20322032
type: object
2033+
etcd:
2034+
properties:
2035+
collectorName:
2036+
type: string
2037+
exclude:
2038+
type: BoolString
2039+
image:
2040+
type: string
2041+
required:
2042+
- image
2043+
type: object
20332044
exec:
20342045
properties:
20352046
args:

config/crds/troubleshoot.sh_supportbundles.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,17 @@ spec:
20612061
timeout:
20622062
type: string
20632063
type: object
2064+
etcd:
2065+
properties:
2066+
collectorName:
2067+
type: string
2068+
exclude:
2069+
type: BoolString
2070+
image:
2071+
type: string
2072+
required:
2073+
- image
2074+
type: object
20642075
exec:
20652076
properties:
20662077
args:

pkg/apis/troubleshoot/v1beta2/collector_shared.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ type DNS struct {
299299
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
300300
}
301301

302+
type Etcd struct {
303+
CollectorMeta `json:",inline" yaml:",inline"`
304+
Image string `json:"image" yaml:"image"`
305+
}
306+
302307
type Collect struct {
303308
ClusterInfo *ClusterInfo `json:"clusterInfo,omitempty" yaml:"clusterInfo,omitempty"`
304309
ClusterResources *ClusterResources `json:"clusterResources,omitempty" yaml:"clusterResources,omitempty"`
@@ -329,6 +334,7 @@ type Collect struct {
329334
Sonobuoy *Sonobuoy `json:"sonobuoy,omitempty" yaml:"sonobuoy,omitempty"`
330335
NodeMetrics *NodeMetrics `json:"nodeMetrics,omitempty" yaml:"nodeMetrics,omitempty"`
331336
DNS *DNS `json:"dns,omitempty" yaml:"dns,omitempty"`
337+
Etcd *Etcd `json:"etcd,omitempty" yaml:"etcd,omitempty"`
332338
}
333339

334340
func (c *Collect) AccessReviewSpecs(overrideNS string) []authorizationv1.SelfSubjectAccessReviewSpec {

pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/collect/collector.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ func GetCollector(collector *troubleshootv1beta2.Collect, bundlePath string, nam
126126
return &CollectNodeMetrics{collector.NodeMetrics, bundlePath, clientConfig, client, ctx, RBACErrors}, true
127127
case collector.DNS != nil:
128128
return &CollectDNS{collector.DNS, bundlePath, namespace, clientConfig, client, ctx, RBACErrors}, true
129+
case collector.Etcd != nil:
130+
return &CollectEtcd{collector.Etcd, bundlePath, clientConfig, client, ctx, RBACErrors}, true
129131
default:
130132
return nil, false
131133
}
@@ -219,6 +221,8 @@ func getCollectorName(c interface{}) string {
219221
collector = "node-metrics"
220222
case *CollectDNS:
221223
collector = "dns"
224+
case *CollectEtcd:
225+
collector = "etcd"
222226
default:
223227
collector = "<none>"
224228
}

0 commit comments

Comments
 (0)