generate ssh certs for kic during creation

pull/6390/head
Medya Gh 2020-01-23 18:43:26 -08:00
parent 3d5c9ae870
commit 09d9d05c6b
2 changed files with 17 additions and 11 deletions

View File

@ -23,8 +23,10 @@ import (
"strings" "strings"
"github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/ssh"
"github.com/docker/machine/libmachine/state" "github.com/docker/machine/libmachine/state"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/golang/glog"
pkgdrivers "k8s.io/minikube/pkg/drivers" pkgdrivers "k8s.io/minikube/pkg/drivers"
"k8s.io/minikube/pkg/drivers/kic/node" "k8s.io/minikube/pkg/drivers/kic/node"
"k8s.io/minikube/pkg/drivers/kic/oci" "k8s.io/minikube/pkg/drivers/kic/oci"
@ -94,23 +96,27 @@ func (d *Driver) Create() error {
CPUs: strconv.Itoa(d.NodeConfig.CPU), CPUs: strconv.Itoa(d.NodeConfig.CPU),
Memory: strconv.Itoa(d.NodeConfig.Memory) + "mb", Memory: strconv.Itoa(d.NodeConfig.Memory) + "mb",
Envs: d.NodeConfig.Envs, Envs: d.NodeConfig.Envs,
ExtraArgs: []string{"--expose", fmt.Sprintf("%d", d.NodeConfig.HostBindPort)}, ExtraArgs: []string{"--expose", fmt.Sprintf("%d", d.NodeConfig.APIHostBindPort)},
OCIBinary: d.NodeConfig.OCIBinary, OCIBinary: d.NodeConfig.OCIBinary,
} }
// control plane specific options // control plane specific options
params.PortMappings = append(params.PortMappings, oci.PortMapping{ params.PortMappings = append(params.PortMappings, oci.PortMapping{
ListenAddress: DefaultBindIPV4, ListenAddress: DefaultBindIPV4,
HostPort: int32(d.NodeConfig.HostBindPort), HostPort: int32(d.NodeConfig.APIHostBindPort),
ContainerPort: constants.APIServerPort, ContainerPort: constants.APIServerPort,
}, },
oci.PortMapping{ oci.PortMapping{
ListenAddress: DefaultBindIPV4, ListenAddress: DefaultBindIPV4,
HostPort: int32(d.NodeConfig.HostBindPort) + constants.SSHPort, // TODO: @medyagh: use github.com/phayes/freeport instead. HostPort: int32(d.NodeConfig.APIHostBindPort) + constants.SSHPort, // TODO: @medyagh: use github.com/phayes/freeport instead.
ContainerPort: constants.SSHPort, ContainerPort: constants.SSHPort,
}, },
) )
keyPath := d.GetSSHKeyPath()
glog.Infof("Creating ssh key for kic: %s...", keyPath)
if err := ssh.GenerateSSHKey(keyPath); err != nil {
return errors.Wrap(err, "generate ssh key")
}
_, err := node.CreateNode(params) _, err := node.CreateNode(params)
if err != nil { if err != nil {
return errors.Wrap(err, "create kic node") return errors.Wrap(err, "create kic node")

View File

@ -48,7 +48,7 @@ func configure(mc config.MachineConfig) interface{} {
ImageDigest: kic.BaseImage, ImageDigest: kic.BaseImage,
CPU: mc.CPUs, CPU: mc.CPUs,
Memory: mc.Memory, Memory: mc.Memory,
HostBindPort: mc.KubernetesConfig.NodePort, APIHostBindPort: mc.KubernetesConfig.NodePort,
OCIBinary: oci.Docker, OCIBinary: oci.Docker,
}) })