GoWiki
Index
Sections
Search
Login
ston1th
Cert Manager Patch
# Cert Manager Patch ``` diff --git a/Makefile b/Makefile index 2290ebbf..5230e253 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ # limitations under the License. # Set DOCKER_REPO to customise the image docker repo, e.g. "quay.io/jetstack" -DOCKER_REPO := -APP_VERSION := canary +DOCKER_REPO := 127.0.0.1:5000/testing +APP_VERSION := v2 HACK_DIR ?= hack SKIP_GLOBALS := false diff --git a/docs/generated/reference/output/reference/api-docs/index.html b/docs/generated/reference/output/reference/api-docs/index.html index 53aeea80..7bbda80f 100755 --- a/docs/generated/reference/output/reference/api-docs/index.html +++ b/docs/generated/reference/output/reference/api-docs/index.html @@ -801,6 +801,10 @@ Appears In: <td><code>serviceType</code><br /> <em>string</em></td> <td>Optional service type for Kubernetes solver service</td> </tr> +<tr> +<td><code>svcName</code><br /> <em>string</em></td> +<td>ServiceName can be used to create a static challenge service for custom ingress controller and routing</td> +</tr> </tbody></table> <h2 id="acmechallengesolverhttp01ingresspodspec-v1alpha1">ACMEChallengeSolverHTTP01IngressPodSpec v1alpha1</h2> <table> @@ -1799,6 +1803,10 @@ Appears In: <td><code>ingressClass</code><br /> <em>string</em></td> <td>IngressClass is the ingress class that should be set on new ingress resources that are created in order to solve HTTP01 challenges. This field should be used when using an ingress controller such as nginx, which 'flattens' ingress configuration instead of maintaining a 1:1 mapping between loadbalancer IP:ingress resources. If this field is not set, and 'ingress' is not set, then ingresses without an ingress class set will be created to solve HTTP01 challenges. If this field is specified, 'ingress' <strong>must not</strong> be specified.</td> </tr> +<tr> +<td><code>svcName</code><br /> <em>string</em></td> +<td>ServiceName can be used to create a static challenge service for custom ingress controller and routing</td> +</tr> </tbody></table> <h2 id="initializer-v1">Initializer v1</h2> <table> diff --git a/pkg/apis/certmanager/v1alpha1/types_issuer.go b/pkg/apis/certmanager/v1alpha1/types_issuer.go index ef604fc1..c7473cda 100644 --- a/pkg/apis/certmanager/v1alpha1/types_issuer.go +++ b/pkg/apis/certmanager/v1alpha1/types_issuer.go @@ -297,6 +297,10 @@ type ACMEChallengeSolverHTTP01Ingress struct { // +optional Name string `json:"name,omitempty"` + // ServiceName can be used to create a static challenge service for custom + // ingress controller and routing + ServiceName string `json:"svcName,omitempty"` + // Optional pod template used to configure the ACME challenge solver pods // used for HTTP01 challenges // +optional diff --git a/pkg/apis/certmanager/v1alpha1/types_order.go b/pkg/apis/certmanager/v1alpha1/types_order.go index e06c067f..a38ba0c7 100644 --- a/pkg/apis/certmanager/v1alpha1/types_order.go +++ b/pkg/apis/certmanager/v1alpha1/types_order.go @@ -223,6 +223,10 @@ type HTTP01SolverConfig struct { // If this field is specified, 'ingress' **must not** be specified. // +optional IngressClass *string `json:"ingressClass,omitempty"` + + // ServiceName can be used to create a static challenge service for custom + // ingress controller and routing + ServiceName string `json:"svcName,omitempty"` } // DNS01SolverConfig contains solver configuration for DNS01 challenges. diff --git a/pkg/apis/certmanager/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/certmanager/v1alpha1/zz_generated.deepcopy.go index 8b9bfb4a..9d0f7092 100644 --- a/pkg/apis/certmanager/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/certmanager/v1alpha1/zz_generated.deepcopy.go @@ -768,7 +768,7 @@ func (in *CertificateRequestSpec) DeepCopyInto(out *CertificateRequestSpec) { if in.Duration != nil { in, out := &in.Duration, &out.Duration *out = new(metav1.Duration) - (*in).DeepCopyInto(*out) + **out = **in } out.IssuerRef = in.IssuerRef if in.CSRPEM != nil { @@ -833,12 +833,12 @@ func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { if in.Duration != nil { in, out := &in.Duration, &out.Duration *out = new(metav1.Duration) - (*in).DeepCopyInto(*out) + **out = **in } if in.RenewBefore != nil { in, out := &in.RenewBefore, &out.RenewBefore *out = new(metav1.Duration) - (*in).DeepCopyInto(*out) + **out = **in } if in.DNSNames != nil { in, out := &in.DNSNames, &out.DNSNames diff --git a/pkg/issuer/acme/http/service.go b/pkg/issuer/acme/http/service.go index a2e41dd0..3bb2c88d 100644 --- a/pkg/issuer/acme/http/service.go +++ b/pkg/issuer/acme/http/service.go @@ -53,7 +53,7 @@ func (s *Solver) ensureService(ctx context.Context, issuer v1alpha1.GenericIssue } log.Info("creating HTTP01 challenge solver service") - return s.createService(issuer, ch) + return s.createService(ctx, issuer, ch) } // getServicesForChallenge returns a list of services that were created to solve @@ -91,11 +91,27 @@ func (s *Solver) getServicesForChallenge(ctx context.Context, ch *v1alpha1.Chall // createService will create the service required to solve this challenge // in the target API server. -func (s *Solver) createService(issuer v1alpha1.GenericIssuer, ch *v1alpha1.Challenge) (*corev1.Service, error) { +func (s *Solver) createService(ctx context.Context, issuer v1alpha1.GenericIssuer, ch *v1alpha1.Challenge) (*corev1.Service, error) { + log := logf.FromContext(ctx).WithName("createService") svc, err := buildService(issuer, ch) if err != nil { return nil, err } + solver := ch.Spec.Solver + config := ch.Spec.Config + if solver != nil { + if solver.HTTP01 != nil { + svc.ObjectMeta.Name = solver.HTTP01.Ingress.ServiceName + } + } else if config != nil { + if config.HTTP01 != nil { + svc.ObjectMeta.Name = config.HTTP01.ServiceName + } + } + if svc.ObjectMeta.Name != "" { + svc.ObjectMeta.GenerateName = "" + log.Info("using static service name: " + svc.ObjectMeta.Name) + } return s.Client.CoreV1().Services(ch.Namespace).Create(svc) } ```