Learn KOP - Deploy Stateless Workload - Rafay Product Documentation

Part 3: Workload

What Will You Do

In this part of the self-paced exercise, you will deploy a stateless workload to both clusters. The stateless workload will be used to demonstrate the ability to keep an application available by means of the blue-green upgrade strategy.


Step 1: Deploy Workload

In this step, you will create a stateless workload on the clusters. The workload will be used to show how the blue-green upgrade strategy can be applied with no disruption to the stateless cluster applications.

name: stateless-workload
namespace: default
project: defaultproject
type: NativeYaml
clusters: blue,green
payload: stateless-workload.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: default
  name: deployment-2048
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: app-2048
  replicas: 5
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app-2048
    spec:
      containers:
      - image: public.ecr.aws/l6m2t8p7/docker-2048:latest
        imagePullPolicy: Always
        name: app-2048
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  namespace: default
  name: service-2048
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: app-2048
rctl create workload workload-spec.yaml

If there were no errors, you should see a message like below

Workload created successfully

Now, let us publish the newly created workload to the EKS clusters. The workload can be deployed to multiple clusters as per the configured "placement policy". In this case, you are deploying to a single EKS cluster with the name "karpenter-cluster".

rctl publish workload stateless-workload

In the web console, click on Applications -> Workloads. You should see something like the following.


Step 2: Access Blue Workload

In this step, we will access the workload on the blue cluster to ensure it is working.

kubectl get services -n default service-2048
NAME           TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)        AGE
service-2048   LoadBalancer   10.100.139.203   a359df9b63fc84d3797397f23db718c3-2075536630.us-west-2.elb.amazonaws.com   80:32518/TCP   10s

We are currently able to access the stateless workload running on the blue cluster.


Step 3: Access Green Workload

In this step, we will access the workload on the green cluster to ensure it is working.

kubectl get services -n default service-2048
NAME           TYPE           CLUSTER-IP      EXTERNAL-IP                                                              PORT(S)        AGE
service-2048   LoadBalancer   10.100.22.204   a18c021ac258f4fcfb1950184a832c7a-465706458.us-west-2.elb.amazonaws.com   80:32370/TCP   11m

We are currently able to access the stateless workload running on the green cluster.


Step 4: Redirect Traffic

Now that we know that the stateless workload is running on the green cluster with the newer version of Kubernetes, we will update our DNS to redirect traffic to the EXTERNAL-IP of the green cluster.

We are now accessing the stateless workload running on the green cluster with no disruption to the end user.


Recap

Congratulations! At this point, you have successfully applied the blue-green upgrade strategy to a cluster running stateless workloads.