Skip to content

Commit

Permalink
Add RoundRobinNodes option
Browse files Browse the repository at this point in the history
  • Loading branch information
msergg committed Sep 1, 2023
1 parent 11cbba8 commit a406c2b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/v1/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ type PodCheck struct {
ExpectedContent string `yaml:"expectedContent,omitempty" json:"expectedContent,omitempty" template:"true"`
ExpectedHTTPStatuses []int `yaml:"expectedHttpStatuses,omitempty" json:"expectedHttpStatuses,omitempty"`
PriorityClass string `yaml:"priorityClass,omitempty" json:"priorityClass,omitempty"`
RoundRobinNodes bool `yaml:"roundRobinNodes,omitempty" json:"roundRobinNodes,omitempty"`
}

func (c PodCheck) GetEndpoint() string {
Expand Down
10 changes: 8 additions & 2 deletions checks/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"

canaryv1 "github.com/flanksource/canary-checker/api/v1"

"github.com/flanksource/canary-checker/pkg"
"github.com/flanksource/canary-checker/pkg/metrics"
"github.com/flanksource/commons/logger"

perrors "github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -89,9 +91,13 @@ func (c *PodChecker) newPod(podCheck canaryv1.PodCheck, nodeName string) (*v1.Po
pod.Labels[nameLabel] = pod.Name
pod.Labels[podCheckSelector] = c.podCheckSelectorValue(podCheck)
pod.Labels[podGeneralSelector] = "true"
pod.Spec.NodeSelector = map[string]string{
"kubernetes.io/hostname": nodeName,

if podCheck.RoundRobinNodes {
pod.Spec.NodeSelector = map[string]string{
"kubernetes.io/hostname": nodeName,
}
}

if podCheck.PriorityClass != "" {
pod.Spec.PriorityClassName = podCheck.PriorityClass
}
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4473,6 +4473,8 @@ spec:
readyTimeout:
format: int64
type: integer
roundRobinNodes:
type: boolean
scheduleTimeout:
format: int64
type: integer
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4473,6 +4473,8 @@ spec:
readyTimeout:
format: int64
type: integer
roundRobinNodes:
type: boolean
scheduleTimeout:
format: int64
type: integer
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/canary.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,9 @@
},
"priorityClass": {
"type": "string"
},
"roundRobinNodes": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2873,6 +2873,9 @@
},
"priorityClass": {
"type": "string"
},
"roundRobinNodes": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/health_pod.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
},
"priorityClass": {
"type": "string"
},
"roundRobinNodes": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/topology.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,9 @@
},
"priorityClass": {
"type": "string"
},
"roundRobinNodes": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit a406c2b

Please sign in to comment.