Merge pull request #116065 from sanposhiho/match-label-key-alternative

feature(scheduler): implement matchLabelKeys in PodAffinity and PodAntiAffinity

Kubernetes-commit: 581552eaf0b4a6689f2a02012804f2780ff7efdf
This commit is contained in:
Kubernetes Publisher 2023-10-23 18:39:13 +02:00
commit b0036672f5
4 changed files with 38 additions and 4 deletions

View File

@ -29,6 +29,8 @@ type PodAffinityTermApplyConfiguration struct {
Namespaces []string `json:"namespaces,omitempty"` Namespaces []string `json:"namespaces,omitempty"`
TopologyKey *string `json:"topologyKey,omitempty"` TopologyKey *string `json:"topologyKey,omitempty"`
NamespaceSelector *v1.LabelSelectorApplyConfiguration `json:"namespaceSelector,omitempty"` NamespaceSelector *v1.LabelSelectorApplyConfiguration `json:"namespaceSelector,omitempty"`
MatchLabelKeys []string `json:"matchLabelKeys,omitempty"`
MismatchLabelKeys []string `json:"mismatchLabelKeys,omitempty"`
} }
// PodAffinityTermApplyConfiguration constructs an declarative configuration of the PodAffinityTerm type for use with // PodAffinityTermApplyConfiguration constructs an declarative configuration of the PodAffinityTerm type for use with
@ -70,3 +72,23 @@ func (b *PodAffinityTermApplyConfiguration) WithNamespaceSelector(value *v1.Labe
b.NamespaceSelector = value b.NamespaceSelector = value
return b return b
} }
// WithMatchLabelKeys adds the given value to the MatchLabelKeys field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the MatchLabelKeys field.
func (b *PodAffinityTermApplyConfiguration) WithMatchLabelKeys(values ...string) *PodAffinityTermApplyConfiguration {
for i := range values {
b.MatchLabelKeys = append(b.MatchLabelKeys, values[i])
}
return b
}
// WithMismatchLabelKeys adds the given value to the MismatchLabelKeys field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the MismatchLabelKeys field.
func (b *PodAffinityTermApplyConfiguration) WithMismatchLabelKeys(values ...string) *PodAffinityTermApplyConfiguration {
for i := range values {
b.MismatchLabelKeys = append(b.MismatchLabelKeys, values[i])
}
return b
}

View File

@ -6272,6 +6272,18 @@ var schemaYAML = typed.YAMLObject(`types:
- name: labelSelector - name: labelSelector
type: type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector
- name: matchLabelKeys
type:
list:
elementType:
scalar: string
elementRelationship: atomic
- name: mismatchLabelKeys
type:
list:
elementType:
scalar: string
elementRelationship: atomic
- name: namespaceSelector - name: namespaceSelector
type: type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector

4
go.mod
View File

@ -24,7 +24,7 @@ require (
golang.org/x/term v0.13.0 golang.org/x/term v0.13.0
golang.org/x/time v0.3.0 golang.org/x/time v0.3.0
google.golang.org/protobuf v1.31.0 google.golang.org/protobuf v1.31.0
k8s.io/api v0.0.0-20231020231155-fe172d7dd4b6 k8s.io/api v0.0.0-20231023194506-ecdf62a858f6
k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432 k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432
k8s.io/klog/v2 v2.100.1 k8s.io/klog/v2 v2.100.1
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00
@ -60,6 +60,6 @@ require (
) )
replace ( replace (
k8s.io/api => k8s.io/api v0.0.0-20231020231155-fe172d7dd4b6 k8s.io/api => k8s.io/api v0.0.0-20231023194506-ecdf62a858f6
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432 k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432
) )

4
go.sum
View File

@ -147,8 +147,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20231020231155-fe172d7dd4b6 h1:L4jlSzYt2s6+MTDB3gKmik1CNSx9Dpzf3wGnSFV1pqk= k8s.io/api v0.0.0-20231023194506-ecdf62a858f6 h1:Zvyr4A5LhIHlT/j4anhh65TuOQ+W6V69lkiVlwJZoOI=
k8s.io/api v0.0.0-20231020231155-fe172d7dd4b6/go.mod h1:mgYOiLIgrQcsuVxrBI6Pplk91r3sl5ZJ7eUx7UBMTkY= k8s.io/api v0.0.0-20231023194506-ecdf62a858f6/go.mod h1:mgYOiLIgrQcsuVxrBI6Pplk91r3sl5ZJ7eUx7UBMTkY=
k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432 h1:TWovhSGZGPhiGaOsd06sIch/R3NwKrbnIj5leHo2OCM= k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432 h1:TWovhSGZGPhiGaOsd06sIch/R3NwKrbnIj5leHo2OCM=
k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432/go.mod h1:mdlGhJWO1mhVzQXm1Lx7D1BvvBIVKlRVy0vvl1LwGjg= k8s.io/apimachinery v0.0.0-20231020230052-c047e325a432/go.mod h1:mdlGhJWO1mhVzQXm1Lx7D1BvvBIVKlRVy0vvl1LwGjg=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=