|
|
@ -17,19 +17,58 @@ limitations under the License.
|
|
|
|
package dm
|
|
|
|
package dm
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/Masterminds/sprig"
|
|
|
|
"github.com/kubernetes/deployment-manager/pkg/format"
|
|
|
|
"github.com/kubernetes/deployment-manager/pkg/format"
|
|
|
|
"github.com/kubernetes/deployment-manager/pkg/kubectl"
|
|
|
|
"github.com/kubernetes/deployment-manager/pkg/kubectl"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Installer is capable of installing DM into Kubernetes.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// See InstallYAML.
|
|
|
|
|
|
|
|
type Installer struct {
|
|
|
|
|
|
|
|
// TODO: At some point we could transform these from maps to structs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Expandybird params are used to render the expandybird manifest.
|
|
|
|
|
|
|
|
Expandybird map[string]interface{}
|
|
|
|
|
|
|
|
// Resourcifier params are used to render the resourcifier manifest.
|
|
|
|
|
|
|
|
Resourcifier map[string]interface{}
|
|
|
|
|
|
|
|
// Manager params are used to render the manager manifest.
|
|
|
|
|
|
|
|
Manager map[string]interface{}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewInstaller creates a new Installer.
|
|
|
|
|
|
|
|
func NewInstaller() *Installer {
|
|
|
|
|
|
|
|
return &Installer{
|
|
|
|
|
|
|
|
Expandybird: map[string]interface{}{},
|
|
|
|
|
|
|
|
Resourcifier: map[string]interface{}{},
|
|
|
|
|
|
|
|
Manager: map[string]interface{}{},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Install uses kubectl to install the base DM.
|
|
|
|
// Install uses kubectl to install the base DM.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
func Install(runner kubectl.Runner) (string, error) {
|
|
|
|
func (i *Installer) Install(runner kubectl.Runner) (string, error) {
|
|
|
|
o, err := runner.Create([]byte(InstallYAML))
|
|
|
|
b, err := i.expand()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return "", err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
o, err := runner.Create(b)
|
|
|
|
return string(o), err
|
|
|
|
return string(o), err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (i *Installer) expand() ([]byte, error) {
|
|
|
|
|
|
|
|
var b bytes.Buffer
|
|
|
|
|
|
|
|
t := template.Must(template.New("manifest").Funcs(sprig.TxtFuncMap()).Parse(InstallYAML))
|
|
|
|
|
|
|
|
err := t.Execute(&b, i)
|
|
|
|
|
|
|
|
return b.Bytes(), err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IsInstalled checks whether DM has been installed.
|
|
|
|
// IsInstalled checks whether DM has been installed.
|
|
|
|
func IsInstalled(runner kubectl.Runner) bool {
|
|
|
|
func IsInstalled(runner kubectl.Runner) bool {
|
|
|
|
// Basically, we test "all-or-nothing" here: if this returns without error
|
|
|
|
// Basically, we test "all-or-nothing" here: if this returns without error
|
|
|
@ -104,7 +143,7 @@ spec:
|
|
|
|
spec:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
containers:
|
|
|
|
- env: []
|
|
|
|
- env: []
|
|
|
|
image: gcr.io/dm-k8s-testing/expandybird:latest
|
|
|
|
image: {{default "gcr.io/dm-k8s-testing/expandybird:latest" .Expandybird.Image}}
|
|
|
|
name: expandybird
|
|
|
|
name: expandybird
|
|
|
|
ports:
|
|
|
|
ports:
|
|
|
|
- containerPort: 8080
|
|
|
|
- containerPort: 8080
|
|
|
@ -148,7 +187,7 @@ spec:
|
|
|
|
spec:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
containers:
|
|
|
|
- env: []
|
|
|
|
- env: []
|
|
|
|
image: gcr.io/dm-k8s-testing/resourcifier:latest
|
|
|
|
image: {{ default "gcr.io/dm-k8s-testing/resourcifier:latest" .Resourcifier.Image }}
|
|
|
|
name: resourcifier
|
|
|
|
name: resourcifier
|
|
|
|
ports:
|
|
|
|
ports:
|
|
|
|
- containerPort: 8080
|
|
|
|
- containerPort: 8080
|
|
|
@ -192,7 +231,7 @@ spec:
|
|
|
|
spec:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
containers:
|
|
|
|
- env: []
|
|
|
|
- env: []
|
|
|
|
image: gcr.io/dm-k8s-testing/manager:latest
|
|
|
|
image: {{ default "gcr.io/dm-k8s-testing/manager:latest" .Manager.Image }}
|
|
|
|
name: manager
|
|
|
|
name: manager
|
|
|
|
ports:
|
|
|
|
ports:
|
|
|
|
- containerPort: 8080
|
|
|
|
- containerPort: 8080
|
|
|
|