karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Some Labels cannot be propagated to member cluster normally When both using OP and COP Object.

Open wangyuan249 opened this issue 1 year ago • 1 comments

What happened: Both using OP and COP Object, Some Labels cannot be propagated to member cluster normally.

What you expected to happen: All labels can be propagated to member cluster normally.

How to reproduce it (as minimally and precisely as possible): Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    k8s.com.net/display-name: python-code-executor
  labels:
    app: python-code-executor
    app.kubernetes.io/name: python-code-executor
    app.kubernetes.io/version: v0
    k8s.com.net/dslVersion: v1alpha
    k8s.com.net/tenant: plantform
  name: python-code-executor
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: python-code-executor
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: python-code-executor
        app.kubernetes.io/name: python-code-executor
        app.kubernetes.io/version: v0
        k8s.com.net/tenant: plantform
    spec:
      containers:
      - image: nginx:latest
        imagePullPolicy: Always
        name: c0
        resources:
          limits:
            cpu: 100m
            memory: 64Mi
          requests:
            cpu: 100m
            memory: 64Mi
        securityContext:
          privileged: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext:
        runAsNonRoot: false
      terminationGracePeriodSeconds: 30

PP

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: python-code-executor-deployment
  namespace: default
spec:
  conflictResolution: Overwrite
  placement:
    clusterAffinity:
      clusterNames:
      - active-cluster
      - standby-cluster
    replicaScheduling:
      replicaSchedulingType: Duplicated
  resourceSelectors:
  - apiVersion: apps/v1
    kind: Deployment
    name: python-code-executor
    namespace: default

OP

apiVersion: policy.karmada.io/v1alpha1
kind: OverridePolicy
metadata:
  name: python-code-executor-deployment
  namespace: default
spec:
  overrideRules:
  - overriders:
      plaintext:
      - operator: add
        path: /metadata/labels/velero.io~1restore-name
        value: velero-test-20231129133059-20231129142127
      - operator: add
        path: /metadata/labels/k8s.com.net~1app-type
        value: null
      - operator: add
        path: /metadata/labels/velero.io~1backup-name
        value: velero-test-20231129133059
      - operator: remove
        path: /metadata/labels/k8s.com.net~1dslVersion
        value: null
    targetCluster:
      clusterNames:
      - standby-cluster
  overriders: {}
  resourceSelectors:
  - apiVersion: apps/v1
    kind: Deployment
    name: python-code-executor
    namespace: default

COP

apiVersion: policy.karmada.io/v1alpha1
kind: ClusterOverridePolicy
metadata:
  name: global-label
spec:
  resourceSelectors:
  - apiVersion: apps/v1
    kind: Deployment
    name: python-code-executor
    namespace: default
  overrideRules:
  - overriders:
      labelsOverrider:
        - operator: add
          value:
            host.karmada.com.net/name: karmada-cop-test
    targetCluster:
      clusterNames:
        - active-cluster
        - standby-cluster

After apply all the above resources, we can see : the label defined in cop "host.karmada.com.net/name: karmada-cop-test"
only apply to one cluster and the other do not have.

Anything else we need to know?:

Environment:

  • Karmada version: v1.9.0-preview5-r2
  • kubectl-karmada or karmadactl version (the result of kubectl-karmada version or karmadactl version):
  • Others:

wangyuan249 avatar Feb 18 '24 12:02 wangyuan249

/cc @chaosi-zju

wangyuan249 avatar Feb 18 '24 12:02 wangyuan249