I have be trying to configure Google App Engine with ManagedVMs on Linux for a few days.
We will perform these steps on Ubuntu ( can also be done on Fedora ):
- Install Google App Engine SDK
- Install Latest Docker
- Install VirtualBox
- Install Boot2Docker CLI
Install Google App Engine SDK
Download Google App Engine SDK ( you may want to keep the defaults as is )
$ curl https://sdk.cloud.google.com | bash
Now in a new terminal
$ gcloud auth login
$ gcloud components update gae-python
$ gcloud components update app
Install latest Docker on local machine
Install the latest Docker
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh
Install VirtualBox
Install VirtualBox
$ sudo apt-get install virtualbox
Install Boot2Docker CLI
Download a prebuild binary of Boot2Docker CLI ( version 1.3.2 )
$ wget -c https://github.com/boot2docker/boot2docker-cli/releases/download/v1.3.2/boot2docker-v1.3.2-linux-amd64
$ chmod +x boot2docker-v1.3.2-linux-amd64
Setup the Boot2Docker Image
$ ./boot2docker-v1.3.2-linux-amd64 init
Latest release for boot2docker/boot2docker is v1.4.0
Downloading boot2docker ISO image...
Add port forwarding in the range {49000, 49900} to VirtualBox VM
$ wget -c https://gist.githubusercontent.com/tuxdna/4d0dbc6ccd4786595c43/raw/a080232fc8adce19a389ff190ada4068ed574f19/boot2docker-portforward.sh
$ chmod +x boot2docker-portforward.sh
$ bash -x boot2docker-portforward.sh
Obtain the DOCKER environment variables. These are used for accessing the Docker daemon inside Boot2Docker VM, from localhost
$ ./boot2docker-v1.3.2-linux-amd64 up
$ ./boot2docker-v1.3.2-linux-amd64 shellinit
Writing /home/tuxdna/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /home/tuxdna/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /home/tuxdna/.boot2docker/certs/boot2docker-vm/key.pem
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/home/tuxdna/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
You must note down the three export
commands, and use them to set these environment variables.
Setup GAE ManagedVM environment
Use the Boot2Docker environment variables obtained earlier
$ export DOCKER_HOST=tcp://192.168.59.103:2376
$ export DOCKER_CERT_PATH=/home/tuxdna/.boot2docker/certs/boot2docker-vm
$ export DOCKER_TLS_VERIFY=1
Now begin setup
$ gcloud preview app setup-managed-vms
Ideally this should just work, but if not, then read on.
When there are problems
This will not work right away as you may not have access to different Google registries such as google/docker-registry
.
Get a SSH shell inside Boot2Docker VM, and pull the registry
$ ./boot2docker-v1.3.2-linux-amd64 ssh
$ docker pull google/docker-registry
You need to perform the following steps inside your local machine
Find your refresh token
$ gcloud auth print-refresh-token
Cretae a registry-params.env
file
$ cat > registry-params.env
GCP_OAUTH2_REFRESH_TOKEN=<YOUR_REFRESH_TOKEN_HERE>
GCS_BUCKET=containers-prod
Now use this file to run `google/docker-registry'
$ docker run -d --env-file=registry-params.env -p 5000:5000 google/docker-registry
And again try to run the setup
$ gcloud preview app setup-managed-vms
While these are the steps I have followed, I am still trying to make it work. Hopefully it will work very soon.
References:
- https://cloud.google.com/appengine/docs/python/managed-vms/
- http://sheerun.net/2014/05/17/remote-access-to-docker-with-tls/
- http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide
- https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md
- https://stackoverflow.com/questions/27323570/gcloud-preview-app-setup-managed-vms-gives-errors-500-server-error-internal-s
- https://stackoverflow.com/questions/27243294/unable-to-pull-google-appengine-go-docker-image
Open questions: