diff --git a/pkg/issuer/acme/http/pod.go b/pkg/issuer/acme/http/pod.go index 75e703f61..11bb0f6ab 100644 --- a/pkg/issuer/acme/http/pod.go +++ b/pkg/issuer/acme/http/pod.go @@ -142,7 +142,9 @@ func (s *Solver) buildPod(ch *v1alpha1.Challenge) *corev1.Pod { pod := s.buildDefaultPod(ch) // Override defaults if they have changed in the pod template. - if ch.Spec.Solver != nil { + if ch.Spec.Solver != nil && + ch.Spec.Solver.HTTP01 != nil && + ch.Spec.Solver.HTTP01.Ingress != nil { pod = s.mergePodObjectMetaWithPodTemplate(pod, ch.Spec.Solver.HTTP01.Ingress.PodTemplate) } @@ -206,10 +208,18 @@ func (s *Solver) mergePodObjectMetaWithPodTemplate(pod *corev1.Pod, podTempl *v1 return pod } + if pod.Labels == nil { + pod.Labels = make(map[string]string) + } + for k, v := range podTempl.Labels { pod.Labels[k] = v } + if pod.Annotations == nil { + pod.Annotations = make(map[string]string) + } + for k, v := range podTempl.Annotations { pod.Annotations[k] = v } diff --git a/pkg/issuer/acme/http/pod_test.go b/pkg/issuer/acme/http/pod_test.go index 7a1c08884..8aecc060c 100644 --- a/pkg/issuer/acme/http/pod_test.go +++ b/pkg/issuer/acme/http/pod_test.go @@ -257,7 +257,7 @@ func TestGetPodsForCertificate(t *testing.T) { func TestMergePodObjectMetaWithPodTemplate(t *testing.T) { const createdPodKey = "createdPod" tests := map[string]solverFixture{ - "should use labels and owner references from template": { + "should use labels and annotations from template": { Challenge: &v1alpha1.Challenge{ Spec: v1alpha1.ChallengeSpec{ DNSName: "example.com",