Add imagePullSecrets to PodSpec

This commit is contained in:
Micro 2020-04-23 12:27:36 +01:00
parent 7345ce9192
commit 501a6bf3ea
4 changed files with 19 additions and 1 deletions

View File

@ -38,6 +38,9 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
kdeploy.Spec.Template.Metadata.Annotations = make(map[string]string)
}
// set the image pull secrets
kdeploy.Spec.Template.PodSpec.ImagePullSecrets = c.ImagePullSecrets
// create if non existent
if s.Metadata == nil {
s.Metadata = make(map[string]string)

View File

@ -66,6 +66,8 @@ type CreateOptions struct {
Retries int
// Specify the image to use
Image string
// Specify secrets to use when pulling the image
ImagePullSecrets []string
}
// ReadOptions queries runtime services
@ -92,6 +94,13 @@ func CreateImage(img string) CreateOption {
}
}
// CreateImagePullSecret sets a secret to use
func CreateImagePullSecret(secret string) CreateOption {
return func(o *CreateOptions) {
o.ImagePullSecrets = append(o.ImagePullSecrets, secret)
}
}
// WithCommand specifies the command to execute
func WithCommand(cmd ...string) CreateOption {
return func(o *CreateOptions) {

View File

@ -50,6 +50,11 @@ spec:
{{- end }}
{{- end }}
spec:
imagePullSecrets:
{{- with .Spec.Template.PodSpec.ImagePullSecrets }}
{{- range . }}
- {{ . }}
{{ end }}
containers:
{{- with .Spec.Template.PodSpec.Containers }}
{{- range . }}

View File

@ -93,7 +93,8 @@ type Metadata struct {
// PodSpec is a pod
type PodSpec struct {
Containers []Container `json:"containers"`
Containers []Container `json:"containers"`
ImagePullSecrets []string `json:"imagePullSecrets"`
}
// PodList