From 5f653c40fe70590c92dcf445aec59c79d5fc70ba Mon Sep 17 00:00:00 2001 From: haolin Date: Sat, 2 Dec 2023 21:12:08 +0800 Subject: [PATCH] clusteradm join support resource-qos-class parameter Signed-off-by: haolin --- pkg/cmd/join/cmd.go | 1 + pkg/cmd/join/exec.go | 3 +++ pkg/cmd/join/options.go | 10 ++++++++++ pkg/cmd/join/scenario/join/klusterlets.cr.yaml | 2 ++ 4 files changed, 16 insertions(+) diff --git a/pkg/cmd/join/cmd.go b/pkg/cmd/join/cmd.go index 3b63ee623..fb8eeef32 100644 --- a/pkg/cmd/join/cmd.go +++ b/pkg/cmd/join/cmd.go @@ -68,6 +68,7 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream cmd.Flags().BoolVar(&o.singleton, "singleton", false, "If true, deploy singleton mode of klusterlet to have registration and work agents run in a single pod. This is an alpha stage flag.") cmd.Flags().StringVar(&o.proxyURL, "proxy-url", "", "the URL of a forward proxy server that will be used by agents to connect to the hub cluster.") cmd.Flags().StringVar(&o.proxyCAFile, "proxy-ca-file", "", "the file path to proxy ca, optional") + cmd.Flags().StringVar(&o.resourceQosClass, "resource-qos-class", "default", "the resource QoS class of the klusterlet pod. Can be one of default or besteffort") return cmd } diff --git a/pkg/cmd/join/exec.go b/pkg/cmd/join/exec.go index b4149000f..f66486b6b 100644 --- a/pkg/cmd/join/exec.go +++ b/pkg/cmd/join/exec.go @@ -119,6 +119,9 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) { Name: klusterletName, KlusterletNamespace: klusterletNamespace, } + o.values.ResourceRequirement = ResourceRequirement{ + Type: o.resourceQosClass, + } o.values.ManagedKubeconfig = o.managedKubeconfigFile o.values.RegistrationFeatures = genericclioptionsclusteradm.ConvertToFeatureGateAPI(genericclioptionsclusteradm.SpokeMutableFeatureGate, ocmfeature.DefaultSpokeRegistrationFeatureGates) o.values.WorkFeatures = genericclioptionsclusteradm.ConvertToFeatureGateAPI(genericclioptionsclusteradm.SpokeMutableFeatureGate, ocmfeature.DefaultSpokeWorkFeatureGates) diff --git a/pkg/cmd/join/options.go b/pkg/cmd/join/options.go index 538c00ef4..f1b5f1998 100644 --- a/pkg/cmd/join/options.go +++ b/pkg/cmd/join/options.go @@ -63,6 +63,9 @@ type Options struct { //The proxy server ca-file(optional) proxyCAFile string + // Resource requirement + resourceQosClass string + //Values below are used to fill in yaml files values Values @@ -81,6 +84,8 @@ type Values struct { Hub Hub //Klusterlet is the klusterlet related configuration Klusterlet Klusterlet + //ResourceRequirement is the resource requirement + ResourceRequirement ResourceRequirement //Registry is the image registry related configuration Registry string //bundle version @@ -112,6 +117,11 @@ type Klusterlet struct { KlusterletNamespace string } +// ResourceRequirement is for templating resource requirement +type ResourceRequirement struct { + Type string +} + type BundleVersion struct { // registration image version RegistrationImageVersion string diff --git a/pkg/cmd/join/scenario/join/klusterlets.cr.yaml b/pkg/cmd/join/scenario/join/klusterlets.cr.yaml index e0686c409..e987e6382 100644 --- a/pkg/cmd/join/scenario/join/klusterlets.cr.yaml +++ b/pkg/cmd/join/scenario/join/klusterlets.cr.yaml @@ -15,6 +15,8 @@ spec: {{ if .Klusterlet.APIServer }} - url: {{ .Klusterlet.APIServer }} {{ end }} + resourceRequirement: + type: {{ .ResourceRequirement.Type }} {{if .RegistrationFeatures}} registrationConfiguration: featureGates: