- Download Gcloud SDK from this link and install it according to the instructions for your OS.
- Initialize the SDK following these instructions.
- Run
gcloud init
from a terminal and follow the instructions. - Make sure that your project is selected with the command
gcloud config list
- Run
- From your project's dashboard, go to Cloud Compute > VM instance
- Create a new instance:
- Manual setup:
- Any name of your choosing
- Pick your favourite region. You can check out the regions in this link.
- Pick a E2 series instance. A e2-standard-4 instance is recommended (4 vCPUs, 16GB RAM)
- Change the boot disk to Ubuntu. The Ubuntu 20.04 LTS version is recommended. Also pick at least 30GB of storage.
- Leave all other settings on their default value and click on Create.
- Gcloud SDK setup:
gcloud compute instances create dezoomcamp --zone=europe-west1-b --image-family=ubuntu-2004-lts --image-project=ubuntu-os-cloud --machine-type=e2-standard-4 --boot-disk-size=30GB
- Manual setup:
- When you create an instance, it will be started automatically. You can skip to step 3 of the next section.
- Start your instance from the VM instances dashboard.
- In your local terminal, make sure that gcloud SDK is configured for your project. Use
gcloud config list
to list your current config's details.- If you have multiple google accounts but the current config does not match the account you want:
- Use
gcloud config configurations list
to see all of the available configs and their associated accounts. - Change to the config you want with
gcloud config configurations activate my-project
- Use
- If the config matches your account but points to a different project:
- Use
gcloud projects list
to list the projects available to your account (it can take a while to load). - use
gcloud config set project my-project
to change your current config to your project.
- Use
- If you have multiple google accounts but the current config does not match the account you want:
- Set up the SSH connection to your VM instances with
gcloud compute config-ssh
- Inside
~/ssh/
a newconfig
file should appear with the necessary info to connect. - If you did not have a SSH key, a pair of public and private SSH keys will be generated for you.
- The output of this command will give you the host name of your instance in this format:
instance.zone.project
; write it down.
- Inside
- You should now be able to open a terminal and SSH to your VM instance like this:
ssh instance.zone.project
- In VSCode, with the Remote SSH extension, if you run the command palette and look for Remote-SSH: Connect to Host (or alternatively you click on the Remote SSH icon on the bottom left corner and click on Connect to Host), your instance should now be listed. Select it to connect to it and work remotely.
- List your available instances.
gcloud compute instances list
- Start your instance.
gcloud compute instances start <instance_name>
- Set up ssh so that you don't have to manually change the IP in your config files.
gcloud compute config-ssh
- Run this first in your SSH session:
sudo apt update && sudo apt -y upgrade
- It's a good idea to run this command often, once per day or every few days, to keep your VM up to date.
- In your local browser, go to the Anaconda download page, scroll to the bottom, right click on the 64 bit x86 installer link under Linux and copy the URL.
- At the time of writing this gist, the URL is https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
- In your SSH session, type
wget <anaconda_url>
to download the installer. - Find the filename of the installer with
ls
- Run the installer with
bash <filename>
(you can start typing the name and then press the Tab key to autocomplete) - Follow the on-screen instructions. Anwer
yes
to all yes/no questions and leave all other default values. - Log out of your current SSH session with
exit
and log back in. You should now see a(base)
at the beginning of your command prompt. - You may now remove the Anaconda installer with
rm <filename>
- Run
sudo apt install docker.io
to install it. - Change your settings so that you can run Docker without
sudo
:- Run
sudo groupadd docker
- Run
sudo gpasswd -a $USER docker
- Log out of your SSH session and log back in.
- Run
sudo service docker restart
- Test that Docker can run successfully with
docker run hello-world
- Run
- Go to https://github.com/docker/compose/releases and copy the URL for the
docker-compose-linux-x86_64
binary for its latest version.- At the time of writing, the last available version is
v2.2.3
and the URL for it is https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64
- At the time of writing, the last available version is
- Create a folder for binary files for your Linux user:
- Create a subfolder
bin
in your home account withmkdir ~/bin
- Go to the folder with
cd ~/bin
- Create a subfolder
- Download the binary file with
wget <compose_url> -O docker-compose
- If you forget to add the
-O
option, you can rename the file withmv <long_filename> docker-compose
- Make sure that the
docker-compose
file is in the folder withls
- If you forget to add the
- Make the binary executable with
chmod +x docker-compose
- Check the file with
ls
again; it should now be colored green. You should now be able to run it with./docker-compose version
- Check the file with
- Go back to the home folder with
cd ~
- Run
nano .bashrc
to modify your path environment variable:- Scroll to the end of the file
- Add this line at the end:
export PATH="${HOME}/bin:${PATH}"
- Press
CTRL
+o
in your keyboard and press Enter afterwards to save the file. - Press
CTRL
+x
in your keyboard to exit the Nano editor.
- Reload the path environment variable with
source .bashrc
- You should now be able to run Docker compose from anywhere; test it with
docker-compose version
- Run
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
- Run
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
- Run
sudo apt-get update && sudo apt-get install terraform
-
Download a file.
# From your local machine scp <instance_name>:path/to/remote/file path/to/local/file
-
Upload a file.
# From your local machine scp path/to/local/file <instance_name>:path/to/remote/file
-
You can also drag & drop stuff in VSCode with the remote extension.
-
If you use a client like Cyberduck, you can connect with SFTP to your instance using the
instance.zone.project
name as server, and adding the generated private ssh key.
Thank you so much! 😃