Commit bea2a506 authored by Eric Tune's avatar Eric Tune

Merge pull request #2608 from jbeda/gcloud

Convert GCE scripts from gcutil to 'gcloud compute'
parents 28df3cb0 6d658055
...@@ -20,7 +20,7 @@ MASTER_SIZE=n1-standard-1 ...@@ -20,7 +20,7 @@ MASTER_SIZE=n1-standard-1
MINION_SIZE=n1-standard-1 MINION_SIZE=n1-standard-1
NUM_MINIONS=4 NUM_MINIONS=4
# TODO(dchen1107): Filed an internal issue to create an alias # TODO(dchen1107): Filed an internal issue to create an alias
# for containervm image, so that gcloud/gcutil will expand this # for containervm image, so that gcloud will expand this
# to the latest supported image. # to the latest supported image.
IMAGE=container-vm-v20141016 IMAGE=container-vm-v20141016
IMAGE_PROJECT=google-containers IMAGE_PROJECT=google-containers
...@@ -31,7 +31,7 @@ MASTER_TAG="${INSTANCE_PREFIX}-master" ...@@ -31,7 +31,7 @@ MASTER_TAG="${INSTANCE_PREFIX}-master"
MINION_TAG="${INSTANCE_PREFIX}-minion" MINION_TAG="${INSTANCE_PREFIX}-minion"
MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}})) MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}}))
MINION_IP_RANGES=($(eval echo "10.244.{1..${NUM_MINIONS}}.0/24")) MINION_IP_RANGES=($(eval echo "10.244.{1..${NUM_MINIONS}}.0/24"))
MINION_SCOPES="storage-ro,compute-rw" MINION_SCOPES=("storage-ro" "compute-rw")
# Increase the sleep interval value if concerned about API rate limits. 3, in seconds, is the default. # Increase the sleep interval value if concerned about API rate limits. 3, in seconds, is the default.
POLL_SLEEP_INTERVAL=3 POLL_SLEEP_INTERVAL=3
PORTAL_NET="10.0.0.0/16" PORTAL_NET="10.0.0.0/16"
......
...@@ -20,7 +20,7 @@ MASTER_SIZE=g1-small ...@@ -20,7 +20,7 @@ MASTER_SIZE=g1-small
MINION_SIZE=g1-small MINION_SIZE=g1-small
NUM_MINIONS=2 NUM_MINIONS=2
# TODO(dchen1107): Filed an internal issue to create an alias # TODO(dchen1107): Filed an internal issue to create an alias
# for containervm image, so that gcloud/gcutil will expand this # for containervm image, so that gcloud will expand this
# to the latest supported image. # to the latest supported image.
IMAGE=container-vm-v20141016 IMAGE=container-vm-v20141016
IMAGE_PROJECT=google-containers IMAGE_PROJECT=google-containers
...@@ -31,7 +31,7 @@ MASTER_TAG="${INSTANCE_PREFIX}-master" ...@@ -31,7 +31,7 @@ MASTER_TAG="${INSTANCE_PREFIX}-master"
MINION_TAG="${INSTANCE_PREFIX}-minion" MINION_TAG="${INSTANCE_PREFIX}-minion"
MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}})) MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}}))
MINION_IP_RANGES=($(eval echo "10.245.{1..${NUM_MINIONS}}.0/24")) MINION_IP_RANGES=($(eval echo "10.245.{1..${NUM_MINIONS}}.0/24"))
MINION_SCOPES="storage-ro,compute-rw" MINION_SCOPES=("storage-ro" "compute-rw")
# Increase the sleep interval value if concerned about API rate limits. 3, in seconds, is the default. # Increase the sleep interval value if concerned about API rate limits. 3, in seconds, is the default.
POLL_SLEEP_INTERVAL=3 POLL_SLEEP_INTERVAL=3
PORTAL_NET="10.0.0.0/16" PORTAL_NET="10.0.0.0/16"
......
...@@ -40,11 +40,12 @@ We set up this bridge on each node with SaltStack, in [container_bridge.py](clus ...@@ -40,11 +40,12 @@ We set up this bridge on each node with SaltStack, in [container_bridge.py](clus
We make these addresses routable in GCE: We make these addresses routable in GCE:
gcutil addroute ${MINION_NAMES[$i]} ${MINION_IP_RANGES[$i]} \ gcloud compute routes add "${MINION_NAMES[$i]}" \
--norespect_terminal_width \ --project "${PROJECT}" \
--project ${PROJECT} \ --destination-range "${MINION_IP_RANGES[$i]}" \
--network ${NETWORK} \ --network "${NETWORK}" \
--next_hop_instance ${ZONE}/instances/${MINION_NAMES[$i]} & --next-hop-instance "${MINION_NAMES[$i]}" \
--next-hop-instance-zone "${ZONE}" &
The minion IP ranges are /24s in the 10-dot space. The minion IP ranges are /24s in the 10-dot space.
......
...@@ -9,14 +9,14 @@ The example below creates a Kubernetes cluster with 4 worker node Virtual Machin ...@@ -9,14 +9,14 @@ The example below creates a Kubernetes cluster with 4 worker node Virtual Machin
2. Make sure you can start up a GCE VM. At least make sure you can do the [Create an instance](https://developers.google.com/compute/docs/quickstart#addvm) part of the GCE Quickstart. 2. Make sure you can start up a GCE VM. At least make sure you can do the [Create an instance](https://developers.google.com/compute/docs/quickstart#addvm) part of the GCE Quickstart.
3. Make sure you can ssh into the VM without interactive prompts. 3. Make sure you can ssh into the VM without interactive prompts.
* Your GCE SSH key must either have no passcode or you need to be using `ssh-agent`. * Your GCE SSH key must either have no passcode or you need to be using `ssh-agent`.
* Ensure the GCE firewall isn't blocking port 22 to your VMs. By default, this should work but if you have edited firewall rules or created a new non-default network, you'll need to expose it: `gcutil addfirewall --network=<network-name> --description "SSH allowed from anywhere" --allowed=tcp:22 default-ssh` * Ensure the GCE firewall isn't blocking port 22 to your VMs. By default, this should work but if you have edited firewall rules or created a new non-default network, you'll need to expose it: `gcloud compute firewall-rules create --network=<network-name> --description "SSH allowed from anywhere" --allow tcp:22 default-ssh`
4. You need to have the Google Cloud Storage API, and the Google Cloud Storage JSON API enabled. This can be done in the Google Cloud Console. 4. You need to have the Google Cloud Storage API, and the Google Cloud Storage JSON API enabled. This can be done in the Google Cloud Console.
### Prerequisites for your workstation ### Prerequisites for your workstation
1. Be running a Linux or Mac OS X. 1. Be running a Linux or Mac OS X.
2. You must have the [Google Cloud SDK](https://developers.google.com/cloud/sdk/) installed. This will get you `gcloud`, `gcutil` and `gsutil`. 2. You must have the [Google Cloud SDK](https://developers.google.com/cloud/sdk/) installed. This will get you `gcloud` and `gsutil`.
3. Ensure that your `gcloud` components are up-to-date by running `gcloud components update`. 3. Ensure that your `gcloud` components are up-to-date by running `gcloud components update`.
4. If you want to build your own release, you need to have [Docker 4. If you want to build your own release, you need to have [Docker
installed](https://docs.docker.com/installation/). On Mac OS X you can use installed](https://docs.docker.com/installation/). On Mac OS X you can use
......
...@@ -59,10 +59,15 @@ Before you can use a GCE PD with a pod, you need to create it and format it. ...@@ -59,10 +59,15 @@ Before you can use a GCE PD with a pod, you need to create it and format it.
__We are actively working on making this more streamlined.__ __We are actively working on making this more streamlined.__
```sh ```sh
gcutil adddisk --size_gb=<size> --zone=<zone> <name> DISK_NAME=my-data-disk
gcutil attachdisk --disk <name> kubernetes-master DISK_SIZE=500GB
gcutil ssh kubernetes-master sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-test2 /mnt/tmp ZONE=us-central1-a
gcutil detachdisk --device_name google-<name> kubernetes-master
gcloud compute disks create --size=$DISK_SIZE --zone=$ZONE $DISK_NAME
gcloud compute instances attach-disk --zone=$ZONE --disk=$DISK_NAME --device-name temp-data kubernetes-master
gcloud compute ssh --zone=$ZONE kubernetes-master \
--command "sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-temp-data /mnt/tmp"
gcloud compute instances detach-disk --zone=$ZONE --disk $DISK_NAME kubernetes-master
``` ```
#### GCE PD Example configuration: #### GCE PD Example configuration:
......
...@@ -39,8 +39,7 @@ redis-master-pod gurpartap/redis kubernetes-minion-3.c.thockin-dev.intern ...@@ -39,8 +39,7 @@ redis-master-pod gurpartap/redis kubernetes-minion-3.c.thockin-dev.intern
If you ssh to that machine, you can run `docker ps` to see the actual pod: If you ssh to that machine, you can run `docker ps` to see the actual pod:
```shell ```shell
$ gcutil ssh --zone us-central1-b kubernetes-minion-3 me@workstation$ gcloud compute ssh --zone us-central1-b kubernetes-minion-3
$ sudo docker ps
me@kubernetes-minion-3:~$ sudo docker ps me@kubernetes-minion-3:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS CONTAINER ID IMAGE COMMAND CREATED STATUS
...@@ -165,33 +164,33 @@ redis-slave name=redis,role=slave name=redis,role=slave 10.0.0.2 ...@@ -165,33 +164,33 @@ redis-slave name=redis,role=slave name=redis,role=slave 10.0.0.2
guestbook name=guestbook 10.0.0.3 3000 guestbook name=guestbook 10.0.0.3 3000
``` ```
To play with the service itself, find the external IP of the load balancer from the [Google Cloud Console][cloud-console] or the `gcutil` tool, and visit `http://<ip>:3000`. To play with the service itself, find the external IP of the load balancer from the [Google Cloud Console][cloud-console] or the `gcloud` tool, and visit `http://<ip>:3000`.
```shell ```shell
$ gcutil getforwardingrule guestbook $ gcloud compute forwarding-rules describe --region=us-central1 guestbook
+---------------+-----------------------------------+ IPAddress: 11.22.33.44
| name | guestbook | IPProtocol: TCP
| description | | creationTimestamp: '2014-11-24T16:08:15.327-08:00'
| creation-time | 2014-10-15T19:07:24.837-07:00 | id: '17594840560849468061'
| region | us-central1 | kind: compute#forwardingRule
| ip | 12.34.56.78 | name: guestbook
| protocol | TCP | portRange: 1-65535
| port-range | 3000-3000 | region: https://www.googleapis.com/compute/v1/projects/jbeda-prod/regions/us-central1
| target | us-central1/targetPools/guestbook | selfLink: https://www.googleapis.com/compute/v1/projects/jbeda-prod/regions/us-central1/forwardingRules/guestbook
+---------------+-----------------------------------+ target: https://www.googleapis.com/compute/v1/projects/jbeda-prod/regions/us-central1/targetPools/guestbook
``` ```
You may need to open the firewall for port 3000 using the [console][cloud-console] or the `gcutil` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`: You may need to open the firewall for port 3000 using the [console][cloud-console] or the `gcloud` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`:
```shell ```shell
$ gcutil addfirewall --allowed=tcp:3000 --target_tags=kubernetes-minion kubernetes-minion-3000 $ gcloud compute firewall-rules create --allow=tcp:3000 --target-tags=kubernetes-minion kubernetes-minion-3000
``` ```
If you are running Kubernetes locally, you can just visit http://localhost:3000 If you are running Kubernetes locally, you can just visit http://localhost:3000
For details about limiting traffic to specific sources, see the [gcutil documentation][gcutil-docs] For details about limiting traffic to specific sources, see the [GCE firewall documentation][gce-firewall-docs].
[cloud-console]: https://console.developer.google.com [cloud-console]: https://console.developer.google.com
[gcutil-docs]: https://developers.google.com/compute/docs/gcutil/reference/firewall#addfirewall [gce-firewall-docs]: https://cloud.google.com/compute/docs/networking#firewalls
### Step Seven: Cleanup ### Step Seven: Cleanup
......
...@@ -66,8 +66,7 @@ redis-master dockerfile/redis kubernetes-minion-3.c.briandpe-api.inter ...@@ -66,8 +66,7 @@ redis-master dockerfile/redis kubernetes-minion-3.c.briandpe-api.inter
If you ssh to that machine, you can run `docker ps` to see the actual pod: If you ssh to that machine, you can run `docker ps` to see the actual pod:
```shell ```shell
$ gcutil ssh --zone us-central1-b kubernetes-minion-3 me@workstation$ gcloud compute ssh --zone us-central1-b kubernetes-minion-3
$ sudo docker ps
me@kubernetes-minion-3:~$ sudo docker ps me@kubernetes-minion-3:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
...@@ -308,23 +307,23 @@ if (isset($_GET['cmd']) === true) { ...@@ -308,23 +307,23 @@ if (isset($_GET['cmd']) === true) {
} ?> } ?>
``` ```
To play with the service itself, find the name of a frontend, grab the external IP of that host from the [Google Cloud Console][cloud-console] or the `gcutil` tool, and visit `http://<host-ip>:8000`. To play with the service itself, find the name of a frontend, grab the external IP of that host from the [Google Cloud Console][cloud-console] or the `gcloud` tool, and visit `http://<host-ip>:8000`.
```shell ```shell
$ gcutil listinstances $ gcloud compute instances list
``` ```
You may need to open the firewall for port 8000 using the [console][cloud-console] or the `gcutil` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`: You may need to open the firewall for port 8000 using the [console][cloud-console] or the `gcloud` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`:
```shell ```shell
$ gcutil addfirewall --allowed=tcp:8000 --target_tags=kubernetes-minion kubernetes-minion-8000 $ gcloud compute firewall-rules create --allow=tcp:8000 --target-tags=kubernetes-minion kubernetes-minion-8000
``` ```
If you are running Kubernetes locally, you can just visit http://localhost:8000. If you are running Kubernetes locally, you can just visit http://localhost:8000.
For details about limiting traffic to specific sources, see the [gcutil documentation][gcutil-docs]. For details about limiting traffic to specific sources, see the [GCE firewall documentation][gce-firewall-docs].
[cloud-console]: https://console.developer.google.com [cloud-console]: https://console.developer.google.com
[gcutil-docs]: https://developers.google.com/compute/docs/gcutil/reference/firewall#addfirewall [gce-firewall-docs]: https://cloud.google.com/compute/docs/networking#firewalls
### Step Six: Cleanup ### Step Six: Cleanup
......
...@@ -33,10 +33,12 @@ It also assumes that `$DOCKER_HUB_USER` is set to your Docker user id. We use t ...@@ -33,10 +33,12 @@ It also assumes that `$DOCKER_HUB_USER` is set to your Docker user id. We use t
$ export DOCKER_HUB_USER=my-docker-id $ export DOCKER_HUB_USER=my-docker-id
``` ```
You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcutil` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`: You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcloud` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`:
```bash ```bash
$ gcutil addfirewall --allowed=tcp:8080 --target_tags=kubernetes-minion kubernetes-minion-8080 $ gcloud compute firewall-rules create \
--allow tcp:8080 --target-tags=kubernetes-minion \
--zone=us-central1-a kubernetes-minion-8080
``` ```
### Step Zero: Build the Docker images ### Step Zero: Build the Docker images
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
# Launches a container and verifies it can be reached. Assumes that # Launches a container and verifies it can be reached. Assumes that
# we're being called by hack/e2e-test.sh (we use some env vars it sets up). # we're being called by hack/e2e-test.sh (we use some env vars it sets up).
# TODO: Convert uses of gcutil to gcloud
set -o errexit set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
...@@ -41,7 +39,7 @@ function teardown() { ...@@ -41,7 +39,7 @@ function teardown() {
rm -rf ${config} rm -rf ${config}
echo "Waiting for disk to become unmounted" echo "Waiting for disk to become unmounted"
sleep 20 sleep 20
gcutil deletedisk -f --zone=${ZONE} ${disk_name} gcloud compute disks delete --quiet --zone="${ZONE}" "${disk_name}"
} }
trap "teardown" EXIT trap "teardown" EXIT
...@@ -49,13 +47,14 @@ trap "teardown" EXIT ...@@ -49,13 +47,14 @@ trap "teardown" EXIT
perl -p -e "s/%.*%/${disk_name}/g" ${KUBE_ROOT}/examples/gce-pd/testpd.yaml > ${config} perl -p -e "s/%.*%/${disk_name}/g" ${KUBE_ROOT}/examples/gce-pd/testpd.yaml > ${config}
# Create and mount the disk. # Create and mount the disk.
gcutil adddisk --size_gb=10 --zone=${ZONE} ${disk_name} gcloud compute disks create --zone="${ZONE}" --size=10GB "${disk_name}"
gcutil attachdisk --disk ${disk_name} ${MASTER_NAME} gcloud compute instances attach-disk --zone="${ZONE}" --disk="${disk_name}" \
gcutil ssh ${MASTER_NAME} sudo rm -rf /mnt/tmp --device-name temp-data "${MASTER_NAME}"
gcutil ssh ${MASTER_NAME} sudo mkdir /mnt/tmp gcloud compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo rm -rf /mnt/tmp"
gcutil ssh ${MASTER_NAME} sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-${disk_name} /mnt/tmp gcloud compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo mkdir -p /mnt/tmp"
gcutil ssh ${MASTER_NAME} sudo umount /mnt/tmp gcloud compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-temp-data /mnt/tmp"
gcloud compute instances detach-disk --disk ${disk_name} --zone ${ZONE} ${MASTER_NAME} gcloud compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo umount /mnt/tmp"
gcloud compute instances detach-disk --zone="${ZONE}" --disk "${disk_name}" "${MASTER_NAME}"
${KUBECFG} -c ${config} create pods ${KUBECFG} -c ${config} create pods
......
...@@ -40,6 +40,7 @@ var ( ...@@ -40,6 +40,7 @@ var (
tests = flag.String("tests", "", "Run only tests in hack/e2e-suite matching this glob. Ignored if -test is set.") tests = flag.String("tests", "", "Run only tests in hack/e2e-suite matching this glob. Ignored if -test is set.")
root = flag.String("root", absOrDie(filepath.Clean(filepath.Join(path.Base(os.Args[0]), ".."))), "Root directory of kubernetes repository.") root = flag.String("root", absOrDie(filepath.Clean(filepath.Join(path.Base(os.Args[0]), ".."))), "Root directory of kubernetes repository.")
verbose = flag.Bool("v", false, "If true, print all command output.") verbose = flag.Bool("v", false, "If true, print all command output.")
trace_bash = flag.Bool("trace-bash", false, "If true, pass -x to bash to trace all bash commands")
checkVersionSkew = flag.Bool("check_version_skew", true, ""+ checkVersionSkew = flag.Bool("check_version_skew", true, ""+
"By default, verify that client and server have exact version match. "+ "By default, verify that client and server have exact version match. "+
"You can explicitly set to false if you're, e.g., testing client changes "+ "You can explicitly set to false if you're, e.g., testing client changes "+
...@@ -172,6 +173,9 @@ func Test() (failed, passed []string) { ...@@ -172,6 +173,9 @@ func Test() (failed, passed []string) {
func runBash(stepName, bashFragment string) bool { func runBash(stepName, bashFragment string) bool {
cmd := exec.Command("bash", "-s") cmd := exec.Command("bash", "-s")
if *trace_bash {
cmd.Args = append(cmd.Args, "-x")
}
cmd.Stdin = strings.NewReader(bashWrap(bashFragment)) cmd.Stdin = strings.NewReader(bashWrap(bashFragment))
return finishRunning(stepName, cmd) return finishRunning(stepName, cmd)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment