Skip to content

Commit

Permalink
feat: etcd collector (#1589)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nvanthao authored Aug 12, 2024
1 parent 60263ca commit 47656a8
Show file tree
Hide file tree
Showing 12 changed files with 584 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ bin/analyze:
bin/collect:
go build ${BUILDFLAGS} ${LDFLAGS} -o bin/collect github.com/replicatedhq/troubleshoot/cmd/collect

build-linux: tidy
@echo "Build cli binaries for Linux"
GOOS=linux GOARCH=amd64 $(MAKE) -j bin/support-bundle bin/preflight bin/analyze bin/collect

.PHONY: fmt
fmt:
go fmt ${BUILDPATHS}
Expand Down
11 changes: 11 additions & 0 deletions config/crds/troubleshoot.sh_collectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,17 @@ spec:
timeout:
type: string
type: object
etcd:
properties:
collectorName:
type: string
exclude:
type: BoolString
image:
type: string
required:
- image
type: object
exec:
properties:
args:
Expand Down
11 changes: 11 additions & 0 deletions config/crds/troubleshoot.sh_preflights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,17 @@ spec:
timeout:
type: string
type: object
etcd:
properties:
collectorName:
type: string
exclude:
type: BoolString
image:
type: string
required:
- image
type: object
exec:
properties:
args:
Expand Down
11 changes: 11 additions & 0 deletions config/crds/troubleshoot.sh_supportbundles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,17 @@ spec:
timeout:
type: string
type: object
etcd:
properties:
collectorName:
type: string
exclude:
type: BoolString
image:
type: string
required:
- image
type: object
exec:
properties:
args:
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/troubleshoot/v1beta2/collector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ type DNS struct {
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

type Etcd struct {
CollectorMeta `json:",inline" yaml:",inline"`
Image string `json:"image" yaml:"image"`
}

type Collect struct {
ClusterInfo *ClusterInfo `json:"clusterInfo,omitempty" yaml:"clusterInfo,omitempty"`
ClusterResources *ClusterResources `json:"clusterResources,omitempty" yaml:"clusterResources,omitempty"`
Expand Down Expand Up @@ -329,6 +334,7 @@ type Collect struct {
Sonobuoy *Sonobuoy `json:"sonobuoy,omitempty" yaml:"sonobuoy,omitempty"`
NodeMetrics *NodeMetrics `json:"nodeMetrics,omitempty" yaml:"nodeMetrics,omitempty"`
DNS *DNS `json:"dns,omitempty" yaml:"dns,omitempty"`
Etcd *Etcd `json:"etcd,omitempty" yaml:"etcd,omitempty"`
}

func (c *Collect) AccessReviewSpecs(overrideNS string) []authorizationv1.SelfSubjectAccessReviewSpec {
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/collect/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func GetCollector(collector *troubleshootv1beta2.Collect, bundlePath string, nam
return &CollectNodeMetrics{collector.NodeMetrics, bundlePath, clientConfig, client, ctx, RBACErrors}, true
case collector.DNS != nil:
return &CollectDNS{collector.DNS, bundlePath, namespace, clientConfig, client, ctx, RBACErrors}, true
case collector.Etcd != nil:
return &CollectEtcd{collector.Etcd, bundlePath, clientConfig, client, ctx, RBACErrors}, true
default:
return nil, false
}
Expand Down Expand Up @@ -219,6 +221,8 @@ func getCollectorName(c interface{}) string {
collector = "node-metrics"
case *CollectDNS:
collector = "dns"
case *CollectEtcd:
collector = "etcd"
default:
collector = "<none>"
}
Expand Down
Loading

0 comments on commit 47656a8

Please sign in to comment.