Categories
Tesla Mate

How to setup and run TeslaMate for free on Google Cloud

If you are also facing a few issues on setup and running TeslaMate on Google Cloud (on my Raspberry Pi (mainly very stable on ethernet only, but still bombed out for no reason on occasion)), I decided to look into getting TeslaMate running in Google Cloud.

Thankfully, being a light touch application you can run TeslaMate on the free tier of GCP.

You will however need your own domain name to be able to do this following the guide from TeslaMate. You can follow all the steps one by one to setup your own domain.

Creating a Micro instance in GCP

There are few steps to build micro instance on Google Cloud. The first thing we need to do, is build our micro instance on Google Cloud. I followed this guide: How to set up a free micro VPS on Google Cloud Platform

The only difference to make this work, is to make sure you select http and https and also change the Linux version to Debian 9 (Debian 10 would not work with the auto generated SSL Cert for me).

Setting a static IP for your GCP instance

Setup TeslaMate on Google Cloud Raspberry Pi

If you have successfully setup the GCP and its live, you’ll now want to set a static IP address, this should be done to ensure that if you reboot/upscale/rebuild your box you’ll have the same IP address that you are going to point your subdomains to.

Click the ‘hamburger’ (three stacked lines) menu top left, this will pop a left hand menu out. Scroll down the menu items on the left hand side until you get to the Networking section, and then hover over VPC Networks, from the menu that pops out on the right hand side, select External IP addresses.

You will now see the VM you have created, in the details of the server, you will see text that says Ephemeral with a down arrow icon. Click the down arrow and instead choose Static. A pop out window will appear asking for a Name, enter the name you wish to give this (I imaginatively choose teslamate), then click Reserve.

This will now fix the currently assigned IP address to your VM.

Create two subdomains to setup TeslaMate on Google Cloud

As per the TeslaMate Guide you have to setup the two different subdomains. TeslaMate instructions recommend creating grafana and teslamate, this is completely up to you, you’ll just need to make changes in the .env file later on to make sure this works for you.

For those subdomains, you need to change the DNS setup so that those subdomains have A records that point to your public facing IP address for your GCP micro VM instance.

Wait for the DNS changes to propagate

Before proceeding, I’d advise waiting until your DNS changes have been reflected. Ping your new subdomain URLs (teslamate.MYDOMAN.COM) when you get a positive result that matches the public IP of your Micro VM you are good to proceed. This won’t be instant and will depend on the DNS management service you are using.

Docker install

Open SSH (SSH via the browser from the Google Cloud console is fine).

Run the following commands one after the other:

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg2
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce
sudo usermod -aG docker $USER

Docker Compose install

Within the same SSH session, we can now install Docker Compose

Run the following commands one after the other:

sudo curl -L https://github.com/docker/compose/releases/download/1.26.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Creating a swap file

Due to the micro instance having a small amount of memory, we will create a 1gb swap file to help deal with the load.

Run the following 2 commands one after the other:

sudo fallocate -l 1G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile
echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab && sudo reboot

Once the box has restarted, continue to the next step.

Installing TeslaMate on Google Cloud

You can now follow this guide to Setup TeslaMate on Google Cloud Raspberry Pi: Advanced Traefik TeslaMate install

For those unfamiliar with how to create the files in the above guide, I use the nano editor. For example, to create the docker-compose.yml file, type the following into your SSH session: nano docker-compose.yml this will load up the nano editor, allowing you to use your familiar PC/Mac copy/paste commands to get the content in.

Once you’ve finished editing the file(s), Ctrl+X to exit, choosing Y to save the file

I’d advise when first starting up TeslaMate, you run the following just so you can check for any errors: sudo docker-compose up

With the above, you’ll see it getting everything installed, hopefully with no errors. Check your new URLs, if you’re a new user login to the teslamate URL, if you’re an existing user moving over to cloud from local you should do a restore of a previous backup before signing in.

Once you’re happy everything works, in the SSH window, you can quit the docker-compose session with Ctrl+C, then restart it with sudo docker-compose up -d

What next?

Now TeslaMate is running, you might want to setup some backups, import Supercharger and destination charger locations (so they show up when you charge)

Get 1000 Miles / 1500 KM of FREE supercharge when you order your new Tesla if you use this order link.

Leave a Reply

Your email address will not be published. Required fields are marked *