mirror of https://github.com/docker/docs.git
Fixes #1243 Custom GCE images support
Signed-off-by: Andrew Grande <aprepel@gmail.com> Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
d855c35059
commit
914ccb6968
|
@ -43,6 +43,7 @@ $ docker-machine create --driver google \
|
|||
- `--google-project`: **required** The id of your project to use when launching the instance.
|
||||
- `--google-zone`: The zone to launch the instance.
|
||||
- `--google-machine-type`: The type of instance.
|
||||
- `--google-machine-image`: The absolute URL to a base VM image to instantiate.
|
||||
- `--google-username`: The username to use for the instance.
|
||||
- `--google-scopes`: The scopes for OAuth 2.0 to Access Google APIs. See [Google Compute Engine Doc](https://cloud.google.com/storage/docs/authentication).
|
||||
- `--google-disk-size`: The disk size of instance.
|
||||
|
@ -51,7 +52,11 @@ $ docker-machine create --driver google \
|
|||
- `--google-preemptible`: Instance preemptibility.
|
||||
- `--google-tags`: Instance tags (comma-separated).
|
||||
|
||||
The driver uses the `ubuntu-1404-trusty-v20150909a` disk image.
|
||||
The GCE driver will use the `ubuntu-1404-trusty-v20150909a` instance image unless otherwise specified. To obtain a
|
||||
list of image URLs run:
|
||||
```
|
||||
gcloud compute images list --uri
|
||||
```
|
||||
|
||||
Environment variables and default values:
|
||||
|
||||
|
@ -60,6 +65,7 @@ Environment variables and default values:
|
|||
| **`--google-project`** | `GOOGLE_PROJECT` | - |
|
||||
| `--google-zone` | `GOOGLE_ZONE` | `us-central1-a` |
|
||||
| `--google-machine-type` | `GOOGLE_MACHINE_TYPE` | `n1-standard-1` |
|
||||
| `--google-machine-image` | `GOOGLE_MACHINE_IMAGE`| `ubuntu-1404-trusty-v20150909a` |
|
||||
| `--google-username` | `GOOGLE_USERNAME` | `docker-user` |
|
||||
| `--google-scopes` | `GOOGLE_SCOPES` | `devstorage.read_only,logging.write` |
|
||||
| `--google-disk-size` | `GOOGLE_DISK_SIZE` | `10` |
|
||||
|
|
|
@ -35,7 +35,6 @@ type ComputeUtil struct {
|
|||
|
||||
const (
|
||||
apiURL = "https://www.googleapis.com/compute/v1/projects/"
|
||||
imageName = "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20150909a"
|
||||
firewallRule = "docker-machines"
|
||||
port = "2376"
|
||||
firewallTargetTag = "docker-machine"
|
||||
|
@ -231,7 +230,7 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
|
|||
if disk == nil || err != nil {
|
||||
instance.Disks[0].InitializeParams = &raw.AttachedDiskInitializeParams{
|
||||
DiskName: c.diskName(),
|
||||
SourceImage: imageName,
|
||||
SourceImage: d.MachineImage,
|
||||
// The maximum supported disk size is 1000GB, the cast should be fine.
|
||||
DiskSizeGb: int64(d.DiskSize),
|
||||
DiskType: c.diskType(),
|
||||
|
|
|
@ -14,21 +14,23 @@ import (
|
|||
// Driver is a struct compatible with the docker.hosts.drivers.Driver interface.
|
||||
type Driver struct {
|
||||
*drivers.BaseDriver
|
||||
Zone string
|
||||
MachineType string
|
||||
DiskType string
|
||||
Address string
|
||||
Preemptible bool
|
||||
Scopes string
|
||||
DiskSize int
|
||||
Project string
|
||||
Tags string
|
||||
Zone string
|
||||
MachineType string
|
||||
MachineImage string
|
||||
DiskType string
|
||||
Address string
|
||||
Preemptible bool
|
||||
Scopes string
|
||||
DiskSize int
|
||||
Project string
|
||||
Tags string
|
||||
}
|
||||
|
||||
const (
|
||||
defaultZone = "us-central1-a"
|
||||
defaultUser = "docker-user"
|
||||
defaultMachineType = "n1-standard-1"
|
||||
defaultImageName = "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20150909a"
|
||||
defaultScopes = "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write"
|
||||
defaultDiskType = "pd-standard"
|
||||
defaultDiskSize = 10
|
||||
|
@ -50,6 +52,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
|||
Value: defaultMachineType,
|
||||
EnvVar: "GOOGLE_MACHINE_TYPE",
|
||||
},
|
||||
mcnflag.StringFlag{
|
||||
Name: "google-machine-image",
|
||||
Usage: "GCE Machine Image Absolute URL",
|
||||
Value: defaultImageName,
|
||||
EnvVar: "GOOGLE_MACHINE_IMAGE",
|
||||
},
|
||||
mcnflag.StringFlag{
|
||||
Name: "google-username",
|
||||
Usage: "GCE User Name",
|
||||
|
@ -101,11 +109,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
|||
// NewDriver creates a Driver with the specified storePath.
|
||||
func NewDriver(machineName string, storePath string) *Driver {
|
||||
return &Driver{
|
||||
Zone: defaultZone,
|
||||
DiskType: defaultDiskType,
|
||||
DiskSize: defaultDiskSize,
|
||||
MachineType: defaultMachineType,
|
||||
Scopes: defaultScopes,
|
||||
Zone: defaultZone,
|
||||
DiskType: defaultDiskType,
|
||||
DiskSize: defaultDiskSize,
|
||||
MachineType: defaultMachineType,
|
||||
MachineImage: defaultImageName,
|
||||
Scopes: defaultScopes,
|
||||
BaseDriver: &drivers.BaseDriver{
|
||||
SSHUser: defaultUser,
|
||||
MachineName: machineName,
|
||||
|
@ -141,6 +150,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
|||
|
||||
d.Zone = flags.String("google-zone")
|
||||
d.MachineType = flags.String("google-machine-type")
|
||||
d.MachineImage = flags.String("google-machine-image")
|
||||
d.DiskSize = flags.Int("google-disk-size")
|
||||
d.DiskType = flags.String("google-disk-type")
|
||||
d.Address = flags.String("google-address")
|
||||
|
|
Loading…
Reference in New Issue