forked from jenkins-x/jx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_cert_manager.go
41 lines (35 loc) · 1.36 KB
/
common_cert_manager.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
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", o.In, o.Out, o.Err)
if ok {
values := []string{"rbac.create=true", "ingressShim.extraArgs='{--default-issuer-name=letsencrypt-staging,--default-issuer-kind=Issuer}'"}
err = o.installChartOptions(InstallChartOptions{
ReleaseName: "cert-manager",
Chart: "stable/cert-manager",
Version: "",
Ns: CertManagerNamespace,
HelmUpdate: true,
SetValues: 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
}