Deploy a Sample App Tutorial
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.
- Create Client Credentials to use when installing Remote Network Agents.
- Connect your cluster.
- Deploy the sample app.
- Tear down the environment.
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”.
- Access the CD-as-a-Service Console.
- Go to the Configuration tab.
- If you have more than one tenant, make sure you select the desired tenant in the User context menu.
- In the left navigation menu, select Access Management > Client Credentials.
- In the upper right corner, select New Credential.
- 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).
- 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.
- 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.
Make sure you are connected to the Kubernetes cluster you want to install the sample app on.
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.Navigate to the
docs-cdaas-sample/configuration
directory and run thesetup-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.
Feedback
Was this page helpful?
Thank you for letting us know!
Sorry to hear that. Please tell us how we can improve.
Last modified June 21, 2023: (c4887fc)