Categorygithub.com/denverdino/docker-machine-driver-aliyunecs
repositorypackage
0.0.0-20210910084342-1807b27d9cd7
Repository: https://github.com/denverdino/docker-machine-driver-aliyunecs.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Docker Machine Driver of Aliyun ECS

Build Status

Create machines on Aliyun Elastic Compute Service (ECS). You will need an Access Key ID, Secret Access Key and a Region ID. If you want to setup instance on the VPC network, you will need the VPC ID and VSwitch ID; Please login to the Aliyun console -> Products and Services -> VPC and select the one where you would like to launch the instance.

creates docker instances on Aliyun ECS.

docker-machine create -d aliyunecs machine-aliyunecs

Installation

The easiest way to install the aliyun docker-machine driver is to:

go get github.com/AliyunContainerService/docker-machine-driver-aliyunecs

binaries also available,you can download from below links:

How to install docker-machine-driver-aliyunecs binary packages on different platforms.

  • Download the binary package for the corresponding platform. We currently support Windows, Linux, and MAC platforms

  • Extract the donload package

    eg. Take the Mac platform for example

    	tar zxvf docker-machine-driver-aliyunecs_darwin-amd64.tgz
    
  • Rename the executable

    #Windows
    docker-machine-driver-aliyunecs.windows-amd64 => docker-machine-driver-aliyunecs.exe
    
    #Linux
    docker-machine-driver-aliyunecs.linux-amd64 => docker-machine-driver-aliyunecs
    
    #Mac
    docker-machine-driver-aliyunecs.darwin-amd64 => docker-machine-driver-aliyunecs
    
  • Add docker-machine driver to the environment variables.

    export PATH=<Your Local Path>/docker-machine-driver-aliyunecs[.exe]:$PATH
    
    

Example Usage

eg. Export your credentials into your shell environment

export ECS_ACCESS_KEY_ID='<Your access key ID>'
export ECS_ACCESS_KEY_SECRET='<Your secret access key>'
export ECS_REGION='<Your region>'

# Using mirrors from Aliyun
export MACHINE_DOCKER_INSTALL_URL=http://kubernetes.oss-cn-hangzhou.aliyuncs.com/docker_install.sh
export ENGINE_REGISTRY_MIRROR=https://registry.docker-cn.com

docker-machine create -d aliyunecs <machine-name>

or pass as cmdline flags

docker-machine create -d aliyunecs --aliyunecs-access-key-id=<Your access key ID for the Aliyun ECS API> --aliyunecs-access-key-secret=<Your secret access key for the Aliyun ECS API>  --aliyunecs-region=<Region> <machine-name>

Examples

using SSH key pair

docker-machine create -d aliyunecs --aliyunecs-ssh-keypair test_keypair --aliyunecs-ssh-keypath ~/.ssh/id_rsa test

custom docker engine config

docker-machine create -d aliyunecs --engine-storage-driver overlay2 test

custom OS config

docker-machine create -d aliyunecs --aliyunecs-image-id centos_7_04_64_20G_alibase_201701015.vhd test

attach data disk for Docker containers

docker-machine create -d aliyunecs --engine-storage-driver overlay2 --aliyunecs-disk-size 40 --aliyunecs-disk-fs xfs test

Options

docker-machine create -d aliyunecs --help
Option NameDescriptionrequired
--aliyunecs-access-key-idYour access key ID for the Aliyun ECS API.yes
--aliyunecs-access-key-secretYour secret access key for the Aliyun ECS API.yes
--aliyunecs-api-endpointThe custom API endpoint.
--aliyunecs-descriptionThe description of instance.
--aliyunecs-disk-sizeThe data disk size for /var/lib/docker (in GB)
--aliyunecs-disk-fsThe file system for data disk (ext4 or xfs).
--aliyunecs-disk-categoryThe category of data disk, the valid values could be cloud (default), cloud_efficiency or cloud_ssd.
--aliyunecs-system-disk-sizeThe system disk size for /var/lib/docker (in GB)
--aliyunecs-system-disk-categoryThe category of system disk, the valid values could be cloud (default), cloud_efficiency or cloud_ssd.
--aliyunecs-image-idThe image ID of the instance to use Default is the latest Ubuntu 16.04 provided by system
--aliyunecs-io-optimizedThe I/O optimized instance type, the valid values could be none (default) or optimized
--aliyunecs-instance-typeThe instance type to run. Default: ecs.n4.small
--aliyunecs-internet-max-bandwidthMaximum bandwidth for Internet access (in Mbps), default 1
--aliyunecs-internet-charge-typeInternet charge type, the valid values could be PayByTraffic (default) or PayByBandwidth
--aliyunecs-private-address-onlyUse the private IP address only
--aliyunecs-regionThe region to use when launching the instance. Default: cn-hangzhou
--aliyunecs-route-cidrThe CIDR to use configure the route entry for the instance in VPC. Sample: 192.168.200.0/24
--aliyunecs-security-groupAliyun security group name. Default: docker-machine
--aliyunecs-slb-idSLB id for instance association
--aliyunecs-ssh-passwordSSH password for created virtual machine. Default is random generated.
--aliyunecs-ssh-keypairSSH key pair name
--aliyunecs-ssh-keypathFile path of SSH private key
--aliyunecs-tagTag for the instance.
--aliyunecs-vpc-idYour VPC ID to launch the instance in. (required for VPC network only)
--aliyunecs-vswitch-idYour VSwitch ID to launch the instance with. (required for VPC network only)
--aliyunecs-zoneThe availability zone to launch the instance

Environment variables and default values:

CLI optionEnvironment variableDefault
--aliyunecs-access-key-idECS_ACCESS_KEY_ID-
--aliyunecs-access-key-keyECS_ACCESS_KEY_SECRET-
--aliyunecs-api-endpointECS_API_ENDPOINT-
--aliyunecs-descriptionECS_DESCRIPTION-
--aliyunecs-disk-sizeECS_DISK_SIZE-
--aliyunecs-disk-categoryECS_DISK_CATEGORY-
--aliyunecs-disk-fsECS_DISK_FSext4
--aliyunecs-system-disk-sizeECS_SYSTEM_DISK_SIZE-
--aliyunecs-system-disk-categoryECS_SYSTEM_DISK_CATEGORY-
--aliyunecs-image-idECS_IMAGE_ID-
--aliyunecs-aliyunecs-io-optimizedECS_IO_OPTIMIZEDnone
--aliyunecs-instance-typeECS_INSTANCE_TYPEecs.t1.small
--aliyunecs-internet-max-bandwidthECS_INTERNET_MAX_BANDWIDTH1
--aliyunecs-internet-charge-typeECS_INTERNET_CHARGE_TYPEPayByTraffic
--aliyunecs-private-address-onlyECS_PRIVATE_ADDR_ONLYfalse
--aliyunecs-regionECS_REGIONcn-hangzhou
--aliyunecs-route-cidrECS_ROUTE_CIDR-
--aliyunecs-security-groupECS_SECURITY_GROUP-
--aliyunecs-slb-idECS_SLB_ID-
--aliyunecs-ssh-passwordECS_SSH_PASSWORDRandom generated
--aliyunecs-ssh-keypairECS_SSH_KEYPAIR-
--aliyunecs-ssh-keypathECS_SSH_KEYPATH-
--aliyunecs-tagECS_TAGS-
--aliyunecs-vpc-idECS_VPC_ID-
--aliyunecs-vswitch-idECS_VSWITCH_ID-
--aliyunecs-zoneECS_ZONE-

Each environment variable may be overloaded by its option equivalent at runtime.

OS

The default OS is Ubuntu 16.04, and you can select your preferred image-id

Hacking

Get the sources

go get github.com/AliyunContainerService/docker-machine-driver-aliyunecs
cd $GOPATH/src/github.com/AliyunContainerService/docker-machine-driver-aliyunecs

Test the driver

To test the driver make sure your current build directory has the highest priority in your $PATH so that docker-machine can find it.

export PATH=$GOPATH/src/github.com/AliyunContainerService/docker-machine-driver-aliyunecs:$PATH

Related links

License

Apache 2.0