Skip to content

Commit

Permalink
Fix nodeSelector expression (kube-burner#234)
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Jan 12, 2023
1 parent 79c5d35 commit 2c1954d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 17 deletions.
12 changes: 10 additions & 2 deletions cmd/kube-burner/ocp-config/node-density-cni/curl-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ spec:
labels:
name: curl-{{.Replica}}-{{.Iteration}}
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
affinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: Exists
- key: node-role.kubernetes.io/infra
operator: DoesNotExist
- key: node-role.kubernetes.io/workload
operator: DoesNotExist
containers:
- name: curlapp
image: quay.io/cloud-bulldozer/curl:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ spec:
labels:
name: webserver-{{.Replica}}-{{.Iteration}}
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
affinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: Exists
- key: node-role.kubernetes.io/infra
operator: DoesNotExist
- key: node-role.kubernetes.io/workload
operator: DoesNotExist
containers:
- name: webserver
image: quay.io/cloud-bulldozer/sampleapp:latest
Expand Down
12 changes: 10 additions & 2 deletions cmd/kube-burner/ocp-config/node-density-heavy/app-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ spec:
labels:
name: perfapp-{{.Replica}}-{{.Iteration}}
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
affinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: Exists
- key: node-role.kubernetes.io/infra
operator: DoesNotExist
- key: node-role.kubernetes.io/workload
operator: DoesNotExist
containers:
- name: perfapp
image: quay.io/cloud-bulldozer/perfapp:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ spec:
labels:
name: postgres-{{.Replica}}-{{.Iteration}}
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
affinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: Exists
- key: node-role.kubernetes.io/infra
operator: DoesNotExist
- key: node-role.kubernetes.io/workload
operator: DoesNotExist
containers:
- name: postgresql
image: registry.redhat.io/rhel8/postgresql-10@sha256:4b912c80085b88a03309aeb7907efcc29dd3342fa3952b6ea067afb1914bfe53
Expand Down
12 changes: 10 additions & 2 deletions cmd/kube-burner/ocp-config/node-density/pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ metadata:
app: node-density-{{.Iteration}}
name: {{.JobName}}-{{.Iteration}}
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
affinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: Exists
- key: node-role.kubernetes.io/infra
operator: DoesNotExist
- key: node-role.kubernetes.io/workload
operator: DoesNotExist
tolerations:
- key: os
value: Windows
Expand Down
6 changes: 3 additions & 3 deletions pkg/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ func getBearerToken(clientset *kubernetes.Clientset) (string, error) {

// GetWorkerNodeCount returns the number of worker nodes
func (da *Agent) GetWorkerNodeCount() (int, error) {
nodeList, err := da.clientSet.CoreV1().Nodes().List(context.TODO(), v1.ListOptions{LabelSelector: "node-role.kubernetes.io/worker="})
log.Debug("Node count: ", len(nodeList.Items))
nodeList, err := da.clientSet.CoreV1().Nodes().List(context.TODO(), v1.ListOptions{LabelSelector: workerNodeSelector})
log.Infof("Listed nodes after using selector %s: %d", workerNodeSelector, len(nodeList.Items))
return len(nodeList.Items), err
}

// GetCurrentPodCount returns the number of current running pods across all worker nodes
func (da *Agent) GetCurrentPodCount() (int, error) {
var podCount int
nodeList, err := da.clientSet.CoreV1().Nodes().List(context.TODO(), v1.ListOptions{LabelSelector: "node-role.kubernetes.io/worker="})
nodeList, err := da.clientSet.CoreV1().Nodes().List(context.TODO(), v1.ListOptions{LabelSelector: workerNodeSelector})
if err != nil {
return podCount, err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/discovery/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ type NodeInfo struct {
}

const (
routeGroup = "route.openshift.io"
routeVersion = "v1"
routeResource = "routes"
completedUpdate = "Completed"
routeGroup = "route.openshift.io"
routeVersion = "v1"
routeResource = "routes"
completedUpdate = "Completed"
workerNodeSelector = "node-role.kubernetes.io/worker=,node-role.kubernetes.io/infra!=,node-role.kubernetes.io/workload!="
)

0 comments on commit 2c1954d

Please sign in to comment.