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

I have deployed multiple PropagationPolicies and now I want to create pods, how do I specify which PropagationPolicy to use in yaml #6001

Open
Schwarao opened this issue Dec 31, 2024 · 8 comments
Labels
kind/question Indicates an issue that is a support question.

Comments

@Schwarao
Copy link

Please provide an in-depth description of the question you have:

What do you think about this question?:

Environment:

  • Karmada version:
  • Kubernetes version:
  • Others:
@Schwarao Schwarao added the kind/question Indicates an issue that is a support question. label Dec 31, 2024
@zhzhuang-zju
Copy link
Contributor

@Schwarao

type PropagationSpec struct {
// ResourceSelectors used to select resources.
// Nil or empty selector is not allowed and doesn't mean match all kinds
// of resources for security concerns that sensitive resources(like Secret)
// might be accidentally propagated.
// +required
// +kubebuilder:validation:MinItems=1
ResourceSelectors []ResourceSelector `json:"resourceSelectors"`

The ResourceSelectors in PropagationPolicy are used to filter resources, for example,

# PropagationPolicy
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: pod-propagation
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: Pod
      name: foo

#pod
apiVersion: v1
kind: Pod
metadata:
  name: foo

You can also share the YAML of your Pod, and then we can take a look at how to properly configure the ResourceSelectors.

@Schwarao
Copy link
Author

Schwarao commented Jan 4, 2025

@zhzhuang-zju
I have two propagationpolicies here, followed by pods, how to specify which propagationpolicy is adopted for different pods
image
image

@zhzhuang-zju
Copy link
Contributor

If you want to use propagationpolicy test-propagation to propagate pod test1, you can config your propagationpolicy test-propagation as

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: test-propagation
  namespace: default
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: Pod
      name: test1

By distinguishing between the resourceSelectors of different propagationpolicy, you can achieve the purpose of a propagationpolicy matching a specific pod or a certain class of pods.

@Schwarao
Copy link
Author

Schwarao commented Jan 6, 2025

If you want to use propagationpolicy test-propagation to propagate pod test1, you can config your propagationpolicy test-propagation as

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: test-propagation
  namespace: default
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: Pod
      name: test1

By distinguishing between the resourceSelectors of different propagationpolicy, you can achieve the purpose of a propagationpolicy matching a specific pod or a certain class of pods.

Can I do this by being given a different namespace?

@zhzhuang-zju
Copy link
Contributor

you mean the namespace of PropagationPolicy?

@Schwarao
Copy link
Author

Schwarao commented Jan 6, 2025

Yes, different namespaces have different PropagationPolicy

@zhzhuang-zju
Copy link
Contributor

Sure. For example:
there are four pods

# pod1
apiVersion: v1
kind: Pod
metadata:
  name: pod1
  namespace: foo1

# pod2
apiVersion: v1
kind: Pod
metadata:
  name: pod2
  namespace: foo1

# pod3
apiVersion: v1
kind: Pod
metadata:
  name: pod3
  namespace: foo2

# pod4
apiVersion: v1
kind: Pod
metadata:
  name: pod4
  namespace: foo2

and two PropagationPolicies

# foo1-pp
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: foo1-pp
  namespace: foo1
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: Pod

# foo2-pp
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: foo2-pp
  namespace: foo2
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: Pod

Then, pod1 and pod2 will bind to foo1-pp, while pod3 and pod4 will bind to foo2-pp.

@Schwarao
Copy link
Author

Schwarao commented Jan 7, 2025

ok,thanks @zhzhuang-zju

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