Deploying Jira on Google Cloud

This tutorial shows how to deploy Atlassian Jira Server Edition on Google Cloud, using Compute Engine and using Cloud SQL as the MySQL database.

Objectives

  • Create a Linux CentOS 7 virtual machine to install Jira version 7.12.
  • Create a Cloud SQL for MySQL version 5.6 instance for Jira to connect to.
  • Configure Jira to run as a service.
  • Enable access to the Jira service using HTTPS.

Costs

This tutorial uses billable components of Google Cloud, including:

  • Compute Engine
  • Cloud SQL
  • Cloud Load Balancing
  • Networking

Use the Pricing Calculator to generate a cost estimate based on your projected usage.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Cloud Console, on the project selector page, select or create a Cloud project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.

  4. Enable the Compute Engine and Cloud SQL Admin APIs.

    Enable the APIs

In addition, make sure you meet these requirements:

  • Make sure you have a trial or full license key for Jira Server Edition.
  • Make sure you have a domain name registered for your Jira site.

When you finish this tutorial, you can avoid continued billing by deleting the resources you created. See Cleaning up for more detail.

Deployment architecture

The following diagram shows the deployment architecture you use to install Jira. The primary Jira application server runs on a Compute Engine instance. That instance is securely connected to an instance of Cloud SQL for MySQL using the Cloud SQL Proxy tool running on the same virtual machine as Jira.

Architecture of JIRA deployment on GCP

Setting up your environment

In this section, you configure the infrastructure and identities that are required in order to complete the tutorial.

Start a Cloud Shell instance

You run all the terminal commands in this tutorial from Cloud Shell.

Configure a service account

The next step is to create a service account to delegate permissions to Jira so that Jira can access data in Cloud SQL.

  1. In Cloud Shell, create the service account:

    gcloud iam service-accounts create jira-service-account \
        --display-name jira-service-account
    
  2. Store the service account email address, current project ID, and default zone in environment variables for use in later commands. For [ZONE], choose the zone that's geographically closest to you.

    export SA_EMAIL=$(gcloud iam service-accounts list \
        --filter="displayName:jira-service-account" \
        --format='value(email)')
    export PROJECT=$(gcloud info \
        --format='value(config.project)')
    export ZONE=[ZONE]
    

    To see a list of zones, run the following command:

    gcloud compute zones list
    
  3. Bind the roles/cloudsql.client role to your service account:

    gcloud projects add-iam-policy-binding $PROJECT \
        --role roles/cloudsql.client \
        --member serviceAccount:$SA_EMAIL
    

Creating an instance of Cloud SQL for MySQL

For this tutorial, you set up Jira to use a MySQL database. Rather than installing MySQL yourself, you use Cloud SQL, which provides a managed version of MySQL.

  1. In Cloud Shell, create an instance of Cloud SQL with MySQL as the database. The following command uses the name mysql-jira-instance as the name of the instance. You can use a different name; if you do, make a note of it, because you need this name in later steps.

    gcloud sql instances create mysql-jira-instance \
        --database-version MYSQL_5_6 --zone $ZONE
    

    The properties of the new instance are displayed:

    NAME                 DATABASE_VERSION  LOCATION    TIER              STATUS
    mysql-jira-instance  MYSQL_5_6         us-east1-d  db-n1-standard-1  RUNNABLE
    
  2. Set the password for the root@% MySQL user. If you didn't use the name mysql-jira-instance for the Cloud SQL instance, be sure that you use the name you used earlier. For [PASSWORD], substitute a strong password.

    gcloud sql users set-password root \
        --host=% --instance=mysql-jira-instance --password=[PASSWORD]
    

Creating the Compute Engine instance and instance group

You create a Compute Engine instance to deploy Jira and then add the new instance to an instance group. This allows you to use an HTTPS load balancer in a later step.

Create the Compute Engine instance

At the time of writing, Atlassian supports installation of Jira 7.12 only on Linux CentOS. For this tutorial, you use the default machine type of n1-standard-1.

  • In Cloud Shell, create a Compute Engine instance on which you can install Jira Software. For this tutorial, you name the instance jira-instance.

    gcloud config set compute/zone $ZONE
    
    gcloud compute instances create jira-instance \
        --image-family centos-7 \
        --image-project centos-cloud \
        --tags=jira-server \
        --service-account $SA_EMAIL \
        --scopes cloud-platform
    

    The properties of the new instance are displayed:

    NAME           ZONE        MACHINE_TYPE   PREEMPTIBLE    STATUS
    jira-instance  us-east1-d  n1-standard-1                 RUNNING
    

For more information about operating systems and machine types by Jira, see the following Atlassian pages:

Create an instance group and add the Compute Engine instance

You can now create an instance group and add the jira-instance virtual machine.

  1. In Cloud Shell, create an instance group:

    gcloud compute instance-groups unmanaged create jira-resources \
        --zone $ZONE
    
  2. Add the Compute Engine instance to the instance group:

    gcloud compute instance-groups unmanaged add-instances jira-resources \
        --instances jira-instance \
        --zone $ZONE
    

Installing Jira Software

In this section, you configure the Compute Engine instance and complete the Jira installation.

Connect to the Compute Engine instance

In order to configure the instance settings, you establish an SSH connection to your instance.

  • In Cloud Shell, connect to your instance:

    gcloud compute ssh jira-instance
    

    Compute Engine generates an SSH key and adds the generated key to the project or instance metadata.

Install required packages

In the Compute Engine instance, you need to install tools that let you work with Jira and with MySQL in later steps.

  1. At the command line of your instance, install wget:

    sudo yum -y install wget
    
  2. Install the MySQL client on the instance:

    sudo yum -y install mysql
    

Download the software installer and install Jira Software

  1. At the command line of your instance, download the Jira Software installer from Atlassian:

    wget https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-7.12.3-x64.bin
    
  2. Make the installer file executable:

    chmod a+x atlassian-jira-software-7.12.3-x64.bin
    
  3. Run the installer. You must perform this step using sudo, which gives you the option to install Jira as a service during the installation process.

    sudo ./atlassian-jira-software-7.12.3-x64.bin
    
  4. Enter the following values during the installation process:

    • Installation option: choose Custom Install (option 2)
    • Installation directory: /opt/atlassian/jira
    • Software data directory: /var/atlassian/application-data/jira
    • TCP ports: HTTP: 8080, Control: 8005
    • Install as service: y
    • Start Jira: no. You don't want to start Jira yet, because there are steps remaining.
  5. Clean up by removing the installer file:

    rm atlassian-jira-software-7.12.3-x64.bin
    

Configuring a connection for Jira to Cloud SQL for MySQL

This section describes how to use the MySQL client to connect to Cloud SQL for MySQL, the database used by Jira.

Download MySQL Connector/J

Jira connects to a database using a JDBC database connection. The MySQL Connector is the official JDBC driver for MySQL. This tutorial uses version 5.1.46 of the MySQL Connector.

  1. At the command line of your Jira instance, download the connector:

    wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
    
  2. Uncompress the tar file:

    tar -xzf mysql-connector-java-5.1.46.tar.gz
    
  3. Copy the file to /opt/atlassian/jira/lib:

    sudo cp ./mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar /opt/atlassian/jira/lib/.
    
  4. Clean up by removing the tar file:

    rm -rf mysql-connector-java-5.1.46d \
    mysql-connector-java-5.1.46.tar.gz
    

Install Cloud SQL Proxy on the Compute Engine instance

Cloud SQL Proxy helps provides secure access to Cloud SQL for the MySQL instance.

  1. At the command line of your instance, download the proxy:

    wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
    
  2. Make the proxy executable:

    chmod +x cloud_sql_proxy
    
  3. Copy the proxy binary to a local directory:

    sudo cp cloud_sql_proxy /usr/local/bin/.
    

Running Jira as a service

Running Jira as a service allows Jira to start automatically whenever the computer restarts.

  1. At the command line of your instance, create a new file called cloud_sql_proxy.service. For example, use the following vi command to create the cloud_sql_proxy.service file:

    sudo vi /usr/lib/systemd/system/cloud_sql_proxy.service
    
  2. Add the following configuration to the file. Replace [PROJECT_ID] with your Google Cloud project ID, and replace [REGION] with the region you are using (for example, us-east1). If you didn't use the name mysql-jira-instance for the Cloud SQL instance, substitute your name.

    [Unit]
    Description=Google Cloud SQL Proxy
    After=network.service
    
    [Service]
    User=root
    Type=forking
    WorkingDirectory=/usr/local/bin
    ExecStart=/bin/sh -c '/usr/bin/nohup /usr/local/bin/cloud_sql_proxy -instances=[PROJECT_ID]:[REGION]:mysql-jira-instance=tcp:3306 &'
    RemainAfterExit=yes
    StandardOutput=journal
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    
  3. Save and close the file.

  4. Create a new file called jira.service:

    sudo vi /usr/lib/systemd/system/jira.service
    
  5. Add the following configuration to the file.

    [Unit]
    Description=JIRA Service
    Requires=cloud_sql_proxy.service
    After=network.target iptables.service firewalld.service httpd.service
    
    [Service]
    Type=forking
    User=root
    ExecStart=/opt/atlassian/jira/bin/start-jira.sh
    ExecStop=/opt/atlassian/jira/bin/stop-jira.sh
    ExecReload=/opt/atlassian/jira/bin/stop-jira.sh | sleep 60 | /opt/atlassian/jira/bin/stop-jira.sh
    
    [Install]
    WantedBy=multi-user.target
    
  6. Save and close the file.

  7. Enable the Jira and Cloud SQL Proxy services:

    sudo systemctl daemon-reload
    sudo systemctl enable jira
    sudo systemctl enable cloud_sql_proxy
    
  8. Start the services:

    sudo systemctl start jira
    

    You need to start only the Jira service. The proxy service is dependent on the Jira service, and it automatically starts after the Jira service has started.

  9. Check the status of the services:

    sudo systemctl status jira
    sudo systemctl status cloud_sql_proxy
    

    If the status is green and says active (running), the service is active and running. If the status is inactive, try reloading the services again in a few minutes using sudo systemctl daemon-reload.

Starting the MySQL session

This section shows how to create a MySQL user and password and how to create a MySQL database to connect Jira to during the setup process.

  1. At the command line of your instance, start a MySQL session:

    mysql -u root -p --host 127.0.0.1 -P 3306
    

    When the session is ready, you see the mysql prompt.

  2. Create the database. Substitute [DATABASE_NAME] for your database name. For information on naming, see MySQL's Database Creation Guide.

    CREATE Database [DATABASE_NAME] CHARACTER SET utf8 COLLATE utf8_bin;
    
  3. Create a non-root user and set the user's password. Replace [USERNAME] for your username and [PASSWORD] with your password.

    CREATE USER '[USERNAME]'@'%' IDENTIFIED BY '[PASSWORD]';
    
  4. Grant the user all privileges:

    GRANT ALL PRIVILEGES ON [DATABASE_NAME] . * TO '[USERNAME]'@'%';
    FLUSH PRIVILEGES;
    
  5. Close the MySQL session:

    EXIT;
    
  6. Close the SSH connection to the instance:

    exit
    

Creating and configuring the HTTPS load balancer

The next step is to create an HTTPS load balancer in order to secure traffic to the Jira instance. At the time of writing, running Jira over HTTPS is outside of the scope of Atlassian support. Therefore, you use an HTTPS load balancer with the Jira instance. For more information on configuring HTTPS, see Running Jira applications over SSL or HTTPS on the Atlassian site.

Create a global static IP address

Global static external IP addresses are the external IP addresses that your customers use to reach the load balancer.

  • In Cloud Shell, create a global static external IP address for your load balancer:

    gcloud compute addresses create lb-ip --global
    

Configure the load balancing service

The next step is to configure the load balancer.

  1. In Cloud Shell, create a named port:

    gcloud compute instance-groups unmanaged set-named-ports jira-resources \
        --named-ports http:8080 \
        --zone $ZONE
    

    When the port is configured, the load balancing service forwards traffic to the named port.

  2. Create a health check:

    gcloud compute health-checks create tcp jira-health --port 8080
    
  3. Create a backend service using the jira-health health check that you created earlier:

    gcloud compute backend-services create jira-app \
        --protocol http \
        --health-checks jira-health \
        --global
    
  4. Add your instance group as a backend to the backend service:

    gcloud compute backend-services add-backend jira-app \
        --instance-group jira-resources \
        --instance-group-zone $ZONE \
        --global
    
  5. Create a default URL map that directs all incoming requests to your instances:

    gcloud compute url-maps create jira-app \
        --default-service jira-app
    

Create a firewall rule

To allow traffic for working with the Jira service, you configure the firewall.

  • Create a firewall rule to allow traffic from the load balancer to the jira-instance instance:

    gcloud compute firewall-rules create jira-lb-allow \
        --action=ALLOW \
        --rules=tcp:8080 \
        --source-ranges=130.211.0.0/22,35.191.0.0/16 \
        --target-tags=jira-server
    

Create a Google-managed SSL certificate resource

To support HTTPS traffic, you need an SSL certificate. In this section, you add a Google-managed SSL certificate. (This feature is currently in beta.) If you want to use a different SSL certificate, see create SSL certificate resource.

Google-managed SSL certificates are automatically renewed in advance of their expiration date. For more information on the renewal process, see Google-managed SSL certificate resource status.

  1. In Cloud Shell, create a Google-managed SSL certificate resource. Replace [DOMAIN] with your domain:

    gcloud beta compute ssl-certificates create jira-cert \
        --domains [DOMAIN]
    

Configure HTTPS routing

You can now configure routing to send Jira traffic to the proxy.

  1. Create a target HTTPS proxy to route requests to your URL map:

    gcloud compute target-https-proxies create https-lb-proxy \
        --url-map jira-app --ssl-certificates jira-cert
    
  2. Create a global forwarding rule to route incoming requests to the proxy. Replace [LB_IP_ADDRESS] with the static external address you created.

    gcloud compute forwarding-rules create https-fwd-rule \
        --address [LB_IP_ADDRESS] \
        --global \
        --target-https-proxy https-lb-proxy \
        --ports 443
    

    To see the external IP address, use the following command:

    gcloud compute addresses list
    

Add or update DNS record

The next step is to add or update the DNS record for your domain so that traffic is directed from your domain to the load balancer.

  1. At your registrar's site, add or update the DNS record for your domain so that it points to the static external IP address you created.

    To see the external IP address, use the following command:

    gcloud compute addresses list
    

Confirm the SSL certificate resource is active

The certificate resource provisioning takes several minutes. Wait for the SSL resource to have the ACTIVE status.

  1. Check the status of the process:

    gcloud beta compute ssl-certificates list
    

Connecting to Jira in the browser

Now that you have installed Jira, configured it to run as a service, and created a database for it, you can begin the setup process in a web browser window.

  1. On your local computer, open a window in your web browser.
  2. In the address bar, enter: https://[DOMAIN]. Replace [DOMAIN] with your domain.
  3. In the Jira setup window, click I'll set it up myself and then click Next.

    The database connection window appears.

  4. Click my own database, which is recommended for production environments, and fill out the following:

    • Database type: MySQL
    • Hostname: 127.0.0.1
    • Port: 3306
    • Database: the MySQL database you created
    • User: the MySQL user you created
    • Password: the password for the MySQL user
  5. Click the Test Connection button to test your database connection with Jira.

    The following image shows a successful connection.

    screenshot of the database connection page that shows example input values for the connection and a green message at the top of the page saying "The database connection test was successful."

  6. Enter your license key for Jira.

  7. During the setup process, configure your email notifications and admin access.

You now can use Jira Software on your database connection using Cloud SQL for MySQL.

Cleaning up

To avoid incurring charges to your Google Cloud Platform account for the resources used in this tutorial:

Delete the project

  1. In the Cloud Console, go to the Manage resources page.

    Go to the Manage resources page

  2. In the project list, select the project that you want to delete and then click Delete .
  3. In the dialog, type the project ID and then click Shut down to delete the project.

What's next