Learn KOP - YAML Workload - Rafay Product Documentation

Part 1: YAML

This is Part 1 of the exercise that will focus on deploying a YAML based workload. You will upload the YAML file to the controller which in turn will deploy it on the remote cluster.

What Will You Do

In part 1, you will:

Step 1: Create Namespace

In this step, we will create a namespace through the UI.

The namespace is now published on the cluster.

Step 2: Create YAML Workload

In this step, we will create a YAML based workload and publish the workload to the cluster.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-yaml
  labels:
    app: nginx
  annotations:
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx-yaml
        image: nginx
        ports:
        - containerPort: 80

The YAML workload is now published on the cluster.

Additionally, you can use the Zero Trust KubeCTL access to check the workload running on the cluster.

Step 1: Create Namespace

In this step, we will create a namespace using the RCTL CLI.

kind: ManagedNamespace
apiVersion: config.rafay.dev/v2
metadata:
  name: yaml-workload
  labels:
  annotations:
spec:
  type: RafayWizard
  resourceQuota:
  placement:
    placementType: ClusterSpecific
    clusterLabels:
    - key: rafay.dev/clusterName
      value: workload-gs

Update the following section of the specification file with the name of the cluster in your environment.

value: workload-gs
./rctl create namespace -f yaml-namespace.yaml

You will see the namespace has been created, but has not been published.

./rctl publish namespace yaml-workload

In the web console, you will see the namespace is now published.

Step 2: Create YAML Workload

In this step, we will create a YAML based workload and publish the workload to the cluster using the RCTL CLI.

name: yaml-workload
namespace: yaml-workload
project: defaultproject
type: NativeYaml
clusters: workload-gs
payload: yaml-workload.yaml

Update the following sections of the specification file:

./rctl create workload -f yaml-workload-resource.yaml

You will see the YAML workload has been created, but has not been published.

./rctl publish workload yaml-workload

In the web console, you will see the workload is now published.

Additionally, you can use the Zero Trust KubeCTL access to check the workload running on the cluster.

Recap

Congratulations! You have successfully deployed a YAML workload to your cluster.