openyurtio / yurt-app-manager

The workload controller manager from NodePool level in OpenYurt cluster
Apache License 2.0
6 stars 1 forks source link

UnitedDeployment need support patch feature for pool #11

Closed kadisi closed 3 years ago

kadisi commented 3 years ago

Now UnitedDeployment controller provides a new way to manage pods in multi-pool by using multiple workloads. Each workload managed by UnitedDeployment is called a pool. Each pool should at least provide the capacity to run the replicas number of pods.

The below sample yaml presents a UnitedDeployment which manages three Deployment instances in one pool(cloud).

apiVersion: apps.openyurt.io/v1alpha1
kind: UnitedDeployment
metadata:
  name: deploy
  namespace: default
spec:
  selector:
    matchLabels:
      app: deploy
  workloadTemplate:
    deploymentTemplate:
      metadata:
        labels:
          app: deploy
      spec:
        selector:
          matchLabels:
            app: deploy
        template:
          metadata:
            labels:
              app: deploy
          spec:
            containers:
            - image: nginx:1.19.3
              imagePullPolicy: Always
              name: nginx
  topology:
    pools:
    - name: cloud
      nodeSelectorTerm:
        matchExpressions:
        - key: apps.openyurt.io/uniteddeployment
          operator: In
          values:
          - cloud
      replicas: 1

We can see the workloadTemplate.DeploymentTemplate configuration to describe a Deployment template, and pool named cloud which has nodeSelectorTerm and replicas field. So use workloadTemplate and topology.pools configuration, UnitedDeployment's Pods are evenly distributed across all pools.

When an UnitedDeployment CR is created, a workload created progress will be triggered. Each workload will inherits this spec.workloadTemplate configuration. Each workload will be patch to spec.workloadTemplate configuration use it's Replicas field.

Therefore, until now, each workload has been able to modify the template differently based on its Replicas configuration. However, in a real edge scenario, the user may not only want to modify the Replicas configuration, but other configurations will also be modified. Here are a few scenario examples:

1 User wants to upgrade the image version in a certain Pool and verify it. After successful verification, upgrade the image's version in all pools in full amount.

2 Users use a Pool to represent a node Pool, each node Pool will be built under a different image repository, so the image name may be different

  1. Host configuration, scale and access pressure are different in different node pools, so pod's containers.resources.request and containers.resources.limit may also be different.

so unitedDeployment controller need support patch feature for pool.

MIBc commented 3 years ago

I think the patch feature is necessary.