Skip to content

Commit

Permalink
Support image pull secrets (grafana#145)
Browse files Browse the repository at this point in the history
* define input for imagePullSecrets

* assign imagePullSecrets to each job type

* update manifest template

* add ignore for vscode

* take imagePullSecrets out of spec

* formatting
  • Loading branch information
kneemaa authored Oct 24, 2022
1 parent df4c9d5 commit 8d5b983
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ bin
/manager

kubebuilder-tools-*

.vscode
23 changes: 12 additions & 11 deletions api/v1alpha1/k6_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ type PodMetadata struct {
}

type Pod struct {
Affinity *corev1.Affinity `json:"affinity,omitempty"`
AutomountServiceAccountToken string `json:"automountServiceAccountToken,omitempty"`
Env []corev1.EnvVar `json:"env,omitempty"`
Image string `json:"image,omitempty"`
Metadata PodMetadata `json:"metadata,omitempty"`
NodeSelector map[string]string `json:"nodeselector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
SecurityContext corev1.PodSecurityContext `json:"securityContext,omitempty"`
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
AutomountServiceAccountToken string `json:"automountServiceAccountToken,omitempty"`
Env []corev1.EnvVar `json:"env,omitempty"`
Image string `json:"image,omitempty"`
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Metadata PodMetadata `json:"metadata,omitempty"`
NodeSelector map[string]string `json:"nodeselector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
SecurityContext corev1.PodSecurityContext `json:"securityContext,omitempty"`
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
}

type K6Scuttle struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

22 changes: 22 additions & 0 deletions config/crd/bases/k6.io_k6s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,17 @@ spec:
type: array
image:
type: string
imagePullSecrets:
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
type: array
metadata:
properties:
annotations:
Expand Down Expand Up @@ -1877,6 +1888,17 @@ spec:
type: array
image:
type: string
imagePullSecrets:
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
type: array
metadata:
properties:
annotations:
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/jobs/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func NewInitializerJob(k6 *v1alpha1.K6, argLine string) (*batchv1.Job, error) {
NodeSelector: k6.Spec.Runner.NodeSelector,
Tolerations: k6.Spec.Runner.Tolerations,
RestartPolicy: corev1.RestartPolicyNever,
ImagePullSecrets: k6.Spec.Runner.ImagePullSecrets,
Containers: []corev1.Container{
{
Image: image,
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/jobs/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func NewRunnerJob(k6 *v1alpha1.K6, index int, testRunId, token string) (*batchv1
NodeSelector: k6.Spec.Runner.NodeSelector,
Tolerations: k6.Spec.Runner.Tolerations,
SecurityContext: &k6.Spec.Runner.SecurityContext,
ImagePullSecrets: k6.Spec.Runner.ImagePullSecrets,
Containers: []corev1.Container{{
Image: image,
Name: "k6",
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/jobs/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func NewStarterJob(k6 *v1alpha1.K6, hostname []string) *batchv1.Job {
Tolerations: k6.Spec.Starter.Tolerations,
RestartPolicy: corev1.RestartPolicyNever,
SecurityContext: &k6.Spec.Starter.SecurityContext,
ImagePullSecrets: k6.Spec.Starter.ImagePullSecrets,
Containers: []corev1.Container{
containers.NewCurlContainer(hostname, starterImage, command, env),
},
Expand Down

0 comments on commit 8d5b983

Please sign in to comment.