mirror of https://github.com/kubernetes/kops.git
Use kops create -f for creating clusters via manifest
This commit is contained in:
parent
196e678205
commit
cef43d2002
|
|
@ -152,9 +152,9 @@ func stateStore(cloudProvider string) string {
|
|||
if ss == "" {
|
||||
switch cloudProvider {
|
||||
case "aws":
|
||||
ss = "s3://k8s-kops-prow/"
|
||||
ss = "s3://k8s-kops-prow"
|
||||
case "gce":
|
||||
ss = "gs://k8s-kops-gce/"
|
||||
ss = "gs://k8s-kops-gce"
|
||||
}
|
||||
}
|
||||
return ss
|
||||
|
|
|
|||
|
|
@ -23,12 +23,11 @@ import (
|
|||
"sigs.k8s.io/kubetest2/pkg/exec"
|
||||
)
|
||||
|
||||
// replace performs a `kops replace` followed by `kops update cluster --yes`
|
||||
// create performs a `kops create -f` followed by `kops update cluster --yes`
|
||||
func (d *deployer) replace() error {
|
||||
args := []string{
|
||||
d.KopsBinaryPath, "replace",
|
||||
d.KopsBinaryPath, "create",
|
||||
"--filename", d.manifestPath,
|
||||
"--force",
|
||||
"--name", d.ClusterName,
|
||||
}
|
||||
klog.Info(strings.Join(args, " "))
|
||||
|
|
@ -42,22 +41,6 @@ func (d *deployer) replace() error {
|
|||
return err
|
||||
}
|
||||
|
||||
args = []string{
|
||||
d.KopsBinaryPath, "create", "secret", "sshpublickey",
|
||||
"admin",
|
||||
"-i", d.SSHPublicKeyPath,
|
||||
"--name", d.ClusterName,
|
||||
}
|
||||
klog.Info(strings.Join(args, " "))
|
||||
cmd = exec.Command(args[0], args[1:]...)
|
||||
cmd.SetEnv(d.env()...)
|
||||
|
||||
exec.InheritOutput(cmd)
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
args = []string{
|
||||
d.KopsBinaryPath, "update", "cluster", "--yes",
|
||||
"--name", d.ClusterName,
|
||||
|
|
@ -63,7 +63,11 @@ func (d *deployer) renderTemplate(values map[string]interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *deployer) templateValues(zones []string, publicIP string) map[string]interface{} {
|
||||
func (d *deployer) templateValues(zones []string, publicIP string) (map[string]interface{}, error) {
|
||||
publicKey, err := ioutil.ReadFile(d.SSHPublicKeyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"cloudProvider": d.CloudProvider,
|
||||
"clusterName": d.ClusterName,
|
||||
|
|
@ -71,5 +75,6 @@ func (d *deployer) templateValues(zones []string, publicIP string) map[string]in
|
|||
"publicIP": publicIP,
|
||||
"stateStore": d.StateStore,
|
||||
"zones": zones,
|
||||
}
|
||||
"sshPublicKey": string(publicKey),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ func (d *deployer) Up() error {
|
|||
}
|
||||
|
||||
if d.TemplatePath != "" {
|
||||
values := d.templateValues(zones, adminAccess)
|
||||
values, err := d.templateValues(zones, adminAccess)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.renderTemplate(values); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,17 @@ spec:
|
|||
|
||||
---
|
||||
|
||||
apiVersion: kops.k8s.io/v1alpha2
|
||||
kind: SSHCredential
|
||||
metadata:
|
||||
name: admin
|
||||
labels:
|
||||
kops.k8s.io/cluster: {{.clusterName}}
|
||||
spec:
|
||||
publicKey: {{.sshPublicKey}}
|
||||
|
||||
---
|
||||
|
||||
apiVersion: kops.k8s.io/v1alpha2
|
||||
kind: InstanceGroup
|
||||
metadata:
|
||||
|
|
|
|||
Loading…
Reference in New Issue