Only show these results:

Installing Nylas on Google Cloud Platform

On-Prem is only available to Enterprise customers. Before deploying, please reach out to our sales team.

Prerequisites

Configure the Google Cloud CLI

If you’ve already installed gcloud CLI, run gcloud auth login to get logged in. This will allow Terraform to access these credentials to provision resources on Google Cloud.

  1. Follow the steps to install the gcloud CLI. If you’re having trouble installing the gcloud CLI, add it to your path with ./google-cloud-sdk/install.sh
  2. Initialize the CLI with gcloud init.
  3. Log in with your Google Console Credentials.

You should see the success page after logging in.

  1. In the gcloud CLI select the project you want to use.
  2. Check if your region has been set. gcloud config get-value compute/region.
  3. If needed, set your region with gcloud configure set.
  4. Run gcloud auth application-default login.
  5. Login with your Google credentials.

New Google Cloud Projects

If you have a new Google Cloud Platform project you may need to enable:

  • Kubernetes Engine API
  • Service Networking API

From the Google Cloud Platform, home page go to APIs & Services > Library. Use the search engine to look for each API

These may take several minutes to update.


Clone the cloud-core-kots Repository

Clone the Nylas Cloud Core KOTS on GitHub. The repository contains Terraform scripts that will provision a GKE cluster, Cloud SQL instance and all the necessary networking.

  1. Run git clone git@github.com:nylas/cloud-core-kots.git
  2. cd terraform/gcp directory in the repository.

Review Infrastructure Requirements

Isolated GKE Cluster

This sample repository also creates a VPC and subnet for the GKE cluster. This is not required but highly recommended to keep your GKE cluster isolated.

  1. Replace the values in [terraform.tfvars](https://github.com/nylas/cloud-core-kots/blob/main/terraform/gcp/terraform.tfvars)
    • project_id - Must match the project you initialized Google Cloud with.
    • region - The region has defaulted to us-central1. You can find a full list of Google Cloud regions at Region Zones.
  2. Cloud SQL
    1. Note: by default for Google Cloud SQL it is a db-f1-micro instance with only 10 GB. Since Cloud SQL will automatically scale, this will be good enough for POC and demo purposes.
    2. We recommend two instances for production sharded and unsharded databases.
      1. Unsharded database houses account information
      2. Sharded database houses all the rich information around calendars, contacts, and email for each account. Sharding allows us to scale horizontally.
    3. See our go-to production guide for more information on how to scale up and down your databases
  3. Google Kubernetes Engine
    1. Note: by default the terraform script will create a n1-standard-1 instance size for demo purposes.
  4. To change your settings run gcloud init.

Initialize Terraform Workspace

  1. Run terraform init. This will download the provider and initialize it with the values provided in the terraform.tfvars file.
    $ terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/random...
- Finding latest version of hashicorp/google-beta...
- Finding latest version of hashicorp/google...
- Installing hashicorp/google-beta v3.51.0...

# Output truncated...

Terraform has been successfully initialized!

Provision Your GCP Cluster

The Terraform scripts will guide you through provisioning your GCP clusters.

  1. Run terraform apply. It will show you a preview of the plan that will get applied. If you want to make changes to your Terraform, .tf files, then type no and update your configuration.
  2. Once you are satisfied with the configuration, run terraform apply and make sure the plan shows 4 to add, 0 changes, and 0 to destroy to make sure you’re only adding provisions to your GCP console.

You should see 0 change, 0 to destroy!

DO NOT CONTINUE unless you see 0 change, 0 to destroy! Unless you intend to make real modifications on your AWS console!

    $ terraform apply

# Output truncated...

Plan: 4 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

# Output truncated...

Apply complete! Resources: 12 added, 0 changed, 0 destroyed.

Outputs:

kubernetes_cluster_name = nylas-cloud-core-terraform
region = us-east4

This will take approximately 10 minutes.

Configure kubectl

Make sure you have installed kubectl.

  1. Run gcloud container clusters get-credentials <name of your cluster> --region <region you made your cluster>. This will get the access credentials for your cluster and automatically configure kubectl.

Check the name and region

Review the name and region of the cluster match what is in your terraform.tfvars file.

The Kubernetes Cluster Name and Region correspond to the resources spun up by Terraform. You can view these outputs again by running: terraform output.

Install Nylas on Your Kubernetes Cluster

Now that we have our clusters setup, we can install Nylas Cloud Core.

  1. Install KOTS(Kubernetes Off-The-Shelf) and install the admin console.
    curl https://kots.io/install | bash
kubectl kots install nylas
  1. As part of setup, it will ask you to create a password. You’ll need this later to log in to your Nylas Dashboard.
  2. You may also be asked to set the namespace: cloud-core.
  3. Once running, you can access the admin console from https://localhost:8800

Admin Password

Make sure you create an admin password. You’ll need it in later steps.

macOS users, if you get a request for kubectly-kots connections, select allow.

On macs, you may need to allow this action

Log In To Your On-Prem Nylas Dashboard

  1. Open http://localhost:8800 in your browser. It will open the Nylas Admin Console.
  2. Enter the password you created during Install Nylas on Your Kubernetes Cluster.

  1. You’ll be asked to upload a license file. You can get this from your sales representative or reach out to sales@nylas.com.
  2. Once your license is finished uploading, you will be able to configure your database.
  3. Set your database to Embedded MySQL.

We highly recommend that you keep your HTTP connections via VPN only access (this means that the service is an internal load balancer)

HTTP (vpn only access)

  • will attach an internal load balancer annotation

HTTP (external access)

  • will expose the load balancer externally

URL of the Nylas API

  • We also recommend that you create a domain with an ingress so that you’ll be to run the OAuth flows more smoothly and incase your service names change in the future.
  • The Nylas API URL will be equivalent to api.nylas.com
  • If you do not plan on using ingresses and only port-forwarding, use localhost:
  • Important! You will need to add a callback URL to your application in your app settings so that your redirect URL is registered properly http://localhost:4444/applications/<application_id>/accounts otherwise you’ll get redirect errors if you auth via the Dashboard using Hosted Auth.

URL of the Nylas Dashboard

  • We also recommend that you create a domain with an ingress so that you’ll be to run the OAuth flows more smoothly and incase your service names change in the future.
  • The Nylas Dashboard URL will be equivalent to dashboard.nylas.com
    • The dashboard is a web application where you will be able to create applications and set OAuth keys
  • If you do not plan on using ingresses and only port-forwarding, use localhost:
  1. Next, we’ll run a Preflight check. The preflight checks make sure that all the version and resource requirements are met for Nylas to run. Yellow messages are okay. You should review them for the best experience. Red preflight checks should be correct right away.

Successful preflight checks

Unsuccessful preflight check will not allow you to update

  1. Click Continue. The build will take 5 to 10 minutes and the status will update once completed. If you want to check the status you can run kubctl get all -n cloud-core.
  2. You’ll be taken to the Dashboard where you manage your cluster.

Successful Deployment

:::sucess
Deployment Troubleshooting

If you are seeing issues, check your Kubernetes pods to see if there are any errors, pending or init stages. If it is taking a long time, there could be networking issues. If it is still showing init, scripts are still running.
:::

Create a Nylas Application

Now that you have installed Nylas on AWS you can start using the API.

You will be using port forwarding to access the API and Nylas Dashboard. Port forwarding will let you access your Nylas Dashboard on your local machine.

Prerequisites

If you are using Google or Microsoft accounts you’ll need to create an application before you can connect the accounts to Nylas.

If you haven’t already created a Google or Microsoft app, you can follow the steps outlined in Create a Google Application or Office 365 Set Up with Nylas.

Port Forward the API

  1. In a new terminal in your AWS folder run kubectl port-forward svc/nylas-api <local-port>:80 -n <namespace>.

Port Forward the Dashboard

  1. Run kubectl port-forward svc/nylas-dashboard <local-port>:80 -n <namespace>.

If you did not change the namespace, the default is nylas. In the example, we are forwarding to localhost port 4040.

This example we’re forwarding to the localhost port 4040

  1. Access the dashboard using your localhost port. In this example, the address is http://localhost:4040/sign-in.
  2. At the login screen, select Register. Since this is a local instance of Nylas, any accounts created at https://nylas.com will not be registered here. You will need to create a new account.
    While we’re port-forwarding, I’m able to access the Nylas Dashboard

Port Forwarding

You must forward the API and the Dashboard before you can register as a new user.

  1. Register a new user as if you’re a new Nylas customer.

  1. Click Create New App.

  2. If you haven’t already created a Google or Microsoft app, you can follow the steps outlined in Create a Google Application or Office 365 Set Up with Nylas.

  3. If you have already created an application, click App Settings and either update Google OAuth with your Google OAuth Client ID or update Office 365 OAuth with your Office365 OAuth Client ID.

  1. After setting your OAuth tokens, click Accounts, then Auth Account. Go through the provider flow to add an account to your Nylas application.

Make Your First API Request

  1. Using the localhost created in Port Forward the API, make an API request. In this example, we are returning account data.

For example: http://localhost:444/account

Congratulations!

You’ve set up Nylas locally, registered a new account, and make your first API request.

Cheat Sheet

To run the admin console

kubeclt kots admin-console -n nylas

Check deployment status

kubctl get all -n cloud-core

Troubleshooting

Troubleshooting Your GCP Cluster

Error: googleapi: Error 403: Service Networking API
Fix: Run gcloud auth application-default login

    Error: googleapi: Error 403: Service Networking API has not been used in project 113812076444 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/servicenetworking.googleapis.com/overview?project=113812076444 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured

Error: Attempted to load application default credentials
Fix: Run gcloud auth application-default login

    Error: Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block.  No credentials loaded. To use your gcloud credentials, run 'gcloud auth application-default login'.  Original error: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
    
    Error: Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block.  No credentials loaded. To use your gcloud credentials, run 'gcloud auth application-default login'.  Original error: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

Troubleshooting Install Nylas on Your Kubernetes Cluster

Error: forward ports: unable to listen on any of the requested ports: [{8800 3000}]
Fix: Make sure you do not have ports 8800 and 3000 free

Error: Do you want the application
Fix: Mac OS users will need to allow the connections.

What’s Next?