|
|
@ -10,49 +10,33 @@ import (
|
|
|
|
"k8s.io/helm/pkg/kube"
|
|
|
|
"k8s.io/helm/pkg/kube"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Installer installs tiller into Kubernetes
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// See InstallYAML.
|
|
|
|
|
|
|
|
type Installer struct {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Metadata holds any global metadata attributes for the resources
|
|
|
|
|
|
|
|
Metadata map[string]interface{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tiller specific metadata
|
|
|
|
|
|
|
|
Tiller map[string]interface{}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewInstaller creates a new Installer
|
|
|
|
|
|
|
|
func NewInstaller() *Installer {
|
|
|
|
|
|
|
|
return &Installer{
|
|
|
|
|
|
|
|
Metadata: map[string]interface{}{},
|
|
|
|
|
|
|
|
Tiller: map[string]interface{}{},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Install uses kubernetes client to install tiller
|
|
|
|
// Install uses kubernetes client to install tiller
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Returns the string output received from the operation, and an error if the
|
|
|
|
// Returns the string output received from the operation, and an error if the
|
|
|
|
// command failed.
|
|
|
|
// command failed.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// If verbose is true, this will print the manifest to stdout.
|
|
|
|
// If verbose is true, this will print the manifest to stdout.
|
|
|
|
//
|
|
|
|
func Install(namespace, image string, verbose bool) error {
|
|
|
|
// If createNS is true, this will also create the namespace.
|
|
|
|
kc := kube.New(nil)
|
|
|
|
func (i *Installer) Install(verbose, createNS bool) error {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var b bytes.Buffer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add namespace
|
|
|
|
if namespace == "" {
|
|
|
|
if createNS {
|
|
|
|
ns, _, err := kc.DefaultNamespace()
|
|
|
|
nstpl := template.New("namespace").Funcs(sprig.TxtFuncMap())
|
|
|
|
if err != nil {
|
|
|
|
if err := template.Must(nstpl.Parse(NamespaceYAML)).Execute(&b, i); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace = ns
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var b bytes.Buffer
|
|
|
|
|
|
|
|
|
|
|
|
// Add main install YAML
|
|
|
|
// Add main install YAML
|
|
|
|
istpl := template.New("install").Funcs(sprig.TxtFuncMap())
|
|
|
|
istpl := template.New("install").Funcs(sprig.TxtFuncMap())
|
|
|
|
if err := template.Must(istpl.Parse(InstallYAML)).Execute(&b, i); err != nil {
|
|
|
|
|
|
|
|
|
|
|
|
cfg := struct {
|
|
|
|
|
|
|
|
Namespace, Image string
|
|
|
|
|
|
|
|
}{namespace, image}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := template.Must(istpl.Parse(InstallYAML)).Execute(&b, cfg); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -60,24 +44,12 @@ func (i *Installer) Install(verbose, createNS bool) error {
|
|
|
|
fmt.Println(b.String())
|
|
|
|
fmt.Println(b.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return kube.New(nil).Create(i.Tiller["Namespace"].(string), &b)
|
|
|
|
return kc.Create(namespace, &b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NamespaceYAML is the installation for a namespace.
|
|
|
|
|
|
|
|
const NamespaceYAML = `
|
|
|
|
|
|
|
|
---{{$namespace := default "helm" .Tiller.Namespace}}
|
|
|
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
|
|
|
kind: Namespace
|
|
|
|
|
|
|
|
metadata:
|
|
|
|
|
|
|
|
labels:
|
|
|
|
|
|
|
|
app: helm
|
|
|
|
|
|
|
|
name: helm-namespace
|
|
|
|
|
|
|
|
name: {{$namespace}}
|
|
|
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// InstallYAML is the installation YAML for DM.
|
|
|
|
// InstallYAML is the installation YAML for DM.
|
|
|
|
const InstallYAML = `
|
|
|
|
const InstallYAML = `
|
|
|
|
---{{$namespace := default "helm" .Tiller.Namespace}}
|
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
apiVersion: v1
|
|
|
|
kind: ReplicationController
|
|
|
|
kind: ReplicationController
|
|
|
|
metadata:
|
|
|
|
metadata:
|
|
|
@ -85,7 +57,7 @@ metadata:
|
|
|
|
app: helm
|
|
|
|
app: helm
|
|
|
|
name: tiller
|
|
|
|
name: tiller
|
|
|
|
name: tiller-rc
|
|
|
|
name: tiller-rc
|
|
|
|
namespace: {{$namespace}}
|
|
|
|
namespace: {{ .Namespace }}
|
|
|
|
spec:
|
|
|
|
spec:
|
|
|
|
replicas: 1
|
|
|
|
replicas: 1
|
|
|
|
selector:
|
|
|
|
selector:
|
|
|
@ -103,7 +75,7 @@ spec:
|
|
|
|
valueFrom:
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: metadata.namespace
|
|
|
|
fieldPath: metadata.namespace
|
|
|
|
image: {{default "gcr.io/kubernetes-helm/tiller:canary" .Tiller.Image}}
|
|
|
|
image: {{default "gcr.io/kubernetes-helm/tiller:canary" .Image}}
|
|
|
|
name: tiller
|
|
|
|
name: tiller
|
|
|
|
ports:
|
|
|
|
ports:
|
|
|
|
- containerPort: 44134
|
|
|
|
- containerPort: 44134
|
|
|
|