-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metallb: add metallb controller and speaker builder func #276
base: main
Are you sure you want to change the base?
Conversation
4e56eb9
to
26a5684
Compare
pkg/metallb/metallb.go
Outdated
Effect: "NoExecute", | ||
}, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can define all 3( Spec, ControllerConfig, ControllerTolerations) together.
builder.Definition.Spec = mlbtypes.MetalLBSpec{
ControllerConfig: &mlbtypes.Config{
PriorityClassName: priorityClassName,
RuntimeClassName: runtimeClassName,
Annotations: map[string]string{deploymentName: "controller"},
Affinity: &corev1.Affinity{
PodAffinity: &corev1.PodAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
LabelSelector: &metaV1.LabelSelector{
MatchLabels: map[string]string{
"component": helmChartControllerTestName,
},
},
TopologyKey: "kubernetes.io/hostname",
},
},
},
},
},
ControllerTolerations: []corev1.Toleration{
{
Key: helmChartKeyExample,
Operator: "Exists",
Effect: "NoExecute",
},
},
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Changed
pkg/metallb/metallb.go
Outdated
Effect: "NoExecute", | ||
}, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same like above. we can define them together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor suggestions
pkg/metallb/metallb.go
Outdated
@@ -392,3 +393,101 @@ func (builder *Builder) convertToStructured(unsObject *unstructured.Unstructured | |||
|
|||
return metalLb, err | |||
} | |||
|
|||
// WithMetallbControllerConfig defines the controller config with a helm chart table. | |||
func (builder *Builder) WithMetallbControllerConfig(priorityClassName, runtimeClassName, deploymentName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please this func to other global With functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
pkg/metallb/metallb.go
Outdated
glog.V(100).Infof("Defining the metallb object with Helm Chart in namespace %s", | ||
builder.Definition.Namespace, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate all arguments: priorityClassName, runtimeClassName, deploymentName,helmChartControllerTestName, helmChartKeyExample
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at CRD, it seems that priorityClassName, runtimeClassName,
are optional fields. Just wonder if is needed to enforce them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are optional. They can also accept an empty string. I have removed the validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that's a good idea, because an empty field and a field that's not configured are not the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi I added a verification to make sure its not an empty field
pkg/metallb/metallb.go
Outdated
func (builder *Builder) WithMetallbSpeakerConfig(speakerPriorityClassName, runtimeClassName, helmChartDemoSpeakerName, | ||
helmChartSpeakerTestName, keyName string) *Builder { | ||
if valid, err := builder.validate(); !valid { | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
pkg/metallb/metallb.go
Outdated
return builder | ||
} | ||
|
||
if !builder.Exists() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
pkg/metallb/metallb.go
Outdated
glog.V(100).Infof("Defining the metallb object with Helm Chart in namespace %s", | ||
builder.Definition.Namespace, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate all arguments: priorityClassName, runtimeClassName, deploymentName,helmChartControllerTestName, helmChartKeyExample
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for PriorityClassName, RuntimeClassName
, those are optional fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are also optional and can receive an empty string. Removing the validations
be591e3
to
1979312
Compare
lgtm |
pkg/metallb/metallb.go
Outdated
} | ||
|
||
if builder.errorMsg != "" { | ||
glog.V(100).Infof("Error occurred building metallb Controller Config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please return builder here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
pkg/metallb/metallb.go
Outdated
} | ||
|
||
if builder.errorMsg != "" { | ||
glog.V(100).Infof("Error occurred building metallb Controller Config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please return builder here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comments on optional fields that are required. Wondering if that is really the intent
pkg/metallb/metallb.go
Outdated
glog.V(100).Infof("Defining the metallb object with Helm Chart in namespace %s", | ||
builder.Definition.Namespace, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at CRD, it seems that priorityClassName, runtimeClassName,
are optional fields. Just wonder if is needed to enforce them.
pkg/metallb/metallb.go
Outdated
glog.V(100).Infof("Defining the metallb object with Helm Chart in namespace %s", | ||
builder.Definition.Namespace, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for PriorityClassName, RuntimeClassName
, those are optional fields.
5d52665
to
0b9fa5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
7e94f52
to
e0ecc15
Compare
de41b86
to
fd722cd
Compare
d6a41b9
to
f3976a0
Compare
f3976a0
to
6616b87
Compare
@@ -326,6 +327,195 @@ func (builder *Builder) WithSpeakerNodeSelector(label map[string]string) *Builde | |||
return builder | |||
} | |||
|
|||
// WithControllerPriorityClassName adds a priority class name tp the metallb controller config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be to
?
// WithControllerPriorityClassName adds a priority class name tp the metallb controller config. | |
// WithControllerPriorityClassName adds a priority class name to the metallb controller config. |
return builder | ||
} | ||
|
||
// if len(priorityClassName) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented code
PodAffinity: &corev1.PodAffinity{ | ||
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{ | ||
{LabelSelector: &metav1.LabelSelector{ | ||
MatchLabels: map[string]string{"component": controllerPodAffinityLabel}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be more flexible by passing in the map for the MatchLabels and a string parameter for the TopologyKey:
MatchLabels: map[string]string{"component": controllerPodAffinityLabel}, | |
MatchLabels: contollerPodAffinityMap, |
This PR adds metallb builder function allowing helm chart fields to be used to populate the controller and speaker config.