Learn KOP - Create and Execute Fleet-Plan - Rafay Product Documentation

Part 1: Create & Execute

In the first part of this exercise, you will create a Fleet Plan that will be used for testing purposes on clusters. This involves creating the Fleet Plan, executing it, and monitoring the progress of the Fleet Job.


What Will You Do

In Part 1, you will focus on creating and configuring the Fleet Plan object. The following tasks are involved:

Note: With the Cluster Runner configuration, the prehook on the target cluster is executed by the Agent running on the Controller. This setup offers flexibility and is suitable when there are restrictions on running additional pods, such as the GitOps Agent, on the cluster to handle the hook execution.

Next, you will repeat the same tasks for the Agent Runner:

Note: With the Agent Runner configuration, the prehook on the target cluster is executed by the GitOps Agent running on the EKS Cluster. This setup offers flexibility and is ideal when there are no restrictions on running additional pods like the GitOps Agent, which handles the hook execution on the cluster where it is running.

By completing these tasks, you will gain a comprehensive understanding of how to configure hooks for both the Cluster and Agent Runners in your fleet plan.


Create Fleet Plan

In this step, we will create a Fleet plan

Create an operation within the above Fleet Plan.

Action: Cluster Upgrade

Running Fleet Plan.

Once the fleet plan has been created, let's proceed to execute it and keep track of the progress.

In the event that the fleet job fails due to a prehook failure caused by the identification of a deprecated API on the cluster, further actions will be halted.


Now, let's examine the successful fleet plan in which we attempted to update the cluster blueprint as an action. Additionally, a different prehook was used, which only displays the deprecated APIs without triggering a failure. By employing this approach, the fleet plan progresses to the action phase and effectively updates the blueprints in the fleet's selected clusters.

Action: Cluster Blueprint Update

This action involves updating the cluster blueprint from the default blueprint to the minimal blueprint

Prehook Configuration

In this example, we demonstrate the usage of the kubepug tool within the hook to perform Kubernetes object validation against the Kubernetes version. This tool efficiently generates a list of Deprecated APIs without causing any failures within the hook.

Execution of the Second Fleet Plan

Once the second fleet plan has been created, let's proceed to execute it and keep track of the progress.

In this step, we will give the RCTL CLI a "declarative Fleet Plan specification." Then, we will use the RCTL CLI to send a command to the controller that starts the creation process and enables future actions on the fleet plan and job.

Save the Fleet Plan specification file below to your computer as "fleet-plan.yaml"

kind: FleetPlan
apiVersion: infra.k8smgmt.io/v3
metadata:
  name: fleetgs1
  project: ankur
spec:
  fleet:
    kind: clusters
    labels:
      rafay.dev/clusterType: aws-eks
    projects:
      - name: ankur
  operationWorkflow:
    operations:
      - name: cluster-update-blueprint
        prehooks:
          - name: apicheck
            containerConfig:
              runner: cluster
              image: ctadeu/kubepug:latest
            arguments:
              - --k8s-version=v1.26.5
        action:
          type: patch
          name: updateblueprint
          patchConfig:
            - op: replace
              path: .spec.blueprintConfig.name
              value: minimal
            - op: replace
              path: .spec.blueprintConfig.version
              value: default
        posthooks:
          - name: posthook-apicheck
            containerConfig:
              runner: cluster
              image: ctadeu/kubepug:latest
            arguments:
              - --k8s-version=v1.26.5

Update the following sections of the specification file with details to match your environment.

Execute the following command to create the fleet plan from the specification file previously defined

<br>1<br> <br>./rctl apply -f fleet-plan.yaml<br>

If there are no apparent problems with the fleet plan specification file, the RCTL CLI will create the fleet plan and execute it accordingly.


Day 2 Fleet Plan Interaction with RCTL CLI Commands

To interact with a fleet plan using RCTL CLI on Day 2, you can use the following commands:


Recap

In this section, you have created a fleet plan for a fleet of clusters, each with its own set of hooks and actions to be run.