-
Notifications
You must be signed in to change notification settings - Fork 631
Audit consistent use of controllerNames and their enabled flags w/ test to verify #13017
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
Changes from all commits
e70276a
ed7a10b
1bf62b1
321c3ae
5bba48e
967af71
1ec265e
5b2eb14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,33 @@ func GetInMemoryGatewayParameters(cfg InMemoryGatewayParametersConfig) *kgateway | |
| // set for the agentgateway deployment. | ||
| func defaultAgentgatewayParameters(imageInfo *ImageInfo, omitDefaultSecurityContext bool) *kgateway.GatewayParameters { | ||
| gwp := defaultGatewayParameters(imageInfo, omitDefaultSecurityContext) | ||
| gwp.Spec.Kube.Agentgateway.Enabled = ptr.To(true) | ||
|
|
||
| // Add agentgateway-specific configuration | ||
| agwConfig := &kgateway.Agentgateway{ | ||
| LogLevel: ptr.To("info"), | ||
| Image: &kgateway.Image{ | ||
| Registry: ptr.To(AgentgatewayRegistry), | ||
| Tag: ptr.To(AgentgatewayDefaultTag), | ||
| Repository: ptr.To(AgentgatewayImage), | ||
| PullPolicy: (*corev1.PullPolicy)(ptr.To(imageInfo.PullPolicy)), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to default to omitting the pull policy so that k8s can use it's unsurprising logic about 'latest means Always, and otherwise...' (see https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting). This is confusing and maybe even casts in the wrong place, but also turns the empty string into "something" when I'd prefer it were nil. There's also validation to consider since we're using a string in ImageInfo, not corev1.PullPolicy. Perhaps use this (which will never error because imageInfo is something we control completely):
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nvm; you just moved this and it's working well enough with a pointer to the empty string because both data plane helm charts say '{{- if $gateway.image.pullPolicy }}'. I don't love the cast on the outside but corev1.PullPolicy is a string like imageInfo.PullPolicy...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I agree, maybe a followup? |
||
| }, | ||
| } | ||
|
|
||
| // Only add SecurityContext if not omitting defaults | ||
| if !omitDefaultSecurityContext { | ||
| agwConfig.SecurityContext = &corev1.SecurityContext{ | ||
| AllowPrivilegeEscalation: ptr.To(false), | ||
| ReadOnlyRootFilesystem: ptr.To(true), | ||
| RunAsNonRoot: ptr.To(true), | ||
| RunAsUser: ptr.To[int64](10101), | ||
| Capabilities: &corev1.Capabilities{ | ||
| Drop: []corev1.Capability{"ALL"}, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| gwp.Spec.Kube.Agentgateway = agwConfig | ||
|
|
||
| gwp.Spec.Kube.PodTemplate.ReadinessProbe.HTTPGet.Path = "/healthz/ready" | ||
| gwp.Spec.Kube.PodTemplate.ReadinessProbe.HTTPGet.Port = intstr.FromInt(15021) | ||
| gwp.Spec.Kube.PodTemplate.StartupProbe.HTTPGet.Path = "/healthz/ready" | ||
|
|
@@ -258,31 +284,13 @@ func defaultGatewayParameters(imageInfo *ImageInfo, omitDefaultSecurityContext b | |
| IstioMetaClusterId: ptr.To("Kubernetes"), | ||
| }, | ||
| }, | ||
| Agentgateway: &kgateway.Agentgateway{ | ||
| Enabled: ptr.To(false), | ||
| LogLevel: ptr.To("info"), | ||
| Image: &kgateway.Image{ | ||
| Registry: ptr.To(AgentgatewayRegistry), | ||
| Tag: ptr.To(AgentgatewayDefaultTag), | ||
| Repository: ptr.To(AgentgatewayImage), | ||
| PullPolicy: (*corev1.PullPolicy)(ptr.To(imageInfo.PullPolicy)), | ||
| }, | ||
| SecurityContext: &corev1.SecurityContext{ | ||
| AllowPrivilegeEscalation: ptr.To(false), | ||
| ReadOnlyRootFilesystem: ptr.To(true), | ||
| RunAsNonRoot: ptr.To(true), | ||
| RunAsUser: ptr.To[int64](10101), | ||
| Capabilities: &corev1.Capabilities{ | ||
| Drop: []corev1.Capability{"ALL"}, | ||
| }, | ||
| }, | ||
| }, | ||
| // Note: Agentgateway config is only added for agentgateway controller gateways | ||
| // via defaultAgentgatewayParameters(). For envoy gateways, we leave this nil. | ||
| }, | ||
| }, | ||
| } | ||
| if omitDefaultSecurityContext { | ||
| gwp.Spec.Kube.EnvoyContainer.SecurityContext = nil | ||
| gwp.Spec.Kube.Agentgateway.SecurityContext = nil | ||
| } | ||
| return gwp.DeepCopy() | ||
| } | ||
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.
As the author of #13018, I want to understand this block better. Seems like we don't need this block or the test/deployer test cases would change with its addition.
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.
Ah; you moved it in this file. You moved it because it was only in use if this function was using it, and because without 'Enabled' it smelled a little funny remaining. There's no point in having the same thing in both places. Looks good.
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.
yeah it would have been dead code here