How to use `kubeconfig` to experience OpenYurt capabilities

This document will describe how to experience the multi-domain workload manage capability of OpenYurt through kubeconfig provided by Experience Center.

Configure kubeconfig locally

You need to configure kubeconfig locally before you can manage the cluster via kubectl.

  1. Copy kubeconfig information in “Connection Information” tab under “Cluster Information” page

How to use `kubeconfig` to experience OpenYurt capabilities - 图1

  1. Save the copied kubeconfig information to the local ~/.kube/config file

How to use `kubeconfig` to experience OpenYurt capabilities - 图2

  1. If the configuration has been all set, you can use kubectl to manage the cluster

How to use `kubeconfig` to experience OpenYurt capabilities - 图3

Experience OpenYurt’s multi-domain workload manage capability

OpenYurt is designed for edge computing scenarios, allowing users to group workloads into different units distributed in different geographical locations. Here is a simple scenario to experience the multi-domain workload manage capability of OpenYurt.

Now that we have two edge-side nodes, node1 and node2, in different locations (e.g. node1 in Hangzhou and node2 in Shanghai). We want to deploy applications to the Hangzhou node but not to the Shanghai node. OpenYurt does this with two resources, NodePool and YurtAppSet (previous UnitedDeployment) to achieve this capability.

  1. Suppose we have two nodes, node1 and node2, connected to OpenYurt cluster (Don’t know how to join nodes? Please refer to the documentation: How to use web_console)

How to use `kubeconfig` to experience OpenYurt capabilities - 图4

  1. Create a NodePool resource by kubectl on the local node where kubeconfig is configured, and add node1 to that NodePool
  1. # create nodepool hangzhou
  2. cat <<EOF | kubectl apply -f -
  3. apiVersion: apps.openyurt.io/v1alpha1
  4. kind: NodePool
  5. metadata:
  6. name: hangzhou
  7. spec:
  8. type: Edge
  9. EOF
  10. # add node1 to nodepool
  11. kubectl label node node1 apps.openyurt.io/desired-nodepool=hangzhou
  12. # display nodepool
  13. kubectl get nodepool

How to use `kubeconfig` to experience OpenYurt capabilities - 图5

The corresponding NodePool information can be seen in browser page. How to use `kubeconfig` to experience OpenYurt capabilities - 图6

  1. Create workload resources via kubectl and only deploy the application to hangzhou’s node pool via YurtAppSet
  1. cat <<EOF | kubectl apply -f -
  2. apiVersion: apps.openyurt.io/v1alpha1
  3. kind: UnitedDeployment
  4. metadata:
  5. labels:
  6. controller-tools.k8s.io: "1.0"
  7. name: ud-test
  8. namespace: "183xxxxxxxx" # Notice: change this with your own namespace
  9. spec:
  10. selector:
  11. matchLabels:
  12. app: ud-test
  13. workloadTemplate:
  14. deploymentTemplate:
  15. metadata:
  16. labels:
  17. app: ud-test
  18. namespace: "183xxxxxxxx" # Notice: change this with your own namespace
  19. spec:
  20. template:
  21. metadata:
  22. labels:
  23. app: ud-test
  24. spec:
  25. containers:
  26. - name: nginx
  27. image: nginx
  28. topology:
  29. pools:
  30. - name: hangzhou
  31. nodeSelectorTerm:
  32. matchExpressions:
  33. - key: apps.openyurt.io/nodepool
  34. operator: In
  35. values:
  36. - hangzhou
  37. replicas: 1
  38. revisionHistoryLimit: 5
  39. EOF
  40. # display the resources
  41. kubectl get node
  42. kubectl get pod -A
  43. kubectl get nodepool

How to use `kubeconfig` to experience OpenYurt capabilities - 图7 How to use `kubeconfig` to experience OpenYurt capabilities - 图8

After successful creation, you can see on the browser page that the corresponding Pod is assigned to node1 in hangzhou node pool.

How to use `kubeconfig` to experience OpenYurt capabilities - 图9