In edge computing scenarios, you can use the UnitedDeployment controller to deploy applications to different node pools. This way, you can centrally manage the number of pods and the image version of containers by using node pools. This topic describes how to use the UnitedDeployment controller to deploy applications.
In edge computing scenarios, computing nodes may be deployed across regions, and an application may run on nodes in different regions. A Deployment is used as an example in this topic. Traditionally, you add the same label to the nodes that are deployed in the same region and create multiple Deployments. These Deployments are deployed to nodes in different regions by matching node selectors.
Application management and maintenance become more complex with the increasing number of regions and differentiated requirements for applications in different regions. The following list describes the main challenges:
- When a new image version is released, you must modify the image version for each Deployment.
- You must customize naming conventions to identify Deployments that belong to the same application.
- Deployments that belong to the same application are configured in the same way, except for the name, node selector, and number of replicated pods.
The UnitedDeployment controller is a feature provided by ACK@Edge. This feature allows you to centrally manage Deployments from a different dimension. For example, you can create, update, and delete multiple Deployments at a time.
The UnitedDeployment controller provides a template to define applications. This template allows you to deploy workloads in different regions and define the nodes in each region as a node pool. The UnitedDeployment controller supports two types of workload: StatefulSet and Deployment. The UnitedDeployment controller creates Deployments or StatefulSets based on the configurations of node pools. You can specify the number of replicated pods for each type of workload. UnitedDeployment enables automatic management and maintenance of multiple Deployments or StatefulSets within individual node pools. In addition, you can create differentiated configurations for these Deployments or StatefulSets, such as the name, node selector, and number of replicated pods.
Create a UnitedDeployment
Create a UnitedDeployment to deploy Deployments.
apiVersion: apps.openyurt.io/v1alpha1 kind: UnitedDeployment metadata: name: example namespace: default spec: revisionHistoryLimit: 5 selector: matchLabels: app: example workloadTemplate: deploymentTemplate: metadata: creationTimestamp: null labels: app: example spec: selector: matchLabels: app: example template: metadata: creationTimestamp: null labels: app: example spec: containers: - image: nginx:1.19.3 imagePullPolicy: Always name: nginx dnsPolicy: ClusterFirst restartPolicy: Always topology: pools: - name: cloud nodeSelectorTerm: matchExpressions: - key: apps.openyurt.io/nodepool operator: In values: - np4b9781c40f0e46c581b2cf2b6160**** replicas: 2 - name: edge nodeSelectorTerm: matchExpressions: - key: apps.openyurt.io/nodepool operator: In values: - np47832359db2e4843aa13e8b76f83**** replicas: 2 tolerations: - effect: NoSchedule key: apps.openyurt.io/taints operator: Exists
|spec.workloadTemplate||The workload template. Valid values:
|spec.topology.pools||Configurations of multiple node pools.|
|spec.topology.pools[*].name||The name of the node pool.|
|spec.topology.pools[*].nodeSelectorTerm||Specifies node affinity for the node pool. Set the key to
Note You can view the ID of a node pool below the name of the node pool on the Node Pools page in the Container Service for Kubernetes (ACK) console.
|spec.topology.pools[*].tolerations||Toleration rules of the node pool.|
|spec.topology.pools[*].replicas||The number of pods in each node pool.|
Use the UnitedDeployment controller to manage pods
- Update pods: You can modify the
spec.template.workloadTemplate.deploymentTemplatefield to trigger pod updates. The UnitedDeployment controller updates the workload template for all node pools. Then, the node pool controller updates the pods in the node pools.
- Scale replicated pods for multiple node pools: You can modify the
spec.topology.poolsfield to change the number of replicated pods for multiple node pools. Then, the replicated pods in the node pools are scaled based on the configuration.