Skip to content

Commit 8d5b983

Browse files
authored
Support image pull secrets (grafana#145)
* define input for imagePullSecrets * assign imagePullSecrets to each job type * update manifest template * add ignore for vscode * take imagePullSecrets out of spec * formatting
1 parent df4c9d5 commit 8d5b983

File tree

7 files changed

+44
-11
lines changed

7 files changed

+44
-11
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ bin
2424
/manager
2525

2626
kubebuilder-tools-*
27+
28+
.vscode

api/v1alpha1/k6_types.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ type PodMetadata struct {
2525
}
2626

2727
type Pod struct {
28-
Affinity *corev1.Affinity `json:"affinity,omitempty"`
29-
AutomountServiceAccountToken string `json:"automountServiceAccountToken,omitempty"`
30-
Env []corev1.EnvVar `json:"env,omitempty"`
31-
Image string `json:"image,omitempty"`
32-
Metadata PodMetadata `json:"metadata,omitempty"`
33-
NodeSelector map[string]string `json:"nodeselector,omitempty"`
34-
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
35-
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
36-
ServiceAccountName string `json:"serviceAccountName,omitempty"`
37-
SecurityContext corev1.PodSecurityContext `json:"securityContext,omitempty"`
38-
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
28+
Affinity *corev1.Affinity `json:"affinity,omitempty"`
29+
AutomountServiceAccountToken string `json:"automountServiceAccountToken,omitempty"`
30+
Env []corev1.EnvVar `json:"env,omitempty"`
31+
Image string `json:"image,omitempty"`
32+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
33+
Metadata PodMetadata `json:"metadata,omitempty"`
34+
NodeSelector map[string]string `json:"nodeselector,omitempty"`
35+
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
36+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
37+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
38+
SecurityContext corev1.PodSecurityContext `json:"securityContext,omitempty"`
39+
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
3940
}
4041

4142
type K6Scuttle struct {

api/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/k6.io_k6s.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,17 @@ spec:
848848
type: array
849849
image:
850850
type: string
851+
imagePullSecrets:
852+
items:
853+
description: LocalObjectReference contains enough information
854+
to let you locate the referenced object inside the same namespace.
855+
properties:
856+
name:
857+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
858+
TODO: Add other useful fields. apiVersion, kind, uid?'
859+
type: string
860+
type: object
861+
type: array
851862
metadata:
852863
properties:
853864
annotations:
@@ -1877,6 +1888,17 @@ spec:
18771888
type: array
18781889
image:
18791890
type: string
1891+
imagePullSecrets:
1892+
items:
1893+
description: LocalObjectReference contains enough information
1894+
to let you locate the referenced object inside the same namespace.
1895+
properties:
1896+
name:
1897+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
1898+
TODO: Add other useful fields. apiVersion, kind, uid?'
1899+
type: string
1900+
type: object
1901+
type: array
18801902
metadata:
18811903
properties:
18821904
annotations:

pkg/resources/jobs/initializer.go

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func NewInitializerJob(k6 *v1alpha1.K6, argLine string) (*batchv1.Job, error) {
8484
NodeSelector: k6.Spec.Runner.NodeSelector,
8585
Tolerations: k6.Spec.Runner.Tolerations,
8686
RestartPolicy: corev1.RestartPolicyNever,
87+
ImagePullSecrets: k6.Spec.Runner.ImagePullSecrets,
8788
Containers: []corev1.Container{
8889
{
8990
Image: image,

pkg/resources/jobs/runner.go

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func NewRunnerJob(k6 *v1alpha1.K6, index int, testRunId, token string) (*batchv1
149149
NodeSelector: k6.Spec.Runner.NodeSelector,
150150
Tolerations: k6.Spec.Runner.Tolerations,
151151
SecurityContext: &k6.Spec.Runner.SecurityContext,
152+
ImagePullSecrets: k6.Spec.Runner.ImagePullSecrets,
152153
Containers: []corev1.Container{{
153154
Image: image,
154155
Name: "k6",

pkg/resources/jobs/starter.go

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func NewStarterJob(k6 *v1alpha1.K6, hostname []string) *batchv1.Job {
6464
Tolerations: k6.Spec.Starter.Tolerations,
6565
RestartPolicy: corev1.RestartPolicyNever,
6666
SecurityContext: &k6.Spec.Starter.SecurityContext,
67+
ImagePullSecrets: k6.Spec.Starter.ImagePullSecrets,
6768
Containers: []corev1.Container{
6869
containers.NewCurlContainer(hostname, starterImage, command, env),
6970
},

0 commit comments

Comments
 (0)