Skip to content

Created Git Jobs not inheriting node selectors from Fleet values.yaml #5011

@charleshu-8

Description

@charleshu-8

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I've set the Helm chart values nodeSelector and tolerations to confine Fleet to a certain set of nodes. The deployments generated by Fleet all have these node selectors and tolerations (e.g., fleet-controller, gitjob) but whenever a new K8s job is created in order to sync a GitRepo, the job is assigned with the tolerations but not the selectors, causing it to get scheduled on untainted nodes.

Digging a little deeper, it appears that the job will inherit tolerations from the Fleet Controller:

// add tolerations from the fleet-controller deployment
jobSpec.Template.Spec.Tolerations = append(
	jobSpec.Template.Spec.Tolerations,
	fleetControllerDeployment.Spec.Template.Spec.Tolerations...,
)

(source)

but only inherits node selectors when Fleet is sharded:

nodeSelector := map[string]string{"kubernetes.io/os": "linux"}
if shardID != "" && len(strings.TrimSpace(r.JobNodeSelector)) > 0 {
	var shardNodeSelector map[string]string
	if err := json.Unmarshal([]byte(r.JobNodeSelector), &shardNodeSelector); err != nil {
		return nil, fmt.Errorf("could not decode shard node selector: %w", err)
	}

	maps.Copy(nodeSelector, shardNodeSelector)
}

(source)

I don't want to shard Fleet, so the jobs stay selector-less and aren't scheduled correctly for me.

Expected Behavior

The ability to assign node selectors to generated jobs without having the enable Fleet sharding.

Steps To Reproduce

No response

Environment

Logs

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    Status

    Needs QA review

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions