From 4c05623a3cdbc3a1ce76dc7f01dbbf7bfa0b52a7 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Thu, 23 Apr 2020 17:26:59 +0100 Subject: [PATCH 1/2] Image pull secret fix --- runtime/kubernetes/service.go | 5 ++++- util/kubernetes/client/templates.go | 2 +- util/kubernetes/client/types.go | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime/kubernetes/service.go b/runtime/kubernetes/service.go index 3673b9ed..0efb2456 100644 --- a/runtime/kubernetes/service.go +++ b/runtime/kubernetes/service.go @@ -39,7 +39,10 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service { } // set the image pull secrets - kdeploy.Spec.Template.PodSpec.ImagePullSecrets = c.ImagePullSecrets + kdeploy.Spec.Template.PodSpec.ImagePullSecrets = make([]client.ImagePullSecret, len(c.ImagePullSecrets)) + for i, s := range c.ImagePullSecrets { + kdeploy.Spec.Template.PodSpec.ImagePullSecrets[i] = client.ImagePullSecret{Name: s} + } // create if non existent if s.Metadata == nil { diff --git a/util/kubernetes/client/templates.go b/util/kubernetes/client/templates.go index dcd08d56..ebac3574 100644 --- a/util/kubernetes/client/templates.go +++ b/util/kubernetes/client/templates.go @@ -53,7 +53,7 @@ spec: imagePullSecrets: {{- with .Spec.Template.PodSpec.ImagePullSecrets }} {{- range . }} - - name: "{{.}}" + - name: "{{ .Name }}" {{- end }} {{- end }} containers: diff --git a/util/kubernetes/client/types.go b/util/kubernetes/client/types.go index 35febde0..745a2661 100644 --- a/util/kubernetes/client/types.go +++ b/util/kubernetes/client/types.go @@ -93,8 +93,8 @@ type Metadata struct { // PodSpec is a pod type PodSpec struct { - Containers []Container `json:"containers"` - ImagePullSecrets []string `json:"imagePullSecrets"` + Containers []Container `json:"containers"` + ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets"` } // PodList @@ -189,3 +189,8 @@ type Namespace struct { type NamespaceList struct { Items []Namespace `json:"items"` } + +// ImagePullSecret +type ImagePullSecret struct { + Name string `json:"name"` +} From 616db3442a6da414078eea45cebf24abc30ce4c5 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Thu, 23 Apr 2020 17:44:40 +0100 Subject: [PATCH 2/2] Debugging --- runtime/kubernetes/kubernetes.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/kubernetes/kubernetes.go b/runtime/kubernetes/kubernetes.go index c26e2984..6de713bb 100644 --- a/runtime/kubernetes/kubernetes.go +++ b/runtime/kubernetes/kubernetes.go @@ -38,6 +38,8 @@ func (k *kubernetes) namespaceExists(name string) (bool, error) { return false, err } k.namespaces = namespaceList.Items + fmt.Println("HERE") + fmt.Println(k.namespaces) } // check if the namespace exists in the cache