2022-10-19 13:52:56 -05:00
|
|
|
|
# Google Cloud Platform
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
In this guide, you will learn how to deploy the Coder control plane instance and
|
|
|
|
|
|
your first template.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
This guide assumes you have `roles/compute.instanceAdmin.v1` access to your
|
|
|
|
|
|
Google Cloud Platform project.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2022-12-05 12:21:09 +01:00
|
|
|
|
## Setting Up your VM
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
If this is the first time you’re creating a VM on this project, you will need to
|
|
|
|
|
|
enable the `Compute Engine API`. On the Compute Engine API page, click `enable`
|
|
|
|
|
|
and wait for the service to finish connecting.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp0.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
This will pull up the `Create an Instance` page - name the instance something
|
|
|
|
|
|
relevant to this project, following your naming convention of choice. In
|
|
|
|
|
|
addition, select a region and zone that is close to your physical location. For
|
|
|
|
|
|
this instance, we will use the base suggested image.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp1.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
Under `Identity and API Access`, click `Allow full access to all Cloud APIs`.
|
|
|
|
|
|
Scroll down to `Firewall` and click `Allow HTTPS traffic` and
|
|
|
|
|
|
`Allow HTTP traffic`.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp2.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
Scroll down to the bottom and click `Create` to create and deploy the VM.
|
|
|
|
|
|
|
|
|
|
|
|
Congrats you’ve created your VM instance!
|
|
|
|
|
|
|
|
|
|
|
|
## SSH-ing into the VM
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
On the Compute Engine Dashboard, click on the VM for this project. Under
|
|
|
|
|
|
`Details`, click `SSH` and select `Open in browser window`.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp3.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
This will give you a terminal into the VM that we will use to install Coder.
|
|
|
|
|
|
|
|
|
|
|
|
## Install Coder
|
|
|
|
|
|
|
2022-12-05 12:21:09 +01:00
|
|
|
|
In the terminal, run the following command
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-02-01 17:05:45 -03:00
|
|
|
|
```console
|
2022-12-05 12:21:09 +01:00
|
|
|
|
curl -fsSL https://coder.com/install.sh | sh
|
2022-10-19 13:52:56 -05:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Run Coder
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
For this tutorial, we will run Coder as a `systemd` service. You can run Coder
|
|
|
|
|
|
in
|
|
|
|
|
|
[a multitude of different ways](https://coder.com/docs/coder-oss/latest/install).
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
First, edit the `coder.env` file to enable `CODER_TUNNEL` by setting the value
|
|
|
|
|
|
to true with the following command:
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-02-01 17:05:45 -03:00
|
|
|
|
```console
|
2022-10-19 13:52:56 -05:00
|
|
|
|
sudo vim /etc/coder.d/coder.env
|
2022-12-05 12:21:09 +01:00
|
|
|
|
```
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp4.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
Exit vim and run the following command to start Coder as a system service:
|
|
|
|
|
|
|
2023-02-01 17:05:45 -03:00
|
|
|
|
```console
|
2022-10-19 13:52:56 -05:00
|
|
|
|
sudo systemctl enable --now coder
|
2022-12-05 12:21:09 +01:00
|
|
|
|
```
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
The following command shows the Coder service's logs, including the Access URL.
|
|
|
|
|
|
The Access URL will be used to access the Coder control plane.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-02-01 17:05:45 -03:00
|
|
|
|
```console
|
2022-12-05 12:21:09 +01:00
|
|
|
|
journalctl -u coder.service -b
|
|
|
|
|
|
```
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp5.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
In this instance, Coder can be accessed at the URL
|
|
|
|
|
|
`https://fcca2f3bfc9d2e3bf1b9feb50e723448.pit-1.try.coder.app`.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
Copy the URL and run the following command to create the workspace admin:
|
|
|
|
|
|
|
2023-02-01 17:05:45 -03:00
|
|
|
|
```console
|
2022-10-19 13:52:56 -05:00
|
|
|
|
coder login <url***.try.coder.app>
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
Fill out the prompts and be sure to save use email and password. This is your
|
|
|
|
|
|
admin login. Now, you can now access Coder from your local machine by navigating
|
|
|
|
|
|
to the `***.try.coder.app` URL and logging in with that same username and
|
|
|
|
|
|
password.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
## Creating and Uploading your First Template
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
First, run `coder template init` to create your first template. You’ll be given
|
|
|
|
|
|
a list of prefabricated templates. This tutorial shows you how to create a Linux
|
|
|
|
|
|
based template on GCP.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp6.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2022-12-05 12:21:09 +01:00
|
|
|
|
Select the `Develop in Linux on Google Cloud`, then `cd ./gcp-linux`.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2022-12-05 12:21:09 +01:00
|
|
|
|
Run the following command:
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-02-01 17:05:45 -03:00
|
|
|
|
```console
|
2022-10-19 13:52:56 -05:00
|
|
|
|
coder templates create
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
It will ask for your `project-id`, which you can find on the home page of your
|
|
|
|
|
|
GCP Dashboard.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
Given it’s your first time setting up Coder, it may give an error that will look
|
|
|
|
|
|
like the following:
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp7.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
In the error message will be a link. In this case, the URL is
|
|
|
|
|
|
`https://console.developes.google.com/apis/api/iam.googles.com/overview:?project=1073148106645`.
|
|
|
|
|
|
Copy the respective URL from your error message, and visit it via your browser.
|
|
|
|
|
|
It may ask you to enable `Identity and Access Management (IAM) API`.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2022-12-05 12:21:09 +01:00
|
|
|
|
Click `enable` and wait as the API initializes for your account.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
Once initialized, click create credentials in the upper right-hand corner.
|
|
|
|
|
|
Select the `Compute Engine API` from the dropdown, and select `Application Data`
|
|
|
|
|
|
under `What data will you be accessing?`. In addition, select
|
|
|
|
|
|
`Yes, I’m using one or more` under
|
|
|
|
|
|
`Are you planning on using this API with Compute Engine, Kubernetes Engine, App Engine, or Cloud Functions?`.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-04-03 09:51:07 -05:00
|
|
|
|
<img src="../images/platforms/google-cloud-platform/gcp8.png">
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2022-12-05 12:21:09 +01:00
|
|
|
|
Back in your GCP terminal, run the `coder templates create` one more time.
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
2023-08-23 12:27:57 +03:00
|
|
|
|
Congrats! You can now create new Linux-based workspaces that use Google Cloud
|
|
|
|
|
|
Platform. Go onto your Coder dashboard, build your workspace, and get started
|
|
|
|
|
|
coding!
|
2022-10-19 13:52:56 -05:00
|
|
|
|
|
|
|
|
|
|
## Next Steps
|
|
|
|
|
|
|
2023-06-02 16:56:06 -04:00
|
|
|
|
- [Learn more about template configuration](../templates/index.md)
|
2022-10-19 13:52:56 -05:00
|
|
|
|
- [Configure more IDEs](../ides/web-ides.md)
|