-
Notifications
You must be signed in to change notification settings - Fork 1
/
common_cert_manageer.go
34 lines (28 loc) · 1.21 KB
/
common_cert_manageer.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
package cmd
import (
"fmt"
"time"
"github.com/jenkins-x/jx/pkg/kube"
"github.com/jenkins-x/jx/pkg/log"
"github.com/jenkins-x/jx/pkg/util"
)
func (o *CommonOptions) ensureCertmanager() error {
log.Infof("Looking for %s deployment in namespace %s...\n", CertManagerDeployment, CertManagerNamespace)
_, err := kube.GetDeploymentPods(o.KubeClientCached, CertManagerDeployment, CertManagerNamespace)
if err != nil {
ok := util.Confirm("CertManager deployment not found, shall we install it now?", true, "CertManager automatically configures Ingress rules with TLS using signed certificates from LetsEncrypt")
if ok {
values := []string{"rbac.create=true", "ingressShim.extraArgs='{--default-issuer-name=letsencrypt-staging,--default-issuer-kind=Issuer}'"}
err = o.installChart("cert-manager", "stable/cert-manager", "", CertManagerNamespace, true, values)
if err != nil {
return fmt.Errorf("CertManager deployment failed: %v", err)
}
log.Info("waiting for CertManager deployment to be ready, this can take a few minutes\n")
err = kube.WaitForDeploymentToBeReady(o.KubeClientCached, CertManagerDeployment, CertManagerNamespace, 10*time.Minute)
if err != nil {
return err
}
}
}
return err
}