mirror of https://github.com/docker/docs.git
authorize swarm port when master is in ec2; fix max dns name for azure
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
557d03a849
commit
4e95c2760f
|
@ -6,8 +6,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
@ -42,8 +45,8 @@ type Driver struct {
|
||||||
InstanceType string
|
InstanceType string
|
||||||
IPAddress string
|
IPAddress string
|
||||||
MachineName string
|
MachineName string
|
||||||
SecurityGroupName string
|
|
||||||
SecurityGroupId string
|
SecurityGroupId string
|
||||||
|
SecurityGroupName string
|
||||||
ReservationId string
|
ReservationId string
|
||||||
RootSize int64
|
RootSize int64
|
||||||
VpcId string
|
VpcId string
|
||||||
|
@ -53,6 +56,8 @@ type Driver struct {
|
||||||
PrivateKeyPath string
|
PrivateKeyPath string
|
||||||
storePath string
|
storePath string
|
||||||
keyPath string
|
keyPath string
|
||||||
|
swarmMaster bool
|
||||||
|
swarmHost string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateFlags struct {
|
type CreateFlags struct {
|
||||||
|
@ -170,6 +175,8 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
zone := flags.String("amazonec2-zone")
|
zone := flags.String("amazonec2-zone")
|
||||||
d.Zone = zone[:]
|
d.Zone = zone[:]
|
||||||
d.RootSize = int64(flags.Int("amazonec2-root-size"))
|
d.RootSize = int64(flags.Int("amazonec2-root-size"))
|
||||||
|
d.swarmMaster = flags.Bool("swarm-master")
|
||||||
|
d.swarmHost = flags.String("swarm-host")
|
||||||
|
|
||||||
if d.AccessKey == "" {
|
if d.AccessKey == "" {
|
||||||
return fmt.Errorf("amazonec2 driver requires the --amazonec2-access-key option")
|
return fmt.Errorf("amazonec2 driver requires the --amazonec2-access-key option")
|
||||||
|
@ -556,6 +563,10 @@ func (d *Driver) terminate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Driver) isSwarmMaster() bool {
|
||||||
|
return d.swarmMaster
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Driver) configureSecurityGroup(groupName string) error {
|
func (d *Driver) configureSecurityGroup(groupName string) error {
|
||||||
log.Debugf("configuring security group in %s", d.VpcId)
|
log.Debugf("configuring security group in %s", d.VpcId)
|
||||||
|
|
||||||
|
@ -596,12 +607,33 @@ func (d *Driver) configureSecurityGroup(groupName string) error {
|
||||||
|
|
||||||
d.SecurityGroupId = securityGroup.GroupId
|
d.SecurityGroupId = securityGroup.GroupId
|
||||||
|
|
||||||
|
perms := configureSecurityGroupPermissions(securityGroup)
|
||||||
|
|
||||||
// configure swarm permission if needed
|
// configure swarm permission if needed
|
||||||
|
if d.isSwarmMaster() {
|
||||||
|
u, err := url.Parse(d.swarmHost)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error authorizing port for swarm: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
parts := strings.Split(u.Host, ":")
|
||||||
|
port, err := strconv.Atoi(parts[1])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("authorizing swarm on port %d", port)
|
||||||
|
|
||||||
|
perms = append(perms, amz.IpPermission{
|
||||||
|
IpProtocol: "tcp",
|
||||||
|
FromPort: port,
|
||||||
|
ToPort: port,
|
||||||
|
IpRange: ipRange,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("configuring security group authorization for %s", ipRange)
|
log.Debugf("configuring security group authorization for %s", ipRange)
|
||||||
|
|
||||||
perms := configureSecurityGroupPermissions(securityGroup)
|
|
||||||
|
|
||||||
if len(perms) != 0 {
|
if len(perms) != 0 {
|
||||||
log.Debugf("authorizing group %s with permissions: %v", securityGroup.GroupName, perms)
|
log.Debugf("authorizing group %s with permissions: %v", securityGroup.GroupName, perms)
|
||||||
if err := d.getClient().AuthorizeSecurityGroup(d.SecurityGroupId, perms); err != nil {
|
if err := d.getClient().AuthorizeSecurityGroup(d.SecurityGroupId, perms); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue