Skip to main content

GCP

In this walk-through, you’re going to automate the deployment of an example application to Kubernetes (GKE) runtime on GCP using Argonaut. It's aimed at first-time users of Argonaut.

The pre-requisites for this deployment are:

  • A GitHub account
  • A GCP account linked to a GCP Organization

1. Create an account

If it’s your first time using Argonaut, you must sign up for an account. You will then receive an email with an account activation link. Alternatively, if you already have one, log into your account.

2. Create your workspace

Each Argonaut account needs to be associated with one Argonaut workspace.

  1. Type in a name for your Workspace. This CAN be changed later.
  2. Click Next

Create your organization

3. Connect your GCP account

To connect your GCP account with Argonaut:

Connect to your GCP account

  1. Log into your GCP account, if not already logged in.
  2. Go to Google Cloud Console.
  3. Create an Organization resource.
  4. Create a project within your organization resource.
  5. Attach your project to a billing account.
  6. Get and copy your organization resource ID.
  7. Navigate to Argonaut dashboard.
  8. Click on the Settings icon on the sidebar and click Connections.
  9. Under Cloud Connect, click on Account +.
  10. Select Google Cloud Platform from the dropdown.
  11. Paste your GCP organization resource ID, and click Connect.
  12. Copy the shown code snippet.
  13. Run that code snippet on the provided Cloud Console URL.
  14. Go back to your Argonaut Cloud Connect page and refresh the status of your organization resource.
  15. Verify that the status of the organization now shows Connected.

4. Connect your GitHub account

On the same screen, you will see a Version control option. Here, you can connect Argonaut to your GitHub or GitLab repository. For this demo, we use GitHub.

  1. In the Version Control section, click on Account +
  2. Choose GitHub, and click on the Connect button.
  3. Click on the GitHub account you’d like to connect with Argonaut. You’ll host your sample application on this account.
  4. Click on Install to install ArgonautBot on your chosen GitHub account.
  5. Enter your password, and click on Confirm Password.
  6. On successfully connecting your GitHub account, you’ll be redirected to the Version Control page that shows your GitHub account.

5. Create a GCP environment

  1. Click on Environments in the sidebar.
  2. Click on Environments +.
  3. Choose Google Cloud Platform.
  4. Choose your GCP Org from the dropdown.
  5. Choose your GCP Project from the dropdown.
  6. Name your GCP environment and select the region. The region CAN'T be changed later.
  7. Click on Create Environment.

Create a GCP environment

note

The chosen GCP project must be attached to a GCP billing account and be a part of a GCP organization.

To check if the environment creation was successful, navigate to the Environments page from the sidebar, and look for your environment's name in the list.

6. Create a GKE cluster

To deploy your application on K8s, you need to first create a K8s cluster:

  1. Navigate to Environments, select your new GCP environment.
  2. Click on the Infra tab.
  3. Click on Resource +.
  4. Input the following values:
    1. Cluster Name as gcpquickstart.
    2. Initial Node Count as 3.
  5. Click Node Pool +.
    1. Set Nodes: Min as 3 and Max as 5.
    2. Machine Type: e2.medium.
    3. Autoscaling toggled on.
    4. Disk Type: pd-balanced.
    5. Set Disk Capacity as 10.
  6. Click on Create.

Your cluster is now created.

Create GKE cluster

7. Set up automatic deployment

  1. Fork the battleships repository into your GitHub account - the same account that you’ve connected to in Argonaut. The rest of the steps assume that the name of the forked repository is also battleships.
  2. On your Argonaut dashboard, click on Applications from the sidebar.
  3. Click the button Applications + on the top right.
  4. Name the application as Battleship and click on Create.
  5. Click on the Pipeline + button next to the Battleship application.
  6. This opens the pipeline builder view with Build and Deploy stages.
  7. Enter a pipeline name as Test Pipeline.
  8. Select your Git account, battleships repository, and main branch. Battleships index page
  9. Select the Build stage. Enter build details.
    1. Set Build Config name as firstbuild
    2. In Path, fill ./Dockerfile.
  10. Select the Deploy stage. Enter deployment details.
    1. Set Service Type as Stateless.
    2. Ensure the correct environment and kubernetes cluster is chosen.
    3. Under Network Services, click Add Service.
      1. Fill your Hostname.
      2. Fill the port you want the application to run on in Container Port.
    4. Ensure that Resource Requests & Limits have values set by default.
    5. Click Commit to Repo.
  11. Once this is done, your app builds and deploy configurations are saved and ready to be deployed.
  12. Go to the Applications from the sidebar and select your app. Now click on Trigger Pipeline.
  13. You will see the status of deployment under Run History. You can also view the history of the Build and the Run stages independently below.
  14. Now, go to the Applications page and look for your application Battleship.
  15. Scroll right, and click the PREVIEW URL against Battleship. This is the URL where your Battleship application is being hosted.
  16. Mavigate to the URL you provided as Hostname. You should see the following screen:

Battleships index page

You’ve successfully deployed your example application using Argonaut! Let’s test whether your application now automatically gets deployed when you push a code change.

8. Test automatic deployment

You’re now ready to test if your app gets deployed automatically whenever any code change is pushed to it. Let’s make a code change, and view the app again.

  1. Git clone your forked battleships repository on your local machine.
  2. Make a code change, and push to remote.
  3. Check your application’s deployments on Argonaut dashboard: ApplicationsBattleshipRun History from the top bar.
  4. You’ll see an ongoing deployment against your commit ID.
  5. Once the deployment is complete, navigate to your service URL to test that your code change is live.

That’s it!

You just used Argonaut to successfully set up automatic deployment of an example application on every code push. You can now connect your own app with Argonaut to automate its deployment.