Skip to content

Instantly share code, notes, and snippets.

@starkSV
Forked from pratos/gcloud_docker_setup.md
Created June 26, 2018 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starkSV/021efa7b5710037309aca877d258c219 to your computer and use it in GitHub Desktop.
Save starkSV/021efa7b5710037309aca877d258c219 to your computer and use it in GitHub Desktop.
Installing gcloud on Ubuntu 16.04 LTS

Installing it using cURL

$ curl https://sdk.cloud.google.com | bash

When the first time you run the above statement, it might be that you'll get the following error if python2 is not installed in your system.

Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/home/pratos/google-cloud-sdk/lib/third_party/enum/__init__.py", line 364, in __getattr__
    return cls._member_map_[name]
KeyError: '_convert'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pratos/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
    import bootstrapping
  File "/home/pratos/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
    import setup
  File "/home/pratos/google-cloud-sdk/bin/bootstrapping/setup.py", line 27, in <module>
    from googlecloudsdk.core.util import platforms
  File "/home/pratos/google-cloud-sdk/lib/googlecloudsdk/core/util/platforms.py", line 18, in <module>
    import platform
  File "/home/pratos/miniconda3/lib/python3.5/platform.py", line 117, in <module>
    import sys, os, re, subprocess
  File "/home/pratos/miniconda3/lib/python3.5/subprocess.py", line 364, in <module>
    import signal
  File "/home/pratos/miniconda3/lib/python3.5/signal.py", line 8, in <module>
    _IntEnum._convert(
  File "/home/pratos/google-cloud-sdk/lib/third_party/enum/__init__.py", line 366, in __getattr__
    raise AttributeError(name)
AttributeError: _convert

No need to panic, just create a python2.7 environment

$ conda create --name gcloud python=2.7

It would install the python2 environment in the system @ /home/<username>/miniconda//envs/gcloud/bin/python2.7.

Add the path for CLOUDSDK_PYTHON

$ vim .bashrc

Edit the file to add

CLOUDSDK_PYTHON="/home/<username>/miniconda//envs/gcloud/bin/python2.7"
$ source .bashrc

Run the cURL command again

$ curl https://sdk.cloud.google.com | bash

<:::file copying - generic, followed by below prints:::>

Welcome to the Google Cloud SDK!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:

    gcloud config set disable_usage_reporting true

Do you want to help improve the Google Cloud SDK (Y/n)?  y


This will install all the core command line tools necessary for working with
the Google Cloud Platform.



Your current Cloud SDK version is: 148.0.0
Installing components from version: 148.0.0

┌────────────────────────────────────────────────────────────────────────────┐
│                    These components will be installed.                     │
├─────────────────────────────────────────────────────┬────────────┬─────────┤
│                         Name                        │  Version   │   Size  │
├─────────────────────────────────────────────────────┼────────────┼─────────┤
│ BigQuery Command Line Tool                          │     2.0.24 │ < 1 MiB │
│ BigQuery Command Line Tool (Platform Specific)      │     2.0.24 │ < 1 MiB │
│ Cloud SDK Core Libraries (Platform Specific)        │ 2016.11.07 │ < 1 MiB │
│ Cloud Storage Command Line Tool                     │       4.23 │ 2.8 MiB │
│ Cloud Storage Command Line Tool (Platform Specific) │       4.18 │ < 1 MiB │
│ Default set of gcloud commands                      │            │         │
│ gcloud-deps (Linux, x86_64)                         │ 2017.02.21 │ 3.9 MiB │
└─────────────────────────────────────────────────────┴────────────┴─────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: BigQuery Command Line Tool                   ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: BigQuery Command Line Tool (Platform Spec... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud SDK Core Libraries (Platform Specific) ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Storage Command Line Tool              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Storage Command Line Tool (Platform... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Default set of gcloud commands               ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud-deps (Linux, x86_64)                  ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation          ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done.                                                                                                              

Update done!


Modify profile to update your $PATH and enable shell command 
completion? (Y/n)?  y

The Google Cloud SDK installer will now prompt you to update an rc 
file to bring the Google Cloud CLIs into your environment.

Enter a path to an rc file to update, or leave blank to use 
[/home/pratos/.bashrc]:  
Backing up [/home/pratos/.bashrc] to [/home/pratos/.bashrc.backup].
[/home/pratos/.bashrc] has been updated.

==> Start a new shell for the changes to take effect.


For more information on how to get started, please visit:
  https://cloud.google.com/sdk/docs/quickstarts

To create docker machine using docker and gcloud

Follow the instructions here to add the default keys for your webapp: https://developers.google.com/identity/protocols/application-default-credentials

Accordingly use the below command to create a machine

docker-machine create --driver google --google-project <project-name> --google-machine-type <machine type: eg. n1-standard-4> <machine-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment