Argo Rollouts Deployment

Use Armory CD-as-a-Service to deploy Argo Rollout Objects across multiple Kubernetes environments.

Objectives

In this guide, you learn how to use Argo Rollouts with Armory CD-as-a-Service.

  1. Create a CD-as-a-Service deployment config file
  2. Add your Rollout manifest
  3. Deploy your app
  4. Extend deployment functionality to use webhooks and to deploy multiple rollouts

Before you begin

Make sure that you have performed the following steps:

  • Connected to your Kubernetes cluster and deployed an app using the CLI. See Quickstart.

To complete this guide, you need the following:

  • Access to a Kubernetes cluster where you have installed the Remote Network Agent (RNA). This cluster acts as the deployment target for the sample app. (Optional) You can connect multiple Kubernetes clusters to deploy to multiple environments

  • One or more Argo Rollout manifests. For example:

    # rollout.yaml
    apiVersion: argoproj.io/v1alpha1
    kind: Rollout
    metadata:
      name: example
      spec:
        replicas: 5
        ...
     

Create a CD-as-a-Service deployment config file

Create a file called armoryDeployment.yaml with the following contents:

# armoryDeployment.yaml
version: v1
kind: kubernetes
application: <app-name> 
targets:
  staging:
    account: <cluster-name> # Name of the cluster you entered when installing the RNA. 
    namespace: <namespace>
  production:
    account: <cluster-name> 
    namespace: <namespace>
    constraints:
      dependsOn: [staging]
      beforeDeployment:
        - pause:
            untilApproved: true
manifests:
     - path: <path-to-app-manifest>

This example includes multiple targets. You can remove or add targets to match your environment.

Be sure to replace <app-name>, <cluster-name>, and <namespace> placeholders with your own values.

See Deployment Reference if you want to create a more robust deployment config file.

Add your Rollout manifest

  1. Go to the manifests section in your deployment config file.

  2. Add your Argo Rollout manifests in the manifests[].path section:

    # armoryDeployment.yaml
    version: v1
    kind: kubernetes
    ...    
    manifests:
      - path: rollout.yaml

Deploy your app

  1. Ensure you have logged into CD-as-a-Service:

    armory login
  2. Start your deployment using the Armory CLI:

    armory deploy start -f armoryDeployment.yaml --watch

    Remove the --watch flag if you don’t want to output deployment status in your terminal.

If you are only deploying Argo Rollouts, CD-as-a-Service ignores any strategy you configure in your deployment config file. The Rollout follows the strategy defined in the Rollout manifest.

Extend functionality for Rollout deployments

Run integration tests using webhooks

You can use webhooks in afterDeployment constraints to add specific logic for Argo Rollouts to finish deploying before starting integration tests. For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 # armoryDeployment.yaml
version: v1
kind: kubernetes
application: my-application
targets:
  staging:
    account: staging
    namespace: default
    constraints:
      afterDeployment:
        - runWebhook:
            name: Refer to Argo Rollouts for status
manifests:
  - path: rollout.yaml
webhooks:
   - name: Refer to Argo Rollouts for status
     method: POST
     uriTemplate: http://cmd-hook.default:8081/cmd
     networkMode: remoteNetworkAgent
     agentIdentifier: <cluster-name>
     retryCount: 3
     bodyTemplate:
        inline:  >-
        {
        "cmd": "kubectl",
        "arg": "wait -n=default rollout/example --for=condition=Completed --timeout=30m",
        "callbackURL": "{{armory.callbackUri}}/callback"
        }        

This example employs cmd-hook, which is an open source service deployed in the cluster to execute kubectl commands. CD-as-a-Service employs RNA to execute kubectl commands for monitoring the state of rollout objects. You can view the source code for cmd-hook in the public repository.

Deploy multiple Argo Rollouts

To deploy multiple Argo Rollouts together, you can add more paths to the manifests section of the deployment config file:

manifests:
  - path: rollout-1.yaml
  - path: rollout-2.yaml
  - path: rollout-3.yaml

What’s next


Last modified October 17, 2023: (6147f9d)