Deploy a Sample App Tutorial

In this tutorial, learn how to deploy a sample app to your Kubernetes cluster using Armory Continuous Deployment-as-a-Service. Use Helm to install the Remote Network Agent. Deploy the sample app to multiple targets.

Objectives

This tutorial is designed to use a single Kubernetes cluster with multiple namespaces to simulate multiple clusters. The sample code is in a GitHub repo that you can fork to your own GitHub account.

Before you begin

  • You have completed the Armory CD-as-a-Service quickstart, in which you create your login credentials, install the CLI, and deploy a sample app.
  • You have installed Helm.
  • You have a GitHub account so you can fork the sample project.

Fork and clone the repo

Fork the sample repo to your own GitHub account and then clone it to the machine where you installed kubectl and the armory CLI.

The configuration directory contains a script to set up Kubernetes cluster and connect it to Armory CD-as-a-Service.

Create Client Credentials

Create a new set of Client Credentials for the Remote Network Agents. Name the credentials “docs-sample-rna”.

  1. Access the CD-as-a-Service Console.
  2. Go to the Configuration tab.
  3. If you have more than one tenant, make sure you select the desired tenant in the User context menu.
  4. In the left navigation menu, select Access Management > Client Credentials.
  5. In the upper right corner, select New Credential.
  6. Create a credential for your RNA. Use a descriptive name for the credential that matches what it is being used for. For example, name the credentials the same as the account name you assigned the target deployment cluster if creating a credential for an Remote Network Agent (RNA).
  7. Select an RBAC role from the Select Roles list. You must assign an RBAC role in order for the credential to access CD-as-a-Service.
    • If the credential for is a Remote Network Agent, select Remote Network Agent.
    • If you plan to use the credential to deploy from a GitHub Action or similar tool, select Deployments Full Access.
  8. Note the values for both Client ID and Client Secret. You need these values when configuring the RNA or any other service that you want to grant access to. Make sure to store the secret somewhere safe. You are not shown the value again.

Connect your cluster

Configure the sample environments and install the Remote Network Agents in your Kubernetes cluster.

  1. Make sure you are connected to the Kubernetes cluster you want to install the sample app on.

  2. Log into your Armory CD-as-a-Service environment using the CLI:

    armory login --envName "<tenant-name>"
    

    --envName is optional. Replace <<tenant-name>> with the name of your Armory CD-as-a-Service tenant if you have access to multiple ones.

  3. Navigate to the docs-cdaas-sample/configuration directory and run the setup-helm.sh script using the “docs-sample-rna” Client Credentials you created for this tutorial.

    The script does the following:

    • Creates four namespaces, one for each Remote Network Agent
    • Creates secrets for each RNA namespace using the Client Credentials
    • Uses Helm to install the Remote Network Agents, one in each RNA namespace
    • Creates four namespaces to mimic different deployment target clusters
    bash setup-helm.sh <client-ID> <client-secret>
    

    After the script completes successfully, you can view the connected Remote Network Agents on the CD-as-a-Service Console’s Networking > Agents screen.

Deploy the sample app

The sample app is a simple webserver and a corresponding Service. You can find the Kubernetes manifest is the manifests directory. The CD-as-a-Service deployment file is called deploy.yml and is at the root level.

You are going to deploy the sample app to four targets: test, staging, prod-us, and prod-eu. Each target defines the following:

  • The RNA to connect to
  • The namespace to deploy the app to
  • The deployment strategy
  • Optionally any deployment constraints

CD-as-a-Service deploys the sample app first to the the test target. If that succeeds, CD-as-a-Service deploys to staging. CD-as-a-Service deploys to the production targets only if deployment to staging is successful and a user manually approves deployment.

To deploy the sample, navigate to your docs-cdaas-sample directory and run:

armory deploy start -f deploy.yml

Output is similar to:

[2022-04-27T16:24:04-05:00] Deployment ID: 4be2228f-5c46-4574-ad9a-e70e601d94c4
[2022-04-27T16:24:04-05:00] See the deployment status UI:
https://console.cloud.armory.io/deployments/pipeline/4be2228f-5c46-4574-ad9a-e70e601d94c4?environmentId=a8906e61-2388-4daa-b38e-4339390b9447

You can check deployment status by accessing the URL included in the output.

Deployment to prod-us and prod-eu requires manual approval, so be sure to approve in the UI. Additionally, prod-eu requires manual approval to move all of the traffic to the new pods, so be sure to look two manual approvals

Tear down

You can run the configuration/teardown-helm.sh script to uninstall the Remote Network Agents and delete both the RNA and app namespaces.

Troubleshooting

Deployment times out

Because Armory CD-as-a-Service deploys to 100% of nodes on initial deployment, you may run out of space. Increasing the number of nodes should solve the issue.


Last modified June 21, 2023: (c4887fc)