Skip to content

Commit

Permalink
✨ support configuration of the agent priorityclass
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Le <yangle@redhat.com>
  • Loading branch information
elgnay committed Feb 2, 2024
1 parent 98ab144 commit 213cb55
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ spec:
resources:
{{ .ResourceRequirements | indent 10 }}
{{- end }}
{{- if .PriorityClassName }}
priorityClassName: "{{ .PriorityClassName }}"
{{- end }}
volumes:
- name: bootstrap-secret
secret:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ spec:
resources:
{{ .ResourceRequirements | indent 10 }}
{{- end }}
{{- if .PriorityClassName }}
priorityClassName: "{{ .PriorityClassName }}"
{{- end }}
volumes:
- name: bootstrap-secret
secret:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ spec:
resources:
{{ .ResourceRequirements | indent 10 }}
{{- end }}
{{- if .PriorityClassName }}
priorityClassName: "{{ .PriorityClassName }}"
{{- end }}
volumes:
- name: hub-kubeconfig-secret
secret:
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/spoke/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewKlusterletOperatorCmd() *cobra.Command {
cmd.Flags().BoolVar(&klOptions.SkipPlaceholderHubSecret, "skip-placeholder-hub-secret", false,
"If set, will skip ensuring a placeholder hub secret which is originally intended for pulling "+
"work image before approved")
cmd.Flags().StringVar(&klOptions.AgentPriorityClassName, "agent-priority-class", "", "PriorityClass name of the klusterlet agents.")
opts.AddFlags(flags)

return cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type klusterletController struct {
kubeClient kubernetes.Interface
kubeVersion *version.Version
operatorNamespace string
agentPriorityClassName string
skipHubSecretPlaceholder bool
cache resourceapply.ResourceCache
managedClusterClientsBuilder managedClusterClientsBuilderInterface
Expand Down Expand Up @@ -80,7 +81,7 @@ func NewKlusterletController(
deploymentInformer appsinformer.DeploymentInformer,
appliedManifestWorkClient workv1client.AppliedManifestWorkInterface,
kubeVersion *version.Version,
operatorNamespace string,
operatorNamespace, agentPriorityClassName string,
recorder events.Recorder,
skipHubSecretPlaceholder bool) factory.Controller {
controller := &klusterletController{
Expand All @@ -90,6 +91,7 @@ func NewKlusterletController(
klusterletLister: klusterletInformer.Lister(),
kubeVersion: kubeVersion,
operatorNamespace: operatorNamespace,
agentPriorityClassName: agentPriorityClassName,
skipHubSecretPlaceholder: skipHubSecretPlaceholder,
cache: resourceapply.NewResourceCache(),
managedClusterClientsBuilder: newManagedClusterClientsBuilder(kubeClient, apiExtensionClient, appliedManifestWorkClient, recorder),
Expand Down Expand Up @@ -147,6 +149,9 @@ type klusterletConfig struct {
ExternalManagedKubeConfigAgentSecret string
InstallMode operatorapiv1.InstallMode

//PriorityClassName is the name of the PriorityClass accociated with the deployed agents
PriorityClassName string

RegistrationFeatureGates []string
WorkFeatureGates []string

Expand Down Expand Up @@ -192,6 +197,7 @@ func (n *klusterletController) sync(ctx context.Context, controllerContext facto
ExternalServerURL: getServersFromKlusterlet(klusterlet),
OperatorNamespace: n.operatorNamespace,
Replica: helpers.DetermineReplica(ctx, n.kubeClient, klusterlet.Spec.DeployOption.Mode, n.kubeVersion),
PriorityClassName: n.agentPriorityClassName,

ExternalManagedKubeConfigSecret: helpers.ExternalManagedKubeConfig,
ExternalManagedKubeConfigRegistrationSecret: helpers.ExternalManagedKubeConfigRegistration,
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/operators/klusterlet/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const defaultComponentNamespace = "open-cluster-management"

type Options struct {
SkipPlaceholderHubSecret bool
AgentPriorityClassName string
}

// RunKlusterletOperator starts a new klusterlet operator
Expand Down Expand Up @@ -107,6 +108,7 @@ func (o *Options) RunKlusterletOperator(ctx context.Context, controllerContext *
workClient.WorkV1().AppliedManifestWorks(),
kubeVersion,
operatorNamespace,
o.AgentPriorityClassName,
controllerContext.EventRecorder,
o.SkipPlaceholderHubSecret)

Expand Down

0 comments on commit 213cb55

Please sign in to comment.