forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
service.go
44 lines (38 loc) · 1.49 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package controller
import (
"fmt"
"time"
"github.com/openshift/library-go/pkg/crypto"
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
servingcertcontroller "github.com/openshift/service-serving-cert-signer/pkg/controller/servingcert"
)
func RunServiceServingCertsController(ctx *ControllerContext) (bool, error) {
signer := ctx.OpenshiftControllerConfig.ServiceServingCert.Signer
if signer == nil || len(signer.CertFile) == 0 || len(signer.KeyFile) == 0 {
return false, nil
}
ca, err := crypto.GetCA(signer.CertFile, signer.KeyFile, "")
if err != nil {
return true, fmt.Errorf("service serving cert controller: %v", err)
}
servingCertController := servingcertcontroller.NewServiceServingCertController(
ctx.KubernetesInformers.Core().V1().Services(),
ctx.KubernetesInformers.Core().V1().Secrets(),
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceServingCertServiceAccountName).Core(),
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceServingCertServiceAccountName).Core(),
ca,
"cluster.local",
2*time.Minute,
)
servingCertUpdateController := servingcertcontroller.NewServiceServingCertUpdateController(
ctx.KubernetesInformers.Core().V1().Services(),
ctx.KubernetesInformers.Core().V1().Secrets(),
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceServingCertServiceAccountName).Core(),
ca,
"cluster.local",
20*time.Minute,
)
go servingCertController.Run(1, ctx.Stop)
go servingCertUpdateController.Run(5, ctx.Stop)
return true, nil
}