Skip to content

Commit 5daf6d6

Browse files
authored
Feat: new collector run-daemonset (#1460)
* feat: new collector run-daemonset
1 parent 8b491b5 commit 5daf6d6

11 files changed

+44838
-0
lines changed

config/crds/troubleshoot.sh_collectors.yaml

Lines changed: 8513 additions & 0 deletions
Large diffs are not rendered by default.

config/crds/troubleshoot.sh_preflights.yaml

Lines changed: 8513 additions & 0 deletions
Large diffs are not rendered by default.

config/crds/troubleshoot.sh_supportbundles.yaml

Lines changed: 8513 additions & 0 deletions
Large diffs are not rendered by default.

pkg/apis/troubleshoot/v1beta2/collector_shared.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ type RunPod struct {
107107
PodSpec corev1.PodSpec `json:"podSpec,omitempty" yaml:"podSpec,omitempty"`
108108
}
109109

110+
type RunDaemonSet struct {
111+
CollectorMeta `json:",inline" yaml:",inline"`
112+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
113+
Namespace string `json:"namespace" yaml:"namespace"`
114+
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
115+
ImagePullSecret *ImagePullSecrets `json:"imagePullSecret,omitempty" yaml:"imagePullSecret,omitempty"`
116+
PodSpec corev1.PodSpec `json:"podSpec,omitempty" yaml:"podSpec,omitempty"`
117+
}
118+
110119
type ImagePullSecrets struct {
111120
Name string `json:"name,omitempty" yaml:"name,omitempty"`
112121
Data map[string]string `json:"data,omitempty" yaml:"data,omitempty"`
@@ -282,6 +291,7 @@ type Collect struct {
282291
Logs *Logs `json:"logs,omitempty" yaml:"logs,omitempty"`
283292
Run *Run `json:"run,omitempty" yaml:"run,omitempty"`
284293
RunPod *RunPod `json:"runPod,omitempty" yaml:"runPod,omitempty"`
294+
RunDaemonSet *RunDaemonSet `json:"runDaemonSet,omitempty" yaml:"runDaemonSet,omitempty"`
285295
Exec *Exec `json:"exec,omitempty" yaml:"exec,omitempty"`
286296
Data *Data `json:"data,omitempty" yaml:"data,omitempty"`
287297
Copy *Copy `json:"copy,omitempty" yaml:"copy,omitempty"`
@@ -432,6 +442,19 @@ func (c *Collect) AccessReviewSpecs(overrideNS string) []authorizationv1.SelfSub
432442
},
433443
NonResourceAttributes: nil,
434444
})
445+
} else if c.RunDaemonSet != nil {
446+
result = append(result, authorizationv1.SelfSubjectAccessReviewSpec{
447+
ResourceAttributes: &authorizationv1.ResourceAttributes{
448+
Namespace: pickNamespaceOrDefault(c.RunDaemonSet.Namespace, overrideNS),
449+
Verb: "create",
450+
Group: "",
451+
Version: "",
452+
Resource: "pods",
453+
Subresource: "",
454+
Name: "",
455+
},
456+
NonResourceAttributes: nil,
457+
})
435458
} else if c.Exec != nil {
436459
result = append(result, authorizationv1.SelfSubjectAccessReviewSpec{
437460
ResourceAttributes: &authorizationv1.ResourceAttributes{
@@ -542,6 +565,10 @@ func (c *Collect) GetName() string {
542565
collector = "run-pod"
543566
name = c.RunPod.CollectorName
544567
}
568+
if c.RunDaemonSet != nil {
569+
collector = "run-daemonset"
570+
name = c.RunDaemonSet.CollectorName
571+
}
545572
if c.Exec != nil {
546573
collector = "exec"
547574
name = c.Exec.CollectorName

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

Lines changed: 27 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func GetCollector(collector *troubleshootv1beta2.Collect, bundlePath string, nam
7575
return &CollectRun{collector.Run, bundlePath, namespace, clientConfig, client, ctx, RBACErrors}, true
7676
case collector.RunPod != nil:
7777
return &CollectRunPod{collector.RunPod, bundlePath, namespace, clientConfig, client, ctx, RBACErrors}, true
78+
case collector.RunDaemonSet != nil:
79+
return &CollectRunDaemonSet{collector.RunDaemonSet, bundlePath, namespace, clientConfig, client, ctx, RBACErrors}, true
7880
case collector.Exec != nil:
7981
return &CollectExec{collector.Exec, bundlePath, namespace, clientConfig, client, ctx, RBACErrors}, true
8082
case collector.Data != nil:
@@ -152,6 +154,9 @@ func getCollectorName(c interface{}) string {
152154
case *CollectRunPod:
153155
collector = "run-pod"
154156
name = v.Collector.CollectorName
157+
case *CollectRunDaemonSet:
158+
collector = "run-daemonset"
159+
name = v.Collector.CollectorName
155160
case *CollectExec:
156161
collector = "exec"
157162
name = v.Collector.CollectorName

0 commit comments

Comments
 (0)