|
| 1 | +Creating Instance on GCP |
| 2 | +======================== |
| 3 | + |
| 4 | +You can use flags on the command line or start the plugin interactively: |
| 5 | + |
| 6 | +```shell |
| 7 | +$ infrakit gcp start-plugin |
| 8 | +Run as Docker container? n |
| 9 | +What's the zone? us-central1-f |
| 10 | +What's the name of the project? docker4x |
| 11 | +Starting daemon |
| 12 | +Tailing log |
| 13 | +time="2017-04-05T00:34:40-07:00" level=debug msg="Using namespacemap[infrakit.scope:docker4x]" |
| 14 | +time="2017-04-05T00:34:40-07:00" level=debug msg="Project: docker4x" |
| 15 | +time="2017-04-05T00:34:40-07:00" level=debug msg="Zone: us-central1-f" |
| 16 | +time="2017-04-05T00:34:40-07:00" level=info msg="Listening at: /Users/davidchung/.infrakit/plugins/instance-gcp" |
| 17 | +time="2017-04-05T00:34:40-07:00" level=info msg="PID file at /Users/davidchung/.infrakit/plugins/instance-gcp.pid" |
| 18 | +``` |
| 19 | + |
| 20 | +Now in another shell, create an instance, using the `provision-instance` command which is basically a 'script' |
| 21 | +that is based on a YAML input and piped to `infrakit instance provision` itself: |
| 22 | + |
| 23 | +```shell |
| 24 | +$ infrakit gcp -h |
| 25 | + |
| 26 | + |
| 27 | +___ ________ ________ ________ ________ ___ __ ___ _________ |
| 28 | +|\ \|\ ___ \|\ _____\\ __ \|\ __ \|\ \|\ \ |\ \|\___ ___\ |
| 29 | +\ \ \ \ \\ \ \ \ \__/\ \ \|\ \ \ \|\ \ \ \/ /|\ \ \|___ \ \_| |
| 30 | + \ \ \ \ \\ \ \ \ __\\ \ _ _\ \ __ \ \ ___ \ \ \ \ \ \ |
| 31 | + \ \ \ \ \\ \ \ \ \_| \ \ \\ \\ \ \ \ \ \ \\ \ \ \ \ \ \ \ |
| 32 | + \ \__\ \__\\ \__\ \__\ \ \__\\ _\\ \__\ \__\ \__\\ \__\ \__\ \ \__\ |
| 33 | + \|__|\|__| \|__|\|__| \|__|\|__|\|__|\|__|\|__| \|__|\|__| \|__| |
| 34 | + |
| 35 | + |
| 36 | +gcp |
| 37 | + |
| 38 | +Usage: |
| 39 | + infrakit gcp [command] |
| 40 | + |
| 41 | +Available Commands: |
| 42 | + provision-instance provision-instance |
| 43 | + start-plugin start-plugin |
| 44 | + |
| 45 | +Global Flags: |
| 46 | + -H, --host stringSlice host list. Default is local sockets |
| 47 | + --httptest.serve string if non-empty, httptest.NewServer serves on this address and blocks |
| 48 | + --log int log level (default 4) |
| 49 | + --log-caller include caller function (default true) |
| 50 | + --log-format string log format: logfmt|term|json (default "term") |
| 51 | + --log-stack include caller stack |
| 52 | + --log-stdout log to stdout |
| 53 | + |
| 54 | +Use "infrakit gcp [command] --help" for more information about a command. |
| 55 | +``` |
| 56 | +
|
| 57 | +```shell |
| 58 | +$ infrakit gcp provision-instance -h |
| 59 | + |
| 60 | + |
| 61 | +___ ________ ________ ________ ________ ___ __ ___ _________ |
| 62 | +|\ \|\ ___ \|\ _____\\ __ \|\ __ \|\ \|\ \ |\ \|\___ ___\ |
| 63 | +\ \ \ \ \\ \ \ \ \__/\ \ \|\ \ \ \|\ \ \ \/ /|\ \ \|___ \ \_| |
| 64 | + \ \ \ \ \\ \ \ \ __\\ \ _ _\ \ __ \ \ ___ \ \ \ \ \ \ |
| 65 | + \ \ \ \ \\ \ \ \ \_| \ \ \\ \\ \ \ \ \ \ \\ \ \ \ \ \ \ \ |
| 66 | + \ \__\ \__\\ \__\ \__\ \ \__\\ _\\ \__\ \__\ \__\\ \__\ \__\ \ \__\ |
| 67 | + \|__|\|__| \|__|\|__| \|__|\|__|\|__|\|__|\|__| \|__|\|__| \|__| |
| 68 | + |
| 69 | + |
| 70 | +provision-instance |
| 71 | + |
| 72 | +Usage: |
| 73 | + infrakit gcp provision-instance [flags] |
| 74 | + |
| 75 | +Flags: |
| 76 | + --disk-size int Disk size in mb |
| 77 | + --machine-type string Machine type |
| 78 | + --prefix string Prefix to use |
| 79 | + --user string owner |
| 80 | + |
| 81 | +Global Flags: |
| 82 | + -H, --host stringSlice host list. Default is local sockets |
| 83 | + --httptest.serve string if non-empty, httptest.NewServer serves on this address and blocks |
| 84 | + --log int log level (default 4) |
| 85 | + --log-caller include caller function (default true) |
| 86 | + --log-format string log format: logfmt|term|json (default "term") |
| 87 | + --log-stack include caller stack |
| 88 | + --log-stdout log to stdout |
| 89 | +``` |
| 90 | +
|
| 91 | +Note that there are flags defined. You can set the in the commandline, or set the interactively: |
| 92 | +
|
| 93 | +```shell |
| 94 | +$ infrakit gcp provision-instance |
| 95 | +Owner? dchung |
| 96 | +Prefix for hostname: dchung |
| 97 | +Disk size in MB [60]? 100 |
| 98 | +Machine type [n1-standard-1]? n1-standard-1 |
| 99 | +dchung-2rg5i2 |
| 100 | +``` |
| 101 | +
|
| 102 | +Now you a list: |
| 103 | +
|
| 104 | +```shell |
| 105 | +$ infrakit instance --name instance-gcp describe |
| 106 | +ID LOGICAL TAGS |
| 107 | +dchung-kw5i37 - infrakit-created=2017-04-05,infrakit-user=dchung,infrakit.scope=docker4x,startup-script=#!/bin/bash |
| 108 | +sudo apt-get update -y |
| 109 | +sudo apt-get install wget curl |
| 110 | +wget -q0- https://get.docker.com | sh |
| 111 | + |
| 112 | +``` |
| 113 | +
|
| 114 | +Note the tags.. we can apply template to define the view on the tags. |
| 115 | +
|
| 116 | +```shell |
| 117 | +$ infrakit instance --name instance-gcp describe --tags-view="{{ len . }}" |
| 118 | +ID LOGICAL TAGS |
| 119 | +dchung-kw5i37 - 4 |
| 120 | +``` |
| 121 | +
|
| 122 | +Also, we can query for details and print out the raw data, as YAML: |
| 123 | +
|
| 124 | +```shell |
| 125 | +$ infrakit instance --name instance-gcp describe -pry |
| 126 | +- ID: dchung-kw5i37 |
| 127 | + LogicalID: null |
| 128 | + Properties: |
| 129 | + cpuPlatform: Intel Ivy Bridge |
| 130 | + creationTimestamp: 2017-04-05T00:30:08.433-07:00 |
| 131 | + description: Some description |
| 132 | + disks: |
| 133 | + - autoDelete: true |
| 134 | + boot: true |
| 135 | + deviceName: persistent-disk-0 |
| 136 | + interface: SCSI |
| 137 | + kind: compute#attachedDisk |
| 138 | + licenses: |
| 139 | + - https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1404-trusty |
| 140 | + mode: READ_WRITE |
| 141 | + source: https://www.googleapis.com/compute/v1/projects/docker4x/zones/us-central1-f/disks/dchung-kw5i37 |
| 142 | + type: PERSISTENT |
| 143 | + id: "5569308151087965167" |
| 144 | + kind: compute#instance |
| 145 | + machineType: https://www.googleapis.com/compute/v1/projects/docker4x/zones/us-central1-f/machineTypes/n1-standard-1 |
| 146 | + metadata: |
| 147 | + fingerprint: zMKHzh-yLow= |
| 148 | + items: |
| 149 | + - key: infrakit--scope |
| 150 | + value: docker4x |
| 151 | + - key: infrakit-created |
| 152 | + value: 2017-04-05 |
| 153 | + - key: infrakit-user |
| 154 | + value: dchung |
| 155 | + - key: startup-script |
| 156 | + value: | |
| 157 | + #!/bin/bash |
| 158 | + sudo apt-get update -y |
| 159 | + sudo apt-get install wget curl |
| 160 | + wget -q0- https://get.docker.com | sh |
| 161 | + kind: compute#metadata |
| 162 | + name: dchung-kw5i37 |
| 163 | + networkInterfaces: |
| 164 | + - accessConfigs: |
| 165 | + - kind: compute#accessConfig |
| 166 | + name: external-nat |
| 167 | + natIP: 104.154.99.160 |
| 168 | + type: ONE_TO_ONE_NAT |
| 169 | + kind: compute#networkInterface |
| 170 | + name: nic0 |
| 171 | + network: https://www.googleapis.com/compute/v1/projects/docker4x/global/networks/default |
| 172 | + networkIP: 10.128.0.3 |
| 173 | + subnetwork: https://www.googleapis.com/compute/v1/projects/docker4x/regions/us-central1/subnetworks/default |
| 174 | + scheduling: |
| 175 | + automaticRestart: true |
| 176 | + onHostMaintenance: MIGRATE |
| 177 | + selfLink: https://www.googleapis.com/compute/v1/projects/docker4x/zones/us-central1-f/instances/dchung-kw5i37 |
| 178 | + serviceAccounts: |
| 179 | + |
| 180 | + scopes: |
| 181 | + - https://www.googleapis.com/auth/cloudruntimeconfig |
| 182 | + - https://www.googleapis.com/auth/logging.write |
| 183 | + status: RUNNING |
| 184 | + tags: |
| 185 | + fingerprint: pDfT_HVxXHI= |
| 186 | + items: |
| 187 | + - dchung |
| 188 | + zone: https://www.googleapis.com/compute/v1/projects/docker4x/zones/us-central1-f |
| 189 | + Tags: |
| 190 | + infrakit-created: 2017-04-05 |
| 191 | + infrakit-user: dchung |
| 192 | + infrakit.scope: docker4x |
| 193 | + startup-script: | |
| 194 | + #!/bin/bash |
| 195 | + sudo apt-get update -y |
| 196 | + sudo apt-get install wget curl |
| 197 | + wget -q0- https://get.docker.com | sh |
| 198 | +``` |
0 commit comments