Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions config/crd/bases/operator.kcp.io_frontproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ spec:
description: |-
Requested DNS subject alternative names. The values given here will be merged into the
DNS names determined automatically by the kcp-operator.
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
trying to guess what DNSNames configued issuer might support.
items:
type: string
type: array
Expand All @@ -208,6 +211,22 @@ spec:
items:
type: string
type: array
issuerRef:
description: IssuerRef is a reference to the issuer for
this certificate.
properties:
group:
description: Group of the object being referred to.
type: string
kind:
description: Kind of the object being referred to.
type: string
name:
description: Name of the object being referred to.
type: string
required:
- name
type: object
privateKey:
description: |-
Private key options. These include the key algorithm and size, the used
Expand Down
19 changes: 19 additions & 0 deletions config/crd/bases/operator.kcp.io_kubeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ spec:
description: |-
Requested DNS subject alternative names. The values given here will be merged into the
DNS names determined automatically by the kcp-operator.
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
trying to guess what DNSNames configued issuer might support.
items:
type: string
type: array
Expand All @@ -85,6 +88,22 @@ spec:
items:
type: string
type: array
issuerRef:
description: IssuerRef is a reference to the issuer for this
certificate.
properties:
group:
description: Group of the object being referred to.
type: string
kind:
description: Kind of the object being referred to.
type: string
name:
description: Name of the object being referred to.
type: string
required:
- name
type: object
privateKey:
description: |-
Private key options. These include the key algorithm and size, the used
Expand Down
39 changes: 39 additions & 0 deletions config/crd/bases/operator.kcp.io_rootshards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ spec:
description: |-
Requested DNS subject alternative names. The values given here will be merged into the
DNS names determined automatically by the kcp-operator.
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
trying to guess what DNSNames configued issuer might support.
items:
type: string
type: array
Expand All @@ -294,6 +297,22 @@ spec:
items:
type: string
type: array
issuerRef:
description: IssuerRef is a reference to the issuer for
this certificate.
properties:
group:
description: Group of the object being referred to.
type: string
kind:
description: Kind of the object being referred to.
type: string
name:
description: Name of the object being referred to.
type: string
required:
- name
type: object
privateKey:
description: |-
Private key options. These include the key algorithm and size, the used
Expand Down Expand Up @@ -1691,6 +1710,9 @@ spec:
description: |-
Requested DNS subject alternative names. The values given here will be merged into the
DNS names determined automatically by the kcp-operator.
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
trying to guess what DNSNames configued issuer might support.
items:
type: string
type: array
Expand All @@ -1711,6 +1733,23 @@ spec:
items:
type: string
type: array
issuerRef:
description: IssuerRef is a reference to the issuer
for this certificate.
properties:
group:
description: Group of the object being referred
to.
type: string
kind:
description: Kind of the object being referred to.
type: string
name:
description: Name of the object being referred to.
type: string
required:
- name
type: object
privateKey:
description: |-
Private key options. These include the key algorithm and size, the used
Expand Down
19 changes: 19 additions & 0 deletions config/crd/bases/operator.kcp.io_shards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ spec:
description: |-
Requested DNS subject alternative names. The values given here will be merged into the
DNS names determined automatically by the kcp-operator.
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
trying to guess what DNSNames configued issuer might support.
items:
type: string
type: array
Expand All @@ -278,6 +281,22 @@ spec:
items:
type: string
type: array
issuerRef:
description: IssuerRef is a reference to the issuer for
this certificate.
properties:
group:
description: Group of the object being referred to.
type: string
kind:
description: Kind of the object being referred to.
type: string
name:
description: Name of the object being referred to.
type: string
required:
- name
type: object
privateKey:
description: |-
Private key options. These include the key algorithm and size, the used
Expand Down
19 changes: 18 additions & 1 deletion internal/resources/utils/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"maps"

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1"

"k8s.io/apimachinery/pkg/util/sets"

Expand Down Expand Up @@ -65,7 +66,16 @@ func applyCertificateSpecTemplate(cert *certmanagerv1.Certificate, tpl *operator
return cert
}

cert.Spec.DNSNames = mergeSlices(cert.Spec.DNSNames, tpl.DNSNames)
// If DNSNames is provided in the template and issuer is overrided,
// it will replace any existing DNSNames.
// We don't merge as we don't know if issuer supports our default names.
// Its users responsibility to add them back if needed.
if len(tpl.DNSNames) > 0 && tpl.IssuerRef != nil {
cert.Spec.DNSNames = tpl.DNSNames
} else if len(tpl.DNSNames) > 0 {
cert.Spec.DNSNames = mergeSlices(cert.Spec.DNSNames, tpl.DNSNames)
}

cert.Spec.IPAddresses = mergeSlices(cert.Spec.IPAddresses, tpl.IPAddresses)

if tpl.Duration != nil {
Expand All @@ -84,6 +94,13 @@ func applyCertificateSpecTemplate(cert *certmanagerv1.Certificate, tpl *operator
cert.Spec.SecretTemplate.Annotations = addNewKeys(cert.Spec.SecretTemplate.Annotations, secretTpl.Annotations)
cert.Spec.SecretTemplate.Labels = addNewKeys(cert.Spec.SecretTemplate.Labels, secretTpl.Labels)
}
if tpl.IssuerRef != nil {
cert.Spec.IssuerRef = cmmeta.ObjectReference{
Name: tpl.IssuerRef.Name,
Kind: tpl.IssuerRef.Kind,
Group: tpl.IssuerRef.Group,
}
}

cert.Spec.PrivateKey = applyCertificatePrivateKeyTemplate(cert.Spec.PrivateKey, tpl.PrivateKey)
cert.Spec.Subject = applyCertificateSubjectTemplate(cert.Spec.Subject, tpl.Subject)
Expand Down
8 changes: 8 additions & 0 deletions sdk/apis/operator/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,16 @@ type CertificateSpecTemplate struct {
// +optional
Subject *X509Subject `json:"subject,omitempty"`

// IssuerRef is a reference to the issuer for this certificate.
//
// +optional
IssuerRef *ObjectReference `json:"issuerRef"`

// Requested DNS subject alternative names. The values given here will be merged into the
// DNS names determined automatically by the kcp-operator.
// If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
// If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
// trying to guess what DNSNames configued issuer might support.
//
// +optional
DNSNames []string `json:"dnsNames,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions sdk/apis/operator/v1alpha1/zz_generated.deepcopy.go

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

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