Skip to content

Commit ca0b3c3

Browse files
Merge pull request #544 from replicatedhq/diamonwiggins/sc-44015/run-pod-service-account
Add ServiceAccountName parameter to Run collector
2 parents 9d41d4a + 2b774e1 commit ca0b3c3

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

pkg/apis/troubleshoot/v1beta2/collector_shared.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ type Data struct {
6565
}
6666

6767
type Run struct {
68-
CollectorMeta `json:",inline" yaml:",inline"`
69-
Name string `json:"name,omitempty" yaml:"name,omitempty"`
70-
Namespace string `json:"namespace" yaml:"namespace"`
71-
Image string `json:"image" yaml:"image"`
72-
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
73-
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
74-
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
75-
ImagePullPolicy string `json:"imagePullPolicy,omitempty" yaml:"imagePullPolicy,omitempty"`
76-
ImagePullSecret *ImagePullSecrets `json:"imagePullSecret,omitempty" yaml:"imagePullSecret,omitempty"`
68+
CollectorMeta `json:",inline" yaml:",inline"`
69+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
70+
Namespace string `json:"namespace" yaml:"namespace"`
71+
Image string `json:"image" yaml:"image"`
72+
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
73+
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
74+
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
75+
ImagePullPolicy string `json:"imagePullPolicy,omitempty" yaml:"imagePullPolicy,omitempty"`
76+
ImagePullSecret *ImagePullSecrets `json:"imagePullSecret,omitempty" yaml:"imagePullSecret,omitempty"`
77+
ServiceAccountName string `json:"serviceAccountName,omitempty" yaml:"serviceAccountName,omitempty"`
7778
}
7879

7980
type ImagePullSecrets struct {

pkg/collect/run.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ func runPod(ctx context.Context, client *kubernetes.Clientset, runCollector *tro
135135
namespace = "default"
136136
}
137137

138+
serviceAccountName := "default"
139+
if runCollector.ServiceAccountName != "" {
140+
serviceAccountName = runCollector.ServiceAccountName
141+
}
142+
138143
pod := corev1.Pod{
139144
ObjectMeta: metav1.ObjectMeta{
140145
Name: runCollector.CollectorName,
@@ -146,7 +151,8 @@ func runPod(ctx context.Context, client *kubernetes.Clientset, runCollector *tro
146151
Kind: "Pod",
147152
},
148153
Spec: corev1.PodSpec{
149-
RestartPolicy: corev1.RestartPolicyNever,
154+
RestartPolicy: corev1.RestartPolicyNever,
155+
ServiceAccountName: serviceAccountName,
150156
Containers: []corev1.Container{
151157
{
152158
Image: runCollector.Image,

0 commit comments

Comments
 (0)