mirror of https://github.com/docker/docs.git
tls for openstack/rackspace
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
d1ece77684
commit
3212d0c509
|
@ -176,7 +176,7 @@ func (driver *Driver) Create() error {
|
|||
return err
|
||||
}
|
||||
|
||||
log.Infof("Creating Azure machine...")
|
||||
log.Info("Creating Azure machine...")
|
||||
vmConfig, err := vmClient.CreateAzureVMConfiguration(driver.MachineName, driver.Size, driver.Image, driver.Location)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -203,7 +203,7 @@ func (driver *Driver) Create() error {
|
|||
return err
|
||||
}
|
||||
|
||||
log.Infof("Waiting for SSH...")
|
||||
log.Info("Waiting for SSH...")
|
||||
log.Debugf("Host: %s SSH Port: %d", driver.getHostname(), driver.SSHPort)
|
||||
|
||||
if err := ssh.WaitForTCP(fmt.Sprintf("%s:%d", driver.getHostname(), driver.SSHPort)); err != nil {
|
||||
|
|
|
@ -17,6 +17,10 @@ import (
|
|||
"github.com/docker/machine/state"
|
||||
)
|
||||
|
||||
const (
|
||||
dockerConfigDir = "/etc/docker"
|
||||
)
|
||||
|
||||
type Driver struct {
|
||||
AuthUrl string
|
||||
Username string
|
||||
|
@ -41,6 +45,8 @@ type Driver struct {
|
|||
SSHPort int
|
||||
Ip string
|
||||
EnableDockerInstall bool
|
||||
CaCertPath string
|
||||
PrivateKeyPath string
|
||||
storePath string
|
||||
client Client
|
||||
}
|
||||
|
@ -176,20 +182,24 @@ func GetCreateFlags() []cli.Flag {
|
|||
}
|
||||
}
|
||||
|
||||
func NewDriver(machineName string, storePath string) (drivers.Driver, error) {
|
||||
func NewDriver(machineName string, storePath string, caCert string, privateKey string) (drivers.Driver, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"machineName": machineName,
|
||||
"storePath": storePath,
|
||||
"caCert": caCert,
|
||||
"privateKey": privateKey,
|
||||
}).Debug("Instantiating OpenStack driver...")
|
||||
|
||||
return NewDerivedDriver(machineName, storePath, &GenericClient{})
|
||||
return NewDerivedDriver(machineName, storePath, &GenericClient{}, caCert, privateKey)
|
||||
}
|
||||
|
||||
func NewDerivedDriver(machineName string, storePath string, client Client) (*Driver, error) {
|
||||
func NewDerivedDriver(machineName string, storePath string, client Client, caCert string, privateKey string) (*Driver, error) {
|
||||
return &Driver{
|
||||
MachineName: machineName,
|
||||
storePath: storePath,
|
||||
client: client,
|
||||
MachineName: machineName,
|
||||
storePath: storePath,
|
||||
client: client,
|
||||
CaCertPath: caCert,
|
||||
PrivateKeyPath: privateKey,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -397,6 +407,38 @@ func (d *Driver) Upgrade() error {
|
|||
return fmt.Errorf("unable to upgrade as we are using the custom docker binary with identity auth")
|
||||
}
|
||||
|
||||
func (d *Driver) StartDocker() error {
|
||||
log.Debug("Starting Docker...")
|
||||
|
||||
cmd, err := d.GetSSHCommand("sudo service docker start")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Driver) StopDocker() error {
|
||||
log.Debug("Stopping Docker...")
|
||||
|
||||
cmd, err := d.GetSSHCommand("sudo service docker stop")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Driver) GetDockerConfigDir() string {
|
||||
return dockerConfigDir
|
||||
}
|
||||
|
||||
func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) {
|
||||
ip, err := d.GetIP()
|
||||
if err != nil {
|
||||
|
@ -694,21 +736,11 @@ func (d *Driver) waitForInstanceToStart() error {
|
|||
}
|
||||
|
||||
func (d *Driver) installDocker() error {
|
||||
log.WithField("MachineId", d.MachineId).Debug("Adding key to authorized-keys.d...")
|
||||
|
||||
if err := drivers.AddPublicKeyToAuthorizedHosts(d, "/.docker/authorized-keys.d"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithField("MachineId", d.MachineId).Debug("Installing docker daemon on the machine")
|
||||
|
||||
if err := d.sshExec([]string{
|
||||
`apt-get install -y curl`,
|
||||
`curl -sSL https://get.docker.com | /bin/sh >/var/log/docker-install.log 2>&1`,
|
||||
`service docker stop`,
|
||||
`curl -sSL https://ehazlett.s3.amazonaws.com/public/docker/linux/docker-1.4.1-136b351e-identity -o /usr/bin/docker`,
|
||||
`echo "export DOCKER_OPTS=\"--auth=identity --host=tcp://0.0.0.0:2376\"" >> /etc/default/docker`,
|
||||
`service docker start`,
|
||||
}); err != nil {
|
||||
log.Error("The docker installation failed.")
|
||||
log.Error(
|
||||
|
|
|
@ -9,6 +9,10 @@ import (
|
|||
"github.com/docker/machine/drivers/openstack"
|
||||
)
|
||||
|
||||
const (
|
||||
dockerConfigDir = "/etc/docker"
|
||||
)
|
||||
|
||||
// Driver is a machine driver for Rackspace. It's a specialization of the generic OpenStack one.
|
||||
type Driver struct {
|
||||
*openstack.Driver
|
||||
|
@ -18,15 +22,17 @@ type Driver struct {
|
|||
|
||||
// CreateFlags stores the command-line arguments given to "machine create".
|
||||
type CreateFlags struct {
|
||||
Username *string
|
||||
APIKey *string
|
||||
Region *string
|
||||
MachineName *string
|
||||
EndpointType *string
|
||||
ImageID *string
|
||||
FlavorID *string
|
||||
SSHUser *string
|
||||
SSHPort *int
|
||||
Username *string
|
||||
APIKey *string
|
||||
Region *string
|
||||
MachineName *string
|
||||
EndpointType *string
|
||||
ImageID *string
|
||||
FlavorID *string
|
||||
SSHUser *string
|
||||
SSHPort *int
|
||||
CaCertPath string
|
||||
PrivateKeyPath string
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -93,14 +99,16 @@ func GetCreateFlags() []cli.Flag {
|
|||
}
|
||||
|
||||
// NewDriver instantiates a Rackspace driver.
|
||||
func NewDriver(machineName string, storePath string) (drivers.Driver, error) {
|
||||
func NewDriver(machineName string, storePath string, caCert string, privateKey string) (drivers.Driver, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"machineName": machineName,
|
||||
"storePath": storePath,
|
||||
"caCert": caCert,
|
||||
"privateKey": privateKey,
|
||||
}).Debug("Instantiating Rackspace driver.")
|
||||
|
||||
client := &Client{}
|
||||
inner, err := openstack.NewDerivedDriver(machineName, storePath, client)
|
||||
inner, err := openstack.NewDerivedDriver(machineName, storePath, client, caCert, privateKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -115,6 +123,10 @@ func (d *Driver) DriverName() string {
|
|||
return "rackspace"
|
||||
}
|
||||
|
||||
func (d *Driver) GetDockerConfigDir() string {
|
||||
return dockerConfigDir
|
||||
}
|
||||
|
||||
func missingEnvOrOption(setting, envVar, opt string) error {
|
||||
return fmt.Errorf(
|
||||
"%s must be specified either using the environment variable %s or the CLI option %s",
|
||||
|
|
|
@ -293,8 +293,6 @@ func (d *Driver) StartDocker() error {
|
|||
func (d *Driver) StopDocker() error {
|
||||
log.Debug("Stopping Docker...")
|
||||
|
||||
// TODO @ehazlett - should we add this exit to make sure it doesn't
|
||||
// break if the daemon isn't running or add an arg?
|
||||
cmd, err := d.GetSSHCommand("if [ -e /var/run/docker.pid ]; then sudo /etc/init.d/docker stop ; fi")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
func newCertificate(org string) (*x509.Certificate, error) {
|
||||
now := time.Now()
|
||||
// need to set notBefore slightly in the past in to account for time
|
||||
// need to set notBefore slightly in the past to account for time
|
||||
// skew in the VMs otherwise the certs sometimes are not yet valid
|
||||
notBefore := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute()-5, 0, 0, time.Local)
|
||||
notAfter := notBefore.Add(time.Hour * 24 * 1080)
|
||||
|
|
Loading…
Reference in New Issue