Added more clear description for override API (#318)
Signed-off-by: RainbowMango <renhongcai@huawei.com>
This commit is contained in:
parent
d91f7868d0
commit
24ab1993ee
|
@ -50,7 +50,7 @@ spec:
|
||||||
properties:
|
properties:
|
||||||
component:
|
component:
|
||||||
description: 'Component is part of image name. Basically
|
description: 'Component is part of image name. Basically
|
||||||
we presume an image can be make of ''[registry/]repository[:tag]''.
|
we presume an image can be made of ''[registry/]repository[:tag]''.
|
||||||
The registry could be: - k8s.gcr.io - fictional.registry.example:10443
|
The registry could be: - k8s.gcr.io - fictional.registry.example:10443
|
||||||
The repository could be: - kube-apiserver - fictional/nginx
|
The repository could be: - kube-apiserver - fictional/nginx
|
||||||
The tag cloud be: - latest - v1.19.1 - @sha256:dbcc1c35ac38df41fd2f5e4130b32ffdb93ebae8b3dbe638c23575912276fc9c'
|
The tag cloud be: - latest - v1.19.1 - @sha256:dbcc1c35ac38df41fd2f5e4130b32ffdb93ebae8b3dbe638c23575912276fc9c'
|
||||||
|
@ -125,7 +125,7 @@ spec:
|
||||||
type: object
|
type: object
|
||||||
resourceSelectors:
|
resourceSelectors:
|
||||||
description: ResourceSelectors restricts resource types that this
|
description: ResourceSelectors restricts resource types that this
|
||||||
override policy applies to.
|
override policy applies to. nil means matching all resources.
|
||||||
items:
|
items:
|
||||||
description: ResourceSelector the resources will be selected.
|
description: ResourceSelector the resources will be selected.
|
||||||
properties:
|
properties:
|
||||||
|
@ -196,7 +196,8 @@ spec:
|
||||||
type: array
|
type: array
|
||||||
targetCluster:
|
targetCluster:
|
||||||
description: TargetCluster defines restrictions on this override policy
|
description: TargetCluster defines restrictions on this override policy
|
||||||
that only applies to resources propagated to the matching clusters
|
that only applies to resources propagated to the matching clusters.
|
||||||
|
nil means matching all clusters.
|
||||||
properties:
|
properties:
|
||||||
clusterNames:
|
clusterNames:
|
||||||
description: ClusterNames is the list of clusters to be selected.
|
description: ClusterNames is the list of clusters to be selected.
|
||||||
|
@ -293,6 +294,8 @@ spec:
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- overriders
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- spec
|
- spec
|
||||||
|
|
|
@ -50,7 +50,7 @@ spec:
|
||||||
properties:
|
properties:
|
||||||
component:
|
component:
|
||||||
description: 'Component is part of image name. Basically
|
description: 'Component is part of image name. Basically
|
||||||
we presume an image can be make of ''[registry/]repository[:tag]''.
|
we presume an image can be made of ''[registry/]repository[:tag]''.
|
||||||
The registry could be: - k8s.gcr.io - fictional.registry.example:10443
|
The registry could be: - k8s.gcr.io - fictional.registry.example:10443
|
||||||
The repository could be: - kube-apiserver - fictional/nginx
|
The repository could be: - kube-apiserver - fictional/nginx
|
||||||
The tag cloud be: - latest - v1.19.1 - @sha256:dbcc1c35ac38df41fd2f5e4130b32ffdb93ebae8b3dbe638c23575912276fc9c'
|
The tag cloud be: - latest - v1.19.1 - @sha256:dbcc1c35ac38df41fd2f5e4130b32ffdb93ebae8b3dbe638c23575912276fc9c'
|
||||||
|
@ -125,7 +125,7 @@ spec:
|
||||||
type: object
|
type: object
|
||||||
resourceSelectors:
|
resourceSelectors:
|
||||||
description: ResourceSelectors restricts resource types that this
|
description: ResourceSelectors restricts resource types that this
|
||||||
override policy applies to.
|
override policy applies to. nil means matching all resources.
|
||||||
items:
|
items:
|
||||||
description: ResourceSelector the resources will be selected.
|
description: ResourceSelector the resources will be selected.
|
||||||
properties:
|
properties:
|
||||||
|
@ -196,7 +196,8 @@ spec:
|
||||||
type: array
|
type: array
|
||||||
targetCluster:
|
targetCluster:
|
||||||
description: TargetCluster defines restrictions on this override policy
|
description: TargetCluster defines restrictions on this override policy
|
||||||
that only applies to resources propagated to the matching clusters
|
that only applies to resources propagated to the matching clusters.
|
||||||
|
nil means matching all clusters.
|
||||||
properties:
|
properties:
|
||||||
clusterNames:
|
clusterNames:
|
||||||
description: ClusterNames is the list of clusters to be selected.
|
description: ClusterNames is the list of clusters to be selected.
|
||||||
|
@ -293,6 +294,8 @@ spec:
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- overriders
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- spec
|
- spec
|
||||||
|
|
|
@ -20,14 +20,19 @@ type OverridePolicy struct {
|
||||||
// OverrideSpec defines the desired behavior of OverridePolicy.
|
// OverrideSpec defines the desired behavior of OverridePolicy.
|
||||||
type OverrideSpec struct {
|
type OverrideSpec struct {
|
||||||
// ResourceSelectors restricts resource types that this override policy applies to.
|
// ResourceSelectors restricts resource types that this override policy applies to.
|
||||||
|
// nil means matching all resources.
|
||||||
|
// +optional
|
||||||
ResourceSelectors []ResourceSelector `json:"resourceSelectors,omitempty"`
|
ResourceSelectors []ResourceSelector `json:"resourceSelectors,omitempty"`
|
||||||
|
|
||||||
// TargetCluster defines restrictions on this override policy
|
// TargetCluster defines restrictions on this override policy
|
||||||
// that only applies to resources propagated to the matching clusters
|
// that only applies to resources propagated to the matching clusters.
|
||||||
TargetCluster ClusterAffinity `json:"targetCluster,omitempty"`
|
// nil means matching all clusters.
|
||||||
|
// +optional
|
||||||
|
TargetCluster *ClusterAffinity `json:"targetCluster,omitempty"`
|
||||||
|
|
||||||
// Overriders represents the override rules that would apply on resources
|
// Overriders represents the override rules that would apply on resources
|
||||||
Overriders Overriders `json:"overriders,omitempty"`
|
// +required
|
||||||
|
Overriders Overriders `json:"overriders"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overriders offers various alternatives to represent the override rules.
|
// Overriders offers various alternatives to represent the override rules.
|
||||||
|
@ -62,7 +67,7 @@ type ImageOverrider struct {
|
||||||
Predicate *ImagePredicate `json:"predicate,omitempty"`
|
Predicate *ImagePredicate `json:"predicate,omitempty"`
|
||||||
|
|
||||||
// Component is part of image name.
|
// Component is part of image name.
|
||||||
// Basically we presume an image can be make of '[registry/]repository[:tag]'.
|
// Basically we presume an image can be made of '[registry/]repository[:tag]'.
|
||||||
// The registry could be:
|
// The registry could be:
|
||||||
// - k8s.gcr.io
|
// - k8s.gcr.io
|
||||||
// - fictional.registry.example:10443
|
// - fictional.registry.example:10443
|
||||||
|
|
|
@ -319,7 +319,11 @@ func (in *OverrideSpec) DeepCopyInto(out *OverrideSpec) {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.TargetCluster.DeepCopyInto(&out.TargetCluster)
|
if in.TargetCluster != nil {
|
||||||
|
in, out := &in.TargetCluster, &out.TargetCluster
|
||||||
|
*out = new(ClusterAffinity)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
in.Overriders.DeepCopyInto(&out.Overriders)
|
in.Overriders.DeepCopyInto(&out.Overriders)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,12 @@ func (o *overrideManagerImpl) getMatchedClusterOverridePolicy(policies []policyv
|
||||||
// select policy which cluster selector matches target resource.
|
// select policy which cluster selector matches target resource.
|
||||||
clusterMatches := make([]policyv1alpha1.ClusterOverridePolicy, 0)
|
clusterMatches := make([]policyv1alpha1.ClusterOverridePolicy, 0)
|
||||||
for _, policy := range resourceMatches {
|
for _, policy := range resourceMatches {
|
||||||
if util.ClusterMatches(cluster, policy.Spec.TargetCluster) {
|
if policy.Spec.TargetCluster == nil {
|
||||||
|
clusterMatches = append(clusterMatches, policy)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if util.ClusterMatches(cluster, *policy.Spec.TargetCluster) {
|
||||||
clusterMatches = append(clusterMatches, policy)
|
clusterMatches = append(clusterMatches, policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +178,12 @@ func (o *overrideManagerImpl) getMatchedOverridePolicy(policies []policyv1alpha1
|
||||||
// select policy which cluster selector matches target resource.
|
// select policy which cluster selector matches target resource.
|
||||||
clusterMatches := make([]policyv1alpha1.OverridePolicy, 0)
|
clusterMatches := make([]policyv1alpha1.OverridePolicy, 0)
|
||||||
for _, policy := range resourceMatches {
|
for _, policy := range resourceMatches {
|
||||||
if util.ClusterMatches(cluster, policy.Spec.TargetCluster) {
|
if policy.Spec.TargetCluster == nil {
|
||||||
|
clusterMatches = append(clusterMatches, policy)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if util.ClusterMatches(cluster, *policy.Spec.TargetCluster) {
|
||||||
clusterMatches = append(clusterMatches, policy)
|
clusterMatches = append(clusterMatches, policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue