mirror of https://github.com/docker/docs.git
Merge pull request #3194 from ahmetalpbalkan/azure-static-ip
azure: Add --azure-static-public-ip flag
This commit is contained in:
commit
25672016fa
|
@ -58,6 +58,7 @@ Optional:
|
||||||
- `--azure-private-ip-address`: Specify a static private IP address for the machine.
|
- `--azure-private-ip-address`: Specify a static private IP address for the machine.
|
||||||
- `--azure-use-private-ip`: Use private IP address of the machine to connect.
|
- `--azure-use-private-ip`: Use private IP address of the machine to connect.
|
||||||
- `--azure-no-public-ip`: Do not create a public IP address for the machine.
|
- `--azure-no-public-ip`: Do not create a public IP address for the machine.
|
||||||
|
- `--azure-static-public-ip`: Assign a static public IP address to the machine.
|
||||||
- `--azure-docker-port`: Port number for Docker engine [$AZURE_DOCKER_PORT]
|
- `--azure-docker-port`: Port number for Docker engine [$AZURE_DOCKER_PORT]
|
||||||
- `--azure-environment`: Azure environment (e.g. `AzurePublicCloud`, `AzureChinaCloud`).
|
- `--azure-environment`: Azure environment (e.g. `AzurePublicCloud`, `AzureChinaCloud`).
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ Environment variables and default values:
|
||||||
| `--azure-private-ip-address` | - | - |
|
| `--azure-private-ip-address` | - | - |
|
||||||
| `--azure-use-private-ip` | - | - |
|
| `--azure-use-private-ip` | - | - |
|
||||||
| `--azure-no-public-ip` | - | - |
|
| `--azure-no-public-ip` | - | - |
|
||||||
|
| `--azure-static-public-ip` | - | - |
|
||||||
| `--azure-docker-port` | `AZURE_DOCKER_PORT` | `2376` |
|
| `--azure-docker-port` | `AZURE_DOCKER_PORT` | `2376` |
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
|
@ -46,6 +46,7 @@ const (
|
||||||
flAzurePorts = "azure-open-port"
|
flAzurePorts = "azure-open-port"
|
||||||
flAzurePrivateIPAddr = "azure-private-ip-address"
|
flAzurePrivateIPAddr = "azure-private-ip-address"
|
||||||
flAzureUsePrivateIP = "azure-use-private-ip"
|
flAzureUsePrivateIP = "azure-use-private-ip"
|
||||||
|
flAzureStaticPublicIP = "azure-static-public-ip"
|
||||||
flAzureNoPublicIP = "azure-no-public-ip"
|
flAzureNoPublicIP = "azure-no-public-ip"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -71,10 +72,11 @@ type Driver struct {
|
||||||
SubnetPrefix string
|
SubnetPrefix string
|
||||||
AvailabilitySet string
|
AvailabilitySet string
|
||||||
|
|
||||||
OpenPorts []string
|
OpenPorts []string
|
||||||
PrivateIPAddr string
|
PrivateIPAddr string
|
||||||
UsePrivateIP bool
|
UsePrivateIP bool
|
||||||
NoPublicIP bool
|
NoPublicIP bool
|
||||||
|
StaticPublicIP bool
|
||||||
|
|
||||||
// Ephemeral fields
|
// Ephemeral fields
|
||||||
ctx *azureutil.DeploymentContext
|
ctx *azureutil.DeploymentContext
|
||||||
|
@ -183,6 +185,10 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
||||||
Name: flAzureNoPublicIP,
|
Name: flAzureNoPublicIP,
|
||||||
Usage: "Do not create a public IP address for the machine",
|
Usage: "Do not create a public IP address for the machine",
|
||||||
},
|
},
|
||||||
|
mcnflag.BoolFlag{
|
||||||
|
Name: flAzureStaticPublicIP,
|
||||||
|
Usage: "Assign a static public IP address to the machine",
|
||||||
|
},
|
||||||
mcnflag.StringSliceFlag{
|
mcnflag.StringSliceFlag{
|
||||||
Name: flAzurePorts,
|
Name: flAzurePorts,
|
||||||
Usage: "Make the specified port number accessible from the Internet",
|
Usage: "Make the specified port number accessible from the Internet",
|
||||||
|
@ -225,6 +231,7 @@ func (d *Driver) SetConfigFromFlags(fl drivers.DriverOptions) error {
|
||||||
d.PrivateIPAddr = fl.String(flAzurePrivateIPAddr)
|
d.PrivateIPAddr = fl.String(flAzurePrivateIPAddr)
|
||||||
d.UsePrivateIP = fl.Bool(flAzureUsePrivateIP)
|
d.UsePrivateIP = fl.Bool(flAzureUsePrivateIP)
|
||||||
d.NoPublicIP = fl.Bool(flAzureNoPublicIP)
|
d.NoPublicIP = fl.Bool(flAzureNoPublicIP)
|
||||||
|
d.StaticPublicIP = fl.Bool(flAzureStaticPublicIP)
|
||||||
d.DockerPort = fl.Int(flAzureDockerPort)
|
d.DockerPort = fl.Int(flAzureDockerPort)
|
||||||
|
|
||||||
// Set flags on the BaseDriver
|
// Set flags on the BaseDriver
|
||||||
|
@ -307,7 +314,7 @@ func (d *Driver) Create() error {
|
||||||
if d.NoPublicIP {
|
if d.NoPublicIP {
|
||||||
log.Info("Not creating a public IP address.")
|
log.Info("Not creating a public IP address.")
|
||||||
} else {
|
} else {
|
||||||
if err := c.CreatePublicIPAddress(d.ctx, d.ResourceGroup, d.naming().IP(), d.Location); err != nil {
|
if err := c.CreatePublicIPAddress(d.ctx, d.ResourceGroup, d.naming().IP(), d.Location, d.StaticPublicIP); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,13 +142,23 @@ func (a AzureClient) DeleteNetworkSecurityGroupIfExists(resourceGroup, name stri
|
||||||
func() (autorest.Response, error) { return a.securityGroupsClient().Delete(resourceGroup, name) })
|
func() (autorest.Response, error) { return a.securityGroupsClient().Delete(resourceGroup, name) })
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string) error {
|
func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string, isStatic bool) error {
|
||||||
log.Info("Creating public IP address...", logutil.Fields{"name": name})
|
log.Info("Creating public IP address...", logutil.Fields{
|
||||||
|
"name": name,
|
||||||
|
"static": isStatic})
|
||||||
|
|
||||||
|
var ipType network.IPAllocationMethod
|
||||||
|
if isStatic {
|
||||||
|
ipType = network.Static
|
||||||
|
} else {
|
||||||
|
ipType = network.Dynamic
|
||||||
|
}
|
||||||
|
|
||||||
_, err := a.publicIPAddressClient().CreateOrUpdate(resourceGroup, name,
|
_, err := a.publicIPAddressClient().CreateOrUpdate(resourceGroup, name,
|
||||||
network.PublicIPAddress{
|
network.PublicIPAddress{
|
||||||
Location: to.StringPtr(location),
|
Location: to.StringPtr(location),
|
||||||
Properties: &network.PublicIPAddressPropertiesFormat{
|
Properties: &network.PublicIPAddressPropertiesFormat{
|
||||||
PublicIPAllocationMethod: network.Dynamic,
|
PublicIPAllocationMethod: ipType,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue