Skip to content

Commit

Permalink
Merge pull request #31 from oribon/node_selector
Browse files Browse the repository at this point in the history
Implement NodeSelector
  • Loading branch information
fedepaol authored Aug 22, 2023
2 parents 7ecf546 + 19fbfe6 commit 0653982
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 6 deletions.
9 changes: 8 additions & 1 deletion api/v1beta1/frrconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ import (
type FRRConfigurationSpec struct {
// +optional
BGP BGPConfig `json:"bgp,omitempty"`
// TODO node selector

// Limits the nodes that will attempt to apply this config.
// When specified, the configuration will be considered only on nodes
// whose labels match the specified selectors.
// When it is not specified all nodes will attempt to apply this config.
// +optional
NodeSelector metav1.LabelSelector `json:"nodeSelector,omitempty"`

// TODO raw config
}

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func main() {
metricsAddr string
probeAddr string
logLevel string
nodeName string // TODO not using this now, but we'll need it when we implement the node selector
nodeName string
)

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
Expand Down Expand Up @@ -94,6 +94,7 @@ func main() {
Scheme: mgr.GetScheme(),
FRRHandler: frr.NewFRR(ctx, logger, logging.Level(logLevel)),
Logger: logger,
NodeName: nodeName,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "FRRConfiguration")
os.Exit(1)
Expand Down
56 changes: 56 additions & 0 deletions config/all-in-one/frr-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,54 @@ spec:
required:
- routers
type: object
nodeSelector:
description: Limits the nodes that will attempt to apply this config.
When specified, the configuration will be considered only on nodes
whose labels match the specified selectors. When it is not specified
all nodes will attempt to apply this config.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
status:
description: FRRConfigurationStatus defines the observed state of FRRConfiguration.
Expand Down Expand Up @@ -336,6 +384,14 @@ metadata:
creationTimestamp: null
name: frr-k8s-daemon-role
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- frrk8s.metallb.io
resources:
Expand Down
48 changes: 48 additions & 0 deletions config/crd/bases/frrk8s.metallb.io_frrconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,54 @@ spec:
required:
- routers
type: object
nodeSelector:
description: Limits the nodes that will attempt to apply this config.
When specified, the configuration will be considered only on nodes
whose labels match the specified selectors. When it is not specified
all nodes will attempt to apply this config.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
status:
description: FRRConfigurationStatus defines the observed state of FRRConfiguration.
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ metadata:
creationTimestamp: null
name: daemon-role
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- frrk8s.metallb.io
resources:
Expand Down
Loading

0 comments on commit 0653982

Please sign in to comment.