Skip to content

Agents

The repo agent is a service that you deploy and operate in the local network or VPC and therefore, the controller can securely connect to the artifact repositories.

The table below describes the list of actions that can be performed on "repository" using the RCTL CLI Utility.

Resource Create Get Delete
Agent YES YES YES

Create Agent

Both "imperative" and "declarative" approaches are supported for management of agents.


Imperative

You can create an agent in the dev-cluster using the command shown below.

./rctl create agent sample-agent --type ClusterAgent --cluster-name dev-cluster

Declarative

Users has two options to choose from the deployment type when creating GitOps agent

  • Kubernetes deployment type, where the cluster mapping is mandatory
  • Docker deployment type. This type will allow the customer to deploy the Gitops agent as a standalone object on any machine without the need of a cluster

Kubernetes Deployment Type

To create a agent with Kubernetes Deployment Type, use the below command

./rctl create agent -f dev-cluster-agent.yaml

An illustrative example of the agent spec YAML file is shown below

apiVersion: gitops.k8smgmt.io/v3
kind: Agent
metadata:
  name: agent-demo
  project: sample-project
spec:
  active: true
  cluster:
    name: demo-new1
  type: Cluster

Docker Deployment Type

  • Step 1: To create an agent with Docker Deployment Type, use the below command
./rctl create agent -f <docker-agent.yaml> --download

An illustrative example of the agent spec YAML file is shown below with the agent name agent-demo

apiVersion: gitops.k8smgmt.io/v3
kind: Agent
metadata:
  name: agent-demo
  project: defaultproject
spec:
  active: true
  type: Docker

The download flag used in the create agent command download two files: - docker-compose.yml: A YAML file that contains the definition of docker services and volumes, which helps the customers to deploy the Gitops agent as a standalone docker container - relayConfigData.json: A JSON file that consists of configuration data where the relay agent can communicate with the core using this file

Below is an example of the downloaded files

docket-compose File

version: "3"
services:
  cd-agent-7dkgjkx:
    image: registry.dev.rafay-edge.net:5000/dev/cd-agent:20220124202911
    command: --cdrelay-agent
    volumes:
      - ./relayConfigData-7dkgjkx.json:/etc/config/relayConfigData
      - tmp-dir-7dkgjkx:/tmp
      - cdagent-volume-7dkgjkx:/opt/rafay
    container_name: cd-agent-7dkgjkx
volumes:
  tmp-dir-7dkgjkx:
  cdagent-volume-7dkgjkx:

relayConfigData File

{
  "agentID": "7dkgjkx",
  "maxDials": "2",
  "relays": [
    {
      "token": "c7nq57hqf0ds3b6dcf80",
      "addr": "console-my-testbed.dev.rafay-edge.net:443",
      "endpoint": "*.core-connector-my-testbed.cdrelay.core.dev.rafay-edge.net:443",
      "name": "rafay-core-cd-relay-agent",
      "templateToken": "c79akdpqf0dts50fe6ng"
    }
  ]
}

Output Directory

To download the relayConfigData and docker-compose files in the required location, use the below command

./rctl create agent -f <docker-agent.yaml> --download --output-dir -/<location>/
  • Steps 2: Once the download is successful, the system provides a docker compose command. Run this command to bring the agent up as a standalone docker container
docker-compose -f docker-compose-<agent_id>.yml up -d

Alternate Command

To perform the files download action and also bring up the new agent in a single step, use the below command.

./rctl create agent -f <docker-agent.yaml> --run output-dir -/<location>/
  • Step 3: The output shows a message on successful creation of Network, Volume and Container. The controller gets updated in a few minutes and shows the newly created agent in Healthy and Activated status (example agent name: agent-demo)

Down the agents

Use the below command to bring down the active agents

docker-compose -f docker-compose-<agent_id>.yml down

Download Agent(s)

  • Use the below command to download the existing agents

./rctl download agent <agent-name>
- Perform Step 1 and Step 2 to create an agent, based on this config details if required


List Agents

Use this command to retrieve the list of agents in the configured Project. The name of the agents, the type of agent and health status are returned. An illustrative example is shown below where RCTL retrieves the list of agents in the project "Demo".

./rctl get agent --project Demo
+---------------+--------------+---------------+------------------------------+
| AGENT NAME    | TYPE         | HEALTH STATUS | CREATE AT                    |
+---------------+--------------+---------------+------------------------------+
| dev           | ClusterAgent | HEALTHY       | Thu Jan  7 22:37:16 UTC 2021 |
+---------------+--------------+---------------+------------------------------+
| test          | ClusterAgent | HEALTHY       | Sat Mar  6 08:31:48 UTC 2021 |
+---------------+--------------+---------------+------------------------------+
| demo          | ClusterAgent | HEALTHY       | Sat Mar  6 09:00:56 UTC 2021 |
+---------------+--------------+---------------+------------------------------+

Get Specific Agent Info

Use this command to retrieve a specific agent's details in the configured project.

./rctl get agent <agent-name>

Below is the illustrative example for the agent called "demo"

./rctl get agent demo
+---------------+--------------+---------------+------------------------------+
| AGENT NAME    | TYPE         | HEALTH STATUS | CREATE AT                    |
+---------------+--------------+---------------+------------------------------+
| demo          | ClusterAgent | HEALTHY       | Sat Mar  6 09:00:56 UTC 2021 |
+---------------+--------------+---------------+------------------------------+

Or you can use below command to get more information of the agent in json or yaml format

./rctl get agent <agent-name> -o json
./rctl get agent <agent-name> -o yaml


Delete Agent

You can delete an agent in the configured project.

./rctl delete agent <agent-name>