@@ -19,22 +19,26 @@ import (
19
19
)
20
20
21
21
const (
22
- serviceName = "hnc-webhook-service"
23
- vwhName = "hnc-validating-webhook-configuration"
24
- mwhName = "hnc-mutating-webhook-configuration"
25
- caName = "hnc-ca"
26
- caOrganization = "hnc"
27
- secretName = "hnc-webhook-server-cert"
28
- certDir = "/tmp/k8s-webhook-server/serving-certs"
22
+ serviceName = "hnc-webhook-service"
23
+ vwhName = "hnc-validating-webhook-configuration"
24
+ mwhName = "hnc-mutating-webhook-configuration"
25
+ caName = "hnc-ca"
26
+ caOrganization = "hnc"
27
+ secretName = "hnc-webhook-server-cert"
28
+ certDir = "/tmp/k8s-webhook-server/serving-certs"
29
+ apiExtCertDir = "/certs"
30
+ apiExtServiceName = "hnc-resourcelist"
31
+ apiExtSecretName = "hnc-resourcelist"
32
+ apiExtName = "v1alpha2.resources.hnc.x-k8s.io"
29
33
)
30
34
31
- // ManageCerts creates all certs for webhooks. This function is called from main.go.
35
+ // ManageCerts creates all certs for webhooks and apiservices . This function is called from main.go.
32
36
func ManageCerts (mgr ctrl.Manager , setupFinished chan struct {}, restartOnSecretRefresh bool ) error {
33
37
hncNamespace := config .GetHNCNamespace ()
34
38
// DNSName is <service name>.<hncNamespace>.svc
35
39
dnsName := fmt .Sprintf ("%s.%s.svc" , serviceName , hncNamespace )
36
40
37
- return cert .AddRotator (mgr , & cert.CertRotator {
41
+ err := cert .AddRotator (mgr , & cert.CertRotator {
38
42
SecretKey : types.NamespacedName {
39
43
Namespace : hncNamespace ,
40
44
Name : secretName ,
@@ -53,6 +57,26 @@ func ManageCerts(mgr ctrl.Manager, setupFinished chan struct{}, restartOnSecretR
53
57
}},
54
58
RestartOnSecretRefresh : restartOnSecretRefresh ,
55
59
})
60
+ if err != nil {
61
+ return err
62
+ }
63
+ apiExtDNSName := fmt .Sprintf ("%s.%s.svc" , apiExtServiceName , hncNamespace )
64
+ return cert .AddRotator (mgr , & cert.CertRotator {
65
+ SecretKey : types.NamespacedName {
66
+ Namespace : hncNamespace ,
67
+ Name : apiExtSecretName ,
68
+ },
69
+ CertDir : apiExtCertDir ,
70
+ CAName : caName ,
71
+ CAOrganization : caOrganization ,
72
+ DNSName : apiExtDNSName ,
73
+ IsReady : setupFinished ,
74
+ Webhooks : []cert.WebhookInfo {{
75
+ Type : cert .APIService ,
76
+ Name : apiExtName ,
77
+ }},
78
+ RestartOnSecretRefresh : restartOnSecretRefresh ,
79
+ })
56
80
}
57
81
58
82
// createWebhooks creates all mutators and validators.
0 commit comments