Skip to content

Commit

Permalink
Add support for TLS connections to tiller (#13)
Browse files Browse the repository at this point in the history
Add possibility for TLS connections to tiller
  • Loading branch information
Thomas Rucker authored and sstarcher committed May 13, 2019
1 parent 058b343 commit a240b73
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/tlsutil"

"github.com/facebookgo/flagenv"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -32,6 +33,10 @@ var (

localTiller = "127.0.0.1:44134"
tillerNamespace = flag.String("tiller-namespaces", "kube-system", "namespaces of Tillers , separated list kube-system,dev")
tillerTLSEnable = flag.Bool("tiller-tls-enable", false, "enable TLS communication with tiller (default false)")
tillerTLSKey = flag.String("tiller-tls-key", "/etc/helm-exporter/tls.key", "path to private key file used to communicate with tiller")
tillerTLSCert = flag.String("tiller-tls-cert", "/etc/helm-exporter/tls.crt", "path to certificate key file used to communicate with tiller")
tillerTLSVerify = flag.Bool("tiller-tls-verify", false, "enable verification of the remote tiller certificate (default false)")

statusCodes = []release.Status_Code{
release.Status_UNKNOWN,
Expand All @@ -52,7 +57,21 @@ var (
func newHelmClient(tillerEndpoint string) (*helm.Client, error) {
log.Printf("Attempting to connect to %s", tillerEndpoint)

client := helm.NewClient(helm.Host(tillerEndpoint))
options := []helm.Option{helm.Host(tillerEndpoint)}
if *tillerTLSEnable {
tlsopts := tlsutil.Options{
KeyFile: *tillerTLSKey,
CertFile: *tillerTLSCert,
InsecureSkipVerify: !(*tillerTLSVerify),
}
tlscfg, err := tlsutil.ClientConfig(tlsopts)
if err != nil {
return nil, err
}
options = append(options, helm.WithTLS(tlscfg))
}

client := helm.NewClient(options...)
err := client.PingTiller()
return client, err
}
Expand Down
89 changes: 89 additions & 0 deletions vendor/k8s.io/helm/pkg/tlsutil/cfg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions vendor/k8s.io/helm/pkg/tlsutil/tls.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions vendor/k8s.io/helm/pkg/urlutil/urlutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a240b73

Please sign in to comment.