mirror of https://github.com/docker/docs.git
Merge pull request #2640 from pottava/2492-awsec2-blockdevicemapping-configurable
Fix amazonec2 initiated shutdown caused by constant DeviceName
This commit is contained in:
commit
3988b5fabf
|
@ -43,7 +43,9 @@ This example assumes the VPC ID was found in the `a` availability zone. Use the`
|
|||
- `--amazonec2-subnet-id`: AWS VPC subnet id.
|
||||
- `--amazonec2-security-group`: AWS VPC security group name.
|
||||
- `--amazonec2-instance-type`: The instance type to run.
|
||||
- `--amazonec2-device-name`: The root device name of the instance.
|
||||
- `--amazonec2-root-size`: The root disk size of the instance (in GB).
|
||||
- `--amazonec2-volume-type`: The Amazon EBS volume type to be attached to the instance.
|
||||
- `--amazonec2-iam-instance-profile`: The AWS IAM role name to be used as the instance profile.
|
||||
- `--amazonec2-ssh-user`: SSH Login user name.
|
||||
- `--amazonec2-request-spot-instance`: Use spot instances.
|
||||
|
@ -82,7 +84,9 @@ Environment variables and default values:
|
|||
| `--amazonec2-subnet-id` | `AWS_SUBNET_ID` | - |
|
||||
| `--amazonec2-security-group` | `AWS_SECURITY_GROUP` | `docker-machine` |
|
||||
| `--amazonec2-instance-type` | `AWS_INSTANCE_TYPE` | `t2.micro` |
|
||||
| `--amazonec2-device-name` | `AWS_DEVICE_NAME` | `/dev/sda1` |
|
||||
| `--amazonec2-root-size` | `AWS_ROOT_SIZE` | `16` |
|
||||
| `--amazonec2-volume-type` | `AWS_VOLUME_TYPE` | `gp2` |
|
||||
| `--amazonec2-iam-instance-profile` | `AWS_INSTANCE_PROFILE` | - |
|
||||
| `--amazonec2-ssh-user` | `AWS_SSH_USER` | `ubuntu` |
|
||||
| `--amazonec2-request-spot-instance` | - | `false` |
|
||||
|
|
|
@ -32,7 +32,9 @@ const (
|
|||
defaultAmiId = "ami-615cb725"
|
||||
defaultRegion = "us-east-1"
|
||||
defaultInstanceType = "t2.micro"
|
||||
defaultDeviceName = "/dev/sda1"
|
||||
defaultRootSize = 16
|
||||
defaultVolumeType = "gp2"
|
||||
defaultZone = "a"
|
||||
defaultSecurityGroup = machineSecurityGroupName
|
||||
defaultSSHUser = "ubuntu"
|
||||
|
@ -64,7 +66,9 @@ type Driver struct {
|
|||
SecurityGroupId string
|
||||
SecurityGroupName string
|
||||
ReservationId string
|
||||
DeviceName string
|
||||
RootSize int64
|
||||
VolumeType string
|
||||
IamInstanceProfile string
|
||||
VpcId string
|
||||
SubnetId string
|
||||
|
@ -133,12 +137,24 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
|||
Value: defaultInstanceType,
|
||||
EnvVar: "AWS_INSTANCE_TYPE",
|
||||
},
|
||||
mcnflag.StringFlag{
|
||||
Name: "amazonec2-device-name",
|
||||
Usage: "AWS root device name",
|
||||
Value: defaultDeviceName,
|
||||
EnvVar: "AWS_DEVICE_NAME",
|
||||
},
|
||||
mcnflag.IntFlag{
|
||||
Name: "amazonec2-root-size",
|
||||
Usage: "AWS root disk size (in GB)",
|
||||
Value: defaultRootSize,
|
||||
EnvVar: "AWS_ROOT_SIZE",
|
||||
},
|
||||
mcnflag.StringFlag{
|
||||
Name: "amazonec2-volume-type",
|
||||
Usage: "Amazon EBS volume type",
|
||||
Value: defaultVolumeType,
|
||||
EnvVar: "AWS_VOLUME_TYPE",
|
||||
},
|
||||
mcnflag.StringFlag{
|
||||
Name: "amazonec2-iam-instance-profile",
|
||||
Usage: "AWS IAM Instance Profile",
|
||||
|
@ -217,7 +233,9 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
|||
d.SecurityGroupName = flags.String("amazonec2-security-group")
|
||||
zone := flags.String("amazonec2-zone")
|
||||
d.Zone = zone[:]
|
||||
d.DeviceName = flags.String("amazonec2-device-name")
|
||||
d.RootSize = int64(flags.Int("amazonec2-root-size"))
|
||||
d.VolumeType = flags.String("amazonec2-volume-type")
|
||||
d.IamInstanceProfile = flags.String("amazonec2-iam-instance-profile")
|
||||
d.SwarmMaster = flags.Bool("swarm-master")
|
||||
d.SwarmHost = flags.String("swarm-host")
|
||||
|
@ -373,10 +391,10 @@ func (d *Driver) Create() error {
|
|||
}
|
||||
|
||||
bdm := &ec2.BlockDeviceMapping{
|
||||
DeviceName: aws.String("/dev/sda1"),
|
||||
DeviceName: aws.String(d.DeviceName),
|
||||
Ebs: &ec2.EbsBlockDevice{
|
||||
VolumeSize: aws.Int64(d.RootSize),
|
||||
VolumeType: aws.String("gp2"),
|
||||
VolumeType: aws.String(d.VolumeType),
|
||||
DeleteOnTermination: aws.Bool(true),
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue