diff --git a/pkg/apis/config/v1alpha1/kwok_configuration_types.go b/pkg/apis/config/v1alpha1/kwok_configuration_types.go
index 16980bfbc5..f7302455cb 100644
--- a/pkg/apis/config/v1alpha1/kwok_configuration_types.go
+++ b/pkg/apis/config/v1alpha1/kwok_configuration_types.go
@@ -70,11 +70,15 @@ type KwokConfigurationOptions struct {
// is the default value for flag --tls-private-key-file
TLSPrivateKeyFile string `json:"tlsPrivateKeyFile,omitempty"`
+ // Manages is the option to manage an resources
+ Manages ManagesSelectors `json:"manages,omitempty"`
+
// ManageSingleNode is the option to manage a single node name.
// is the default value for flag --manage-single-node
// Note: when `manage-all-nodes` is specified as true or
// `manage-nodes-with-label-selector` or `manage-nodes-with-annotation-selector` is specified,
// this is a no-op.
+ // Deprecated: use Manages instead
ManageSingleNode string `json:"manageSingleNode,omitempty"`
// Default option to manage (i.e., maintain heartbeat/liveness of) all Nodes or not.
@@ -83,6 +87,7 @@ type KwokConfigurationOptions struct {
// `manage-nodes-with-label-selector` or `manage-nodes-with-annotation-selector` is specified,
// this is a no-op.
// +default=false
+ // Deprecated: use Manages instead
ManageAllNodes *bool `json:"manageAllNodes,omitempty"`
// Default annotations specified on Nodes to demand manage.
@@ -90,6 +95,7 @@ type KwokConfigurationOptions struct {
// Note: when `all-node-manage` is specified as true or
// `manage-single-node` is specified,
// this is a no-op.
+ // Deprecated: use Manages instead
ManageNodesWithAnnotationSelector string `json:"manageNodesWithAnnotationSelector,omitempty"`
// Default labels specified on Nodes to demand manage.
@@ -97,6 +103,7 @@ type KwokConfigurationOptions struct {
// Note: when `all-node-manage` is specified as true or
// `manage-single-node` is specified,
// this is a no-op.
+ // Deprecated: use Manages instead
ManageNodesWithLabelSelector string `json:"manageNodesWithLabelSelector,omitempty"`
// If a Node/Pod is on a managed Node and has this annotation status will not be modified
diff --git a/pkg/apis/config/v1alpha1/kwok_manage_selector_types.go b/pkg/apis/config/v1alpha1/kwok_manage_selector_types.go
new file mode 100644
index 0000000000..b3fe4b275c
--- /dev/null
+++ b/pkg/apis/config/v1alpha1/kwok_manage_selector_types.go
@@ -0,0 +1,38 @@
+/*
+Copyright 2024 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1alpha1
+
+// ManagesSelectors holds information about the manages selectors.
+type ManagesSelectors []ManagesSelector
+
+// ManagesSelector holds information about the manages selector.
+type ManagesSelector struct {
+ // Kind of the referent.
+ Kind string `json:"kind"`
+ // Group of the referent.
+ Group string `json:"group,omitempty"`
+ // Version of the referent.
+ Version string `json:"version,omitempty"`
+ // Namespace of the referent. only valid if it is a namespaced.
+ Namespace string `json:"namespace,omitempty"`
+ // Name of the referent. specify only this one.
+ Name string `json:"name,omitempty"`
+ // Labels of the referent. specify matched with labels.
+ Labels map[string]string `json:"labels,omitempty"`
+ // Annotations of the referent. specify matched with annotations.
+ Annotations map[string]string `json:"annotations,omitempty"`
+}
diff --git a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
index 1b5f881f11..c499319526 100644
--- a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go
@@ -201,6 +201,13 @@ func (in *KwokConfigurationOptions) DeepCopyInto(out *KwokConfigurationOptions)
*out = make([]string, len(*in))
copy(*out, *in)
}
+ if in.Manages != nil {
+ in, out := &in.Manages, &out.Manages
+ *out = make(ManagesSelectors, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
if in.ManageAllNodes != nil {
in, out := &in.ManageAllNodes, &out.ManageAllNodes
*out = new(bool)
@@ -404,6 +411,58 @@ func (in *KwokctlResource) DeepCopyObject() runtime.Object {
return nil
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ManagesSelector) DeepCopyInto(out *ManagesSelector) {
+ *out = *in
+ if in.Labels != nil {
+ in, out := &in.Labels, &out.Labels
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ if in.Annotations != nil {
+ in, out := &in.Annotations, &out.Annotations
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagesSelector.
+func (in *ManagesSelector) DeepCopy() *ManagesSelector {
+ if in == nil {
+ return nil
+ }
+ out := new(ManagesSelector)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in ManagesSelectors) DeepCopyInto(out *ManagesSelectors) {
+ {
+ in := &in
+ *out = make(ManagesSelectors, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ return
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagesSelectors.
+func (in ManagesSelectors) DeepCopy() ManagesSelectors {
+ if in == nil {
+ return nil
+ }
+ out := new(ManagesSelectors)
+ in.DeepCopyInto(out)
+ return *out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Port) DeepCopyInto(out *Port) {
*out = *in
diff --git a/pkg/apis/internalversion/kwok_configuration_types.go b/pkg/apis/internalversion/kwok_configuration_types.go
index 40fa116534..1e8173efe2 100644
--- a/pkg/apis/internalversion/kwok_configuration_types.go
+++ b/pkg/apis/internalversion/kwok_configuration_types.go
@@ -52,16 +52,23 @@ type KwokConfigurationOptions struct {
// TLSPrivateKeyFile is the ile containing x509 private key
TLSPrivateKeyFile string
+ // Manages is the option to manage the resource
+ Manages ManagesSelectors
+
// ManageSingleNode is the option to manage a single node name
+ // Deprecated: use Manages instead
ManageSingleNode string
// Default option to manage (i.e., maintain heartbeat/liveness of) all Nodes or not.
+ // Deprecated: use Manages instead
ManageAllNodes bool
// Default annotations specified on Nodes to demand manage.
+ // Deprecated: use Manages instead
ManageNodesWithAnnotationSelector string
// Default labels specified on Nodes to demand manage.
+ // Deprecated: use Manages instead
ManageNodesWithLabelSelector string
// If a Node/Pod is on a managed Node and has this annotation status will not be modified
diff --git a/pkg/apis/internalversion/kwok_manages_selector.go b/pkg/apis/internalversion/kwok_manages_selector.go
new file mode 100644
index 0000000000..55ff82a217
--- /dev/null
+++ b/pkg/apis/internalversion/kwok_manages_selector.go
@@ -0,0 +1,242 @@
+/*
+Copyright 2024 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package internalversion
+
+import (
+ "fmt"
+ "sort"
+ "strings"
+
+ "k8s.io/apimachinery/pkg/fields"
+ "k8s.io/apimachinery/pkg/runtime/schema"
+ "k8s.io/apimachinery/pkg/selection"
+
+ "sigs.k8s.io/kwok/pkg/utils/maps"
+ "sigs.k8s.io/kwok/pkg/utils/slices"
+)
+
+// ManagesSelectors holds information about the manages selectors.
+type ManagesSelectors []ManagesSelector
+
+// ManagesSelector holds information about the manages selector.
+type ManagesSelector struct {
+ // Kind of the referent.
+ Kind string
+ // Group of the referent.
+ Group string
+ // Version of the referent.
+ Version string
+ // Namespace of the referent. only valid if it is a namespaced.
+ Namespace string
+ // Name of the referent. specify only this one.
+ Name string
+ // Labels of the referent. specify matched with labels.
+ Labels map[string]string
+ // Annotations of the referent. specify matched with annotations.
+ Annotations map[string]string
+}
+
+func (s *ManagesSelectors) Set(sel string) error {
+ p, err := parseManagesSelector(sel)
+ if err != nil {
+ return err
+ }
+ *s = append(*s, *p)
+ return nil
+}
+
+func (s ManagesSelectors) Type() string {
+ return "ManagesSelectorSlice"
+}
+
+func (s ManagesSelectors) String() string {
+ strSlice := slices.Map(s, func(t ManagesSelector) string {
+ return t.String()
+ })
+ return strings.Join(strSlice, " ")
+}
+
+func (s *ManagesSelector) Set(sel string) error {
+ p, err := parseManagesSelector(sel)
+ if err != nil {
+ return err
+ }
+ *s = *p
+ return nil
+}
+
+func (s *ManagesSelector) Type() string {
+ return "ManagesSelector"
+}
+
+func parseManagesSelector(arg string) (*ManagesSelector, error) {
+ items := strings.Split(arg, ":")
+
+ t := ManagesSelector{}
+ gvk := items[0]
+ if gvk == "" {
+ return nil, fmt.Errorf("invalid empty target resource ref")
+ }
+
+ sepVersion := strings.Index(gvk, "/")
+ if sepVersion != -1 {
+ t.Version = gvk[sepVersion+1:]
+ gvk = gvk[:sepVersion]
+ }
+
+ sepGroup := strings.Index(gvk, ".")
+ if sepGroup != -1 {
+ t.Kind = gvk[:sepGroup]
+ t.Group = gvk[sepGroup+1:]
+ } else {
+ t.Kind = gvk
+ }
+
+ for _, item := range items[1:] {
+ sel, err := fields.ParseSelector(item)
+ if err != nil {
+ return nil, err
+ }
+ for _, req := range sel.Requirements() {
+ if req.Operator != selection.Equals && req.Operator != selection.DoubleEquals {
+ return nil, fmt.Errorf("invalid selector requirements: %s", req.Operator)
+ }
+ switch req.Field {
+ case "metadata.name":
+ t.Name = req.Value
+ case "metadata.namespace":
+ t.Namespace = req.Value
+ default:
+ sp := strings.SplitN(req.Field, ".", 3)
+ if len(sp) < 2 {
+ return nil, fmt.Errorf("error target resource ref: %s", item)
+ }
+ if sp[0] != "metadata" {
+ return nil, fmt.Errorf("error target resource ref: %s", item)
+ }
+
+ switch sp[1] {
+ case "labels":
+ if t.Labels == nil {
+ t.Labels = map[string]string{}
+ }
+ t.Labels[sp[2]] = req.Value
+ case "annotations":
+ if t.Annotations == nil {
+ t.Annotations = map[string]string{}
+ }
+ t.Annotations[sp[2]] = req.Value
+ default:
+ return nil, fmt.Errorf("error target resource ref: %s", item)
+ }
+ }
+ }
+ }
+ return &t, nil
+}
+
+func (s *ManagesSelector) String() string {
+ if s == nil {
+ return ""
+ }
+
+ buf := &strings.Builder{}
+ buf.WriteString(s.Kind)
+ if s.Group != "" {
+ buf.WriteString(fmt.Sprintf(".%s", s.Group))
+ }
+ if s.Version != "" {
+ buf.WriteString(fmt.Sprintf("/%s", s.Version))
+ }
+ if s.Name != "" {
+ buf.WriteString(fmt.Sprintf(":metadata.name=%s", s.Name))
+ }
+ if s.Namespace != "" {
+ buf.WriteString(fmt.Sprintf(":metadata.namespace=%s", s.Namespace))
+ }
+ if len(s.Labels) > 0 {
+ keys := maps.Keys(s.Labels)
+ sort.Strings(keys)
+ for _, k := range keys {
+ buf.WriteString(fmt.Sprintf(":metadata.labels.%s=%s", k, s.Labels[k]))
+ }
+ }
+ if len(s.Annotations) > 0 {
+ keys := maps.Keys(s.Annotations)
+ sort.Strings(keys)
+ for _, k := range keys {
+ buf.WriteString(fmt.Sprintf(":metadata.annotations.%s=%s", k, s.Annotations[k]))
+ }
+ }
+ return buf.String()
+}
+
+func (s ManagesSelectors) MatchStage(stage *Stage) bool {
+ for _, t := range s {
+ if t.MatchStage(stage) {
+ return true
+ }
+ }
+ return false
+}
+
+func (s *ManagesSelector) MatchStage(stage *Stage) bool {
+ spec := stage.Spec
+ rr := spec.ResourceRef
+
+ if s.Kind != rr.Kind {
+ return false
+ }
+
+ gv := schema.GroupVersion{
+ Group: s.Group,
+ Version: s.Version,
+ }
+ apiGroup := gv.String()
+ if apiGroup == "" {
+ apiGroup = "v1"
+ }
+
+ if rr.APIGroup == "" {
+ rr.APIGroup = "v1"
+ }
+
+ if apiGroup != rr.APIGroup {
+ return false
+ }
+
+ if spec.Selector != nil {
+ if len(s.Labels) != 0 {
+ ml := spec.Selector.MatchLabels
+ for k, v := range s.Labels {
+ if mv, ok := ml[k]; ok && mv != v {
+ return false
+ }
+ }
+ }
+ if len(s.Annotations) != 0 {
+ ma := spec.Selector.MatchAnnotations
+ for k, v := range s.Annotations {
+ if mv, ok := ma[k]; ok && mv != v {
+ return false
+ }
+ }
+ }
+ }
+
+ return true
+}
diff --git a/pkg/apis/internalversion/kwok_manages_selector_node.go b/pkg/apis/internalversion/kwok_manages_selector_node.go
new file mode 100644
index 0000000000..3f440df24e
--- /dev/null
+++ b/pkg/apis/internalversion/kwok_manages_selector_node.go
@@ -0,0 +1,96 @@
+/*
+Copyright 2024 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package internalversion
+
+import (
+ "fmt"
+
+ "k8s.io/apimachinery/pkg/labels"
+)
+
+// ManageNodeSelector is a struct that holds how to manage nodes.
+type ManageNodeSelector struct {
+ // ManageSingleNode is the option to manage a single node name
+ ManageSingleNode string
+
+ // Default option to manage (i.e., maintain heartbeat/liveness of) all Nodes or not.
+ ManageAllNodes bool
+
+ // Default annotations specified on Nodes to demand manage.
+ ManageNodesWithAnnotationSelector string
+
+ // Default labels specified on Nodes to demand manage.
+ ManageNodesWithLabelSelector string
+}
+
+// IsEmpty means that no node needs to be managed.
+func (n ManageNodeSelector) IsEmpty() bool {
+ return !n.ManageAllNodes &&
+ n.ManageSingleNode == "" &&
+ n.ManageNodesWithAnnotationSelector == "" &&
+ n.ManageNodesWithLabelSelector == ""
+}
+
+// NodeSelector returns the selector of nodes
+func (s ManagesSelectors) NodeSelector() (ManageNodeSelector, error) {
+ var n *ManageNodeSelector
+ for _, sel := range s {
+ // TODO: Node, Lease, Pod can be maintained separately by different controllers.
+ if sel.Kind == "Pod" &&
+ sel.Group == "" &&
+ (sel.Version == "" || sel.Version == "v1") {
+ return ManageNodeSelector{}, fmt.Errorf("unsupported pod selector type")
+ }
+ if sel.Kind == "Lease" &&
+ sel.Namespace == "kube-node-lease" &&
+ sel.Group == "coordination.k8s.io" &&
+ (sel.Version == "" || sel.Version == "v1") {
+ return ManageNodeSelector{}, fmt.Errorf("unsupported leases.coordination.k8s.io on kube-node-lease selector type")
+ }
+
+ if sel.Kind != "Node" || sel.Group != "" || !(sel.Version == "" || sel.Version == "v1") {
+ continue
+ }
+
+ // TODO: Support multiple nodes selector
+ if n != nil {
+ return ManageNodeSelector{}, fmt.Errorf("duplicate node selector: %v", sel)
+ }
+
+ if sel.Namespace != "" {
+ return ManageNodeSelector{}, fmt.Errorf("invalid node selector with namespace %q", sel.Namespace)
+ }
+
+ n = &ManageNodeSelector{}
+
+ if sel.Name != "" {
+ n.ManageSingleNode = sel.Name
+ }
+ if len(sel.Labels) != 0 {
+ n.ManageNodesWithLabelSelector = labels.Set(sel.Labels).String()
+ }
+ if len(sel.Annotations) != 0 {
+ n.ManageNodesWithAnnotationSelector = labels.Set(sel.Annotations).String()
+ }
+ }
+
+ if n == nil {
+ return ManageNodeSelector{}, nil
+ }
+
+ return *n, nil
+}
diff --git a/pkg/apis/internalversion/kwok_manages_selector_test.go b/pkg/apis/internalversion/kwok_manages_selector_test.go
new file mode 100644
index 0000000000..c71ac9a63d
--- /dev/null
+++ b/pkg/apis/internalversion/kwok_manages_selector_test.go
@@ -0,0 +1,122 @@
+/*
+Copyright 2024 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package internalversion
+
+import (
+ "reflect"
+ "testing"
+)
+
+func Test_parseManagesSelector(t *testing.T) {
+ tests := []struct {
+ name string
+ args string
+ want *ManagesSelector
+ wantErr bool
+ }{
+ {
+ name: "empty",
+ args: "",
+ wantErr: true,
+ },
+ {
+ name: "pod",
+ args: "pod",
+ want: &ManagesSelector{
+ Kind: "pod",
+ },
+ },
+ {
+ name: "pod v1",
+ args: "pod/v1",
+ want: &ManagesSelector{
+ Kind: "pod",
+ Version: "v1",
+ },
+ },
+ {
+ name: "deploy.apps",
+ args: "deploy.apps",
+ want: &ManagesSelector{
+ Kind: "deploy",
+ Group: "apps",
+ },
+ },
+ {
+ name: "deploy.apps v1",
+ args: "deploy.apps/v1",
+ want: &ManagesSelector{
+ Kind: "deploy",
+ Group: "apps",
+ Version: "v1",
+ },
+ },
+ {
+ name: "pod name=po",
+ args: "pod:metadata.name=po",
+ want: &ManagesSelector{
+ Kind: "pod",
+ Name: "po",
+ },
+ },
+ {
+ name: "pod namespace=ns",
+ args: "pod:metadata.namespace=ns",
+ want: &ManagesSelector{
+ Kind: "pod",
+ Namespace: "ns",
+ },
+ },
+ {
+ name: "pod labels.apps.group=xxx",
+ args: "pod:metadata.labels.apps.group=xxx",
+ want: &ManagesSelector{
+ Kind: "pod",
+ Labels: map[string]string{
+ "apps.group": "xxx",
+ },
+ },
+ },
+ {
+ name: "pod annotations.apps.group=xxx",
+ args: "pod:metadata.annotations.apps.group=xxx",
+ want: &ManagesSelector{
+ Kind: "pod",
+ Annotations: map[string]string{
+ "apps.group": "xxx",
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got, err := parseManagesSelector(tt.args)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("ParseTargetResourceRef() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("ParseTargetResourceRef() got = %v, want %v", got, tt.want)
+ }
+
+ rev := got.String()
+ if rev != tt.args {
+ t.Errorf("reverse got = %v, want %v", rev, tt.args)
+ }
+ })
+ }
+}
diff --git a/pkg/apis/internalversion/zz_generated.conversion.go b/pkg/apis/internalversion/zz_generated.conversion.go
index 65008ceaae..b4d243b9b6 100644
--- a/pkg/apis/internalversion/zz_generated.conversion.go
+++ b/pkg/apis/internalversion/zz_generated.conversion.go
@@ -410,6 +410,16 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
+ if err := s.AddGeneratedConversionFunc((*ManagesSelector)(nil), (*configv1alpha1.ManagesSelector)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_internalversion_ManagesSelector_To_v1alpha1_ManagesSelector(a.(*ManagesSelector), b.(*configv1alpha1.ManagesSelector), scope)
+ }); err != nil {
+ return err
+ }
+ if err := s.AddGeneratedConversionFunc((*configv1alpha1.ManagesSelector)(nil), (*ManagesSelector)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_v1alpha1_ManagesSelector_To_internalversion_ManagesSelector(a.(*configv1alpha1.ManagesSelector), b.(*ManagesSelector), scope)
+ }); err != nil {
+ return err
+ }
if err := s.AddGeneratedConversionFunc((*Metric)(nil), (*v1alpha1.Metric)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_internalversion_Metric_To_v1alpha1_Metric(a.(*Metric), b.(*v1alpha1.Metric), scope)
}); err != nil {
@@ -1492,6 +1502,7 @@ func autoConvert_internalversion_KwokConfigurationOptions_To_v1alpha1_KwokConfig
out.NodePort = in.NodePort
out.TLSCertFile = in.TLSCertFile
out.TLSPrivateKeyFile = in.TLSPrivateKeyFile
+ out.Manages = *(*configv1alpha1.ManagesSelectors)(unsafe.Pointer(&in.Manages))
out.ManageSingleNode = in.ManageSingleNode
if err := v1.Convert_bool_To_Pointer_bool(&in.ManageAllNodes, &out.ManageAllNodes, s); err != nil {
return err
@@ -1533,6 +1544,7 @@ func autoConvert_v1alpha1_KwokConfigurationOptions_To_internalversion_KwokConfig
out.NodePort = in.NodePort
out.TLSCertFile = in.TLSCertFile
out.TLSPrivateKeyFile = in.TLSPrivateKeyFile
+ out.Manages = *(*ManagesSelectors)(unsafe.Pointer(&in.Manages))
out.ManageSingleNode = in.ManageSingleNode
if err := v1.Convert_Pointer_bool_To_bool(&in.ManageAllNodes, &out.ManageAllNodes, s); err != nil {
return err
@@ -2004,6 +2016,38 @@ func Convert_v1alpha1_LogsSpec_To_internalversion_LogsSpec(in *v1alpha1.LogsSpec
return autoConvert_v1alpha1_LogsSpec_To_internalversion_LogsSpec(in, out, s)
}
+func autoConvert_internalversion_ManagesSelector_To_v1alpha1_ManagesSelector(in *ManagesSelector, out *configv1alpha1.ManagesSelector, s conversion.Scope) error {
+ out.Kind = in.Kind
+ out.Group = in.Group
+ out.Version = in.Version
+ out.Namespace = in.Namespace
+ out.Name = in.Name
+ out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
+ out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations))
+ return nil
+}
+
+// Convert_internalversion_ManagesSelector_To_v1alpha1_ManagesSelector is an autogenerated conversion function.
+func Convert_internalversion_ManagesSelector_To_v1alpha1_ManagesSelector(in *ManagesSelector, out *configv1alpha1.ManagesSelector, s conversion.Scope) error {
+ return autoConvert_internalversion_ManagesSelector_To_v1alpha1_ManagesSelector(in, out, s)
+}
+
+func autoConvert_v1alpha1_ManagesSelector_To_internalversion_ManagesSelector(in *configv1alpha1.ManagesSelector, out *ManagesSelector, s conversion.Scope) error {
+ out.Kind = in.Kind
+ out.Group = in.Group
+ out.Version = in.Version
+ out.Namespace = in.Namespace
+ out.Name = in.Name
+ out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
+ out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations))
+ return nil
+}
+
+// Convert_v1alpha1_ManagesSelector_To_internalversion_ManagesSelector is an autogenerated conversion function.
+func Convert_v1alpha1_ManagesSelector_To_internalversion_ManagesSelector(in *configv1alpha1.ManagesSelector, out *ManagesSelector, s conversion.Scope) error {
+ return autoConvert_v1alpha1_ManagesSelector_To_internalversion_ManagesSelector(in, out, s)
+}
+
func autoConvert_internalversion_Metric_To_v1alpha1_Metric(in *Metric, out *v1alpha1.Metric, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_internalversion_MetricSpec_To_v1alpha1_MetricSpec(&in.Spec, &out.Spec, s); err != nil {
diff --git a/pkg/apis/internalversion/zz_generated.deepcopy.go b/pkg/apis/internalversion/zz_generated.deepcopy.go
index 3bbf08b6a7..fb56747cbf 100644
--- a/pkg/apis/internalversion/zz_generated.deepcopy.go
+++ b/pkg/apis/internalversion/zz_generated.deepcopy.go
@@ -682,6 +682,13 @@ func (in *KwokConfigurationOptions) DeepCopyInto(out *KwokConfigurationOptions)
*out = make([]string, len(*in))
copy(*out, *in)
}
+ if in.Manages != nil {
+ in, out := &in.Manages, &out.Manages
+ *out = make(ManagesSelectors, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
return
}
@@ -859,6 +866,74 @@ func (in *LogsSpec) DeepCopy() *LogsSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ManageNodeSelector) DeepCopyInto(out *ManageNodeSelector) {
+ *out = *in
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManageNodeSelector.
+func (in *ManageNodeSelector) DeepCopy() *ManageNodeSelector {
+ if in == nil {
+ return nil
+ }
+ out := new(ManageNodeSelector)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ManagesSelector) DeepCopyInto(out *ManagesSelector) {
+ *out = *in
+ if in.Labels != nil {
+ in, out := &in.Labels, &out.Labels
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ if in.Annotations != nil {
+ in, out := &in.Annotations, &out.Annotations
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagesSelector.
+func (in *ManagesSelector) DeepCopy() *ManagesSelector {
+ if in == nil {
+ return nil
+ }
+ out := new(ManagesSelector)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in ManagesSelectors) DeepCopyInto(out *ManagesSelectors) {
+ {
+ in := &in
+ *out = make(ManagesSelectors, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ return
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagesSelectors.
+func (in ManagesSelectors) DeepCopy() ManagesSelectors {
+ if in == nil {
+ return nil
+ }
+ out := new(ManagesSelectors)
+ in.DeepCopyInto(out)
+ return *out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Metric) DeepCopyInto(out *Metric) {
*out = *in
diff --git a/pkg/kwok/cmd/root.go b/pkg/kwok/cmd/root.go
index c49ee08d60..73e696df50 100644
--- a/pkg/kwok/cmd/root.go
+++ b/pkg/kwok/cmd/root.go
@@ -82,10 +82,15 @@ func NewCommand(ctx context.Context) *cobra.Command {
cmd.Flags().IntVar(&flags.Options.NodePort, "node-port", flags.Options.NodePort, "Port of the node")
cmd.Flags().StringVar(&flags.Options.TLSCertFile, "tls-cert-file", flags.Options.TLSCertFile, "File containing the default x509 Certificate for HTTPS")
cmd.Flags().StringVar(&flags.Options.TLSPrivateKeyFile, "tls-private-key-file", flags.Options.TLSPrivateKeyFile, "File containing the default x509 private key matching --tls-cert-file")
+ cmd.Flags().Var(&flags.Options.Manages, "manage", "Manages resources")
cmd.Flags().StringVar(&flags.Options.ManageSingleNode, "manage-single-node", flags.Options.ManageSingleNode, "Node that matches the name will be watched and managed. It's conflicted with manage-nodes-with-annotation-selector, manage-nodes-with-label-selector and manage-all-nodes.")
+ _ = cmd.Flags().MarkDeprecated("manage-single-node", "Please use --manage Node:metadata.name=
+ ManagesSelector holds information about the manages selector.
KwokConfiguration
@@ -382,6 +385,118 @@ string
+
+ManagesSelector
+ #
+
+
Field | +Description | +
---|---|
+apiVersion
+string
+ |
+
+
+config.kwok.x-k8s.io/v1alpha1
+
+ |
+
+kind
+string
+ |
+ManagesSelector |
+
+kind
+
+string
+
+ |
+
+ Kind of the referent. + |
+
+group
+
+string
+
+ |
+
+ Group of the referent. + |
+
+version
+
+string
+
+ |
+
+ Version of the referent. + |
+
+namespace
+
+string
+
+ |
+
+ Namespace of the referent. only valid if it is a namespaced. + |
+
+name
+
+string
+
+ |
+
+ Name of the referent. specify only this one. + |
+
+labels
+
+map[string]string
+
+ |
+
+ Labels of the referent. specify matched with labels. + |
+
+annotations
+
+map[string]string
+
+ |
+
+ Annotations of the referent. specify matched with annotations. + |
+
manages
+
+
+ManagesSelectors
+
+
+Manages is the option to manage an resources
+manageSingleNode
string
@@ -2457,7 +2585,8 @@ string
is the default value for flag –manage-single-node
Note: when manage-all-nodes
is specified as true or
manage-nodes-with-label-selector
or manage-nodes-with-annotation-selector
is specified,
-this is a no-op.
+this is a no-op.
+Deprecated: use Manages instead
manage-single-node
is specified as true or
manage-nodes-with-label-selector
or manage-nodes-with-annotation-selector
is specified,
-this is a no-op.
+this is a no-op.
+Deprecated: use Manages instead
all-node-manage
is specified as true or
manage-single-node
is specified,
-this is a no-op.
+this is a no-op.
+Deprecated: use Manages instead
all-node-manage
is specified as true or
manage-single-node
is specified,
-this is a no-op.
+this is a no-op.
+Deprecated: use Manages instead
[]sigs.k8s.io/kwok/pkg/apis/config/v1alpha1.ManagesSelector
alias)
+ #
++Appears on: +KwokConfigurationOptions +
++
ManagesSelectors holds information about the manages selectors.
+