Skip to content

Commit 5ca129c

Browse files
authored
Merge pull request #33 from gruntwork-io/gke_gmc_name_fix
Make cert name configurable
2 parents 6fd7906 + b31f996 commit 5ca129c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

charts/k8s-service/templates/gmc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ that will provision a Google managed SSL certificate.
77
We declare some variables defined on the Values. These are reused in `with` and `range` blocks where the scoped variable
88
(`.`) is rebound within the block.
99
*/ -}}
10-
{{- $fullName := include "k8s-service.fullname" . -}}
1110
{{- $domainName := .Values.google.managedCertificate.domainName -}}
11+
{{- $certificateName := .Values.google.managedCertificate.name -}}
1212
apiVersion: networking.gke.io/v1beta1
1313
kind: ManagedCertificate
1414
metadata:
15-
name: {{ $fullName }}
15+
name: {{ $certificateName }}
1616
labels:
1717
gruntwork.io/app-name: {{ .Values.applicationName }}
1818
# These labels are required by helm. You can read more about required labels in the chart best practices guide:

charts/k8s-service/values.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,17 @@ google:
355355
# The expected keys are:
356356
# - enabled (bool) (required) : Whether or not the ManagedCertificate resource should be created.
357357
# - domainName (string) : Specifies the domain that the SSL certificate will be created for
358+
# - name (string) : Specifies the name of the SSL certificate that you reference in Ingress with
359+
# networking.gke.io/managed-certificates: name
358360
#
359-
# The following example specifies a ManagedCertificate with a domain name 'api.acme.com':
361+
# The following example specifies a ManagedCertificate with a domain name 'api.acme.com' and name 'acme-cert':
360362
#
361363
# EXAMPLE:
362364
#
363365
# google:
364366
# managedCertificate:
365367
# enabled: true
368+
# name: acme-cert
366369
# domainName: api.acme.com
367370
#
368371
# NOTE: if you enable managedCertificate, then Ingress must also be enabled.

test/k8s_service_template_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,23 @@ func TestK8SServiceIngressAdditionalPathsHigherPriorityNoServiceName(t *testing.
438438
}
439439

440440
// Test rendering Managed Certificate
441-
func TestK8SServiceManagedCertDomainName(t *testing.T) {
441+
func TestK8SServiceManagedCertDomainNameAndName(t *testing.T) {
442442
t.Parallel()
443443

444444
cert := renderK8SServiceManagedCertificateWithSetValues(
445445
t,
446446
map[string]string{
447447
"google.managedCertificate.enabled": "true",
448448
"google.managedCertificate.domainName": "api.acme.io",
449+
"google.managedCertificate.name": "acme-cert",
449450
},
450451
)
451452

452453
domains := cert.Spec.Domains
454+
certName := cert.ObjectMeta.Name
453455
assert.Equal(t, len(domains), 1)
454456
assert.Equal(t, domains[0], "api.acme.io")
457+
assert.Equal(t, certName, "acme-cert")
455458
}
456459

457460
// Test that setting ingress.enabled = false will cause the helm template to not render the ManagedCertificate resource

0 commit comments

Comments
 (0)