Skip to content

Commit c2f6677

Browse files
Merge pull request #1154 from rabi/job_nodeselector
Add nodeselector for ansible jobs
2 parents 0b1d305 + 02f47e5 commit c2f6677

6 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎apis/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ spec:
4646
properties:
4747
ansibleExtraVars:
4848
x-kubernetes-preserve-unknown-fields: true
49+
ansibleJobNodeSelector:
50+
additionalProperties:
51+
type: string
52+
type: object
4953
ansibleLimit:
5054
type: string
5155
ansibleSkipTags:

‎apis/dataplane/v1beta1/openstackdataplanedeployment_types.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ type OpenStackDataPlaneDeploymentSpec struct {
6767
// +kubebuilder:validation:Minimum:=1
6868
// +kubebuilder:default:=15
6969
DeploymentRequeueTime int `json:"deploymentRequeueTime"`
70+
71+
// +kubebuilder:validation:Optional
72+
// AnsibleJobNodeSelector to target subset of worker nodes running the ansible jobs
73+
AnsibleJobNodeSelector map[string]string `json:"ansibleJobNodeSelector,omitempty"`
7074
}
7175

7276
// OpenStackDataPlaneDeploymentStatus defines the observed state of OpenStackDataPlaneDeployment

‎apis/dataplane/v1beta1/zz_generated.deepcopy.go‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ spec:
4646
properties:
4747
ansibleExtraVars:
4848
x-kubernetes-preserve-unknown-fields: true
49+
ansibleJobNodeSelector:
50+
additionalProperties:
51+
type: string
52+
type: object
4953
ansibleLimit:
5054
type: string
5155
ansibleSkipTags:

‎pkg/dataplane/util/ansible_execution.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func AnsibleExecution(
8484

8585
ansibleEE.ExtraMounts = append(aeeSpec.ExtraMounts, []storage.VolMounts{ansibleEEMounts}...)
8686
ansibleEE.Env = aeeSpec.Env
87+
ansibleEE.NodeSelector = deployment.Spec.AnsibleJobNodeSelector
8788

8889
currentJobHash := deployment.Status.AnsibleEEHashes[ansibleEE.Name]
8990
jobDef, err := ansibleEE.JobForOpenStackAnsibleEE(helper)

‎pkg/dataplane/util/ansibleee.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ type EEJob struct {
6363
Annotations map[string]string `json:"annotations,omitempty"`
6464
// Env is a list containing the environment variables to pass to the pod
6565
Env []corev1.EnvVar `json:"env,omitempty"`
66+
// NodeSelector to target subset of worker nodes running the ansible jobs
67+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
6668
}
6769

6870
// JobForOpenStackAnsibleEE returns a openstackansibleee Job object
@@ -103,6 +105,10 @@ func (a *EEJob) JobForOpenStackAnsibleEE(h *helper.Helper) (*batchv1.Job, error)
103105
}},
104106
}
105107

108+
if a.NodeSelector != nil && len(a.NodeSelector) > 0 {
109+
podSpec.NodeSelector = a.NodeSelector
110+
}
111+
106112
if a.DNSConfig != nil {
107113
podSpec.DNSConfig = a.DNSConfig
108114
podSpec.DNSPolicy = "None"

0 commit comments

Comments
 (0)