-
Notifications
You must be signed in to change notification settings - Fork 787
/
common_cert_manager.go
47 lines (41 loc) · 1.5 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
42
43
44
45
46
47
package cmd
import (
"fmt"
"time"
"github.com/jenkins-x/jx/pkg/helm"
"github.com/jenkins-x/jx/pkg/kube"
"github.com/jenkins-x/jx/pkg/log"
"github.com/jenkins-x/jx/pkg/util"
"github.com/pkg/errors"
)
func (o *CommonOptions) ensureCertmanager() error {
log.Infof("Looking for %s deployment in namespace %s...\n", CertManagerDeployment, CertManagerNamespace)
client, err := o.KubeClient()
if err != nil {
return errors.Wrap(err, "creating kube client")
}
_, err = kube.GetDeploymentPods(client, 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(helm.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(client, CertManagerDeployment, CertManagerNamespace, 10*time.Minute)
if err != nil {
return err
}
}
}
return err
}