github.com/zoumo/helm@v2.5.0+incompatible/cmd/helm/installer/options.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package installer // import "k8s.io/helm/cmd/helm/installer" 18 19 import ( 20 "fmt" 21 22 "k8s.io/client-go/pkg/api/v1" 23 "k8s.io/helm/pkg/version" 24 ) 25 26 const defaultImage = "gcr.io/kubernetes-helm/tiller" 27 28 // Options control how to install tiller into a cluster, upgrade, and uninstall tiller from a cluster. 29 type Options struct { 30 // EnableTLS instructs tiller to serve with TLS enabled. 31 // 32 // Implied by VerifyTLS. If set the TLSKey and TLSCert are required. 33 EnableTLS bool 34 35 // VerifyTLS instructs tiller to serve with TLS enabled verify remote certificates. 36 // 37 // If set TLSKey, TLSCert, TLSCaCert are required. 38 VerifyTLS bool 39 40 // UseCanary indicates that tiller should deploy using the latest tiller image. 41 UseCanary bool 42 43 // Namespace is the kubernetes namespace to use to deploy tiller. 44 Namespace string 45 46 // ServiceAccount is the Kubernetes service account to add to tiller 47 ServiceAccount string 48 49 // ImageSpec indentifies the image tiller will use when deployed. 50 // 51 // Valid if and only if UseCanary is false. 52 ImageSpec string 53 54 // TLSKeyFile identifies the file containing the pem encoded TLS private 55 // key tiller should use. 56 // 57 // Required and valid if and only if EnableTLS or VerifyTLS is set. 58 TLSKeyFile string 59 60 // TLSCertFile identifies the file containing the pem encoded TLS 61 // certificate tiller should use. 62 // 63 // Required and valid if and only if EnableTLS or VerifyTLS is set. 64 TLSCertFile string 65 66 // TLSCaCertFile identifies the file containing the pem encoded TLS CA 67 // certificate tiller should use to verify remotes certificates. 68 // 69 // Required and valid if and only if VerifyTLS is set. 70 TLSCaCertFile string 71 72 // EnableHostNetwork installs Tiller with net=host 73 EnableHostNetwork bool 74 } 75 76 func (opts *Options) selectImage() string { 77 switch { 78 case opts.UseCanary: 79 return defaultImage + ":canary" 80 case opts.ImageSpec == "": 81 return fmt.Sprintf("%s:%s", defaultImage, version.Version) 82 default: 83 return opts.ImageSpec 84 } 85 } 86 87 func (opts *Options) pullPolicy() v1.PullPolicy { 88 if opts.UseCanary { 89 return v1.PullAlways 90 } 91 return v1.PullIfNotPresent 92 } 93 94 func (opts *Options) tls() bool { return opts.EnableTLS || opts.VerifyTLS }