Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any setting or feature that can prevent karmada reconciling resources in cluster #5756

Open
maoyangLiu opened this issue Oct 30, 2024 · 2 comments
Labels
kind/question Indicates an issue that is a support question.

Comments

@maoyangLiu
Copy link
Contributor

For example, when I create a deployment in karmada, it will be deployed to cluster-a and cluster-b. When I edit the spec property of the deployment in cluster-a, karmada will reconcile the deployment in cluster-a with the data in karmada. Is there any setting or feature that can prevent karmada from reconciling the corresponding changes?

Thanks a lot

@maoyangLiu maoyangLiu added the kind/question Indicates an issue that is a support question. label Oct 30, 2024
@zhzhuang-zju
Copy link
Contributor

@maoyangLiu You can use Karmada's custom resource interpreter Retain to resolve control conflicts between the control plane and member clusters.

@zhzhuang-zju
Copy link
Contributor

To facilitate understanding, we can use the maxSurge field of the Deployment nginx as an example.

# nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 2
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx

The Deployment nginx has been propagated to member clusters member1 and member2. To modify the spec.strategy.rollingUpdate.maxSurge field of the Deployment nginx in member1 without being overridden by the control plane, you can achieve this using the following retain strategy.

apiVersion: config.karmada.io/v1alpha1
kind: ResourceInterpreterCustomization
metadata:
  name: nginx-deployment-maxsurge-retention
spec:
  target:
    apiVersion: apps/v1
    kind: Deployment
  customizations:
    retention:
      luaScript: >
        function Retain(desiredObj, observedObj)
          desiredObj.spec.strategy.rollingUpdate.maxSurge = observedObj.spec.strategy.rollingUpdate.maxSurge
          return desiredObj
        end

The target is used to match the target resource. The Retain function is a Lua script, where desiredObj is the object expected by the control plane, and observedObj is the object observed from the member cluster. The final effect is that the maxSurge field of the Deployment nginx in the member cluster is controlled by the member cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

2 participants