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 is correct, 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 local node where kubeconfig is configured, and add node1 to that NodePool
  1. # 创建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. # 将node1节点加入nodepool
  11. kubectl label node node1 apps.openyurt.io/desired-nodepool=hangzhou
  12. # 获取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. # 单元化部署pod
  2. cat <<EOF | kubectl apply -f -
  3. apiVersion: apps.openyurt.io/v1alpha1
  4. kind: UnitedDeployment
  5. metadata:
  6. labels:
  7. controller-tools.k8s.io: "1.0"
  8. name: ud-test
  9. namespace: "183xxxxxxxx" # 注意: 替换成你的namespace
  10. spec:
  11. selector:
  12. matchLabels:
  13. app: ud-test
  14. workloadTemplate:
  15. deploymentTemplate:
  16. metadata:
  17. labels:
  18. app: ud-test
  19. namespace: "183xxxxxxxx" # 注意: 替换成你的namespace
  20. spec:
  21. template:
  22. metadata:
  23. labels:
  24. app: ud-test
  25. spec:
  26. containers:
  27. - name: nginx
  28. image: nginx
  29. topology:
  30. pools:
  31. - name: hangzhou
  32. nodeSelectorTerm:
  33. matchExpressions:
  34. - key: apps.openyurt.io/nodepool
  35. operator: In
  36. values:
  37. - hangzhou
  38. replicas: 1
  39. revisionHistoryLimit: 5
  40. EOF
  41. # 查看资源
  42. kubectl get node
  43. kubectl get pod -A
  44. 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