Skip to content
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

Set default limits to oauth proxy #1106

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/set_recources_tempo_frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. tempostack, tempomonolithic, github action)
component: tempostack, tempomonolithic

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Assign a percentage of the resources to oauth-proxy if resources are not specified

# One or more tracking issues related to the change
issues: [1107]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
15 changes: 8 additions & 7 deletions internal/manifests/manifestutils/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ var (
"jaeger-frontend": {cpu: 0.045, memory: 0.025},
}
resourcesMapWithGateway = map[string]componentResource{
"distributor": {cpu: 0.26, memory: 0.11},
"ingester": {cpu: 0.36, memory: 0.49},
"compactor": {cpu: 0.15, memory: 0.17},
"querier": {cpu: 0.09, memory: 0.14},
"query-frontend": {cpu: 0.04, memory: 0.02},
"jaeger-frontend": {cpu: 0.04, memory: 0.02},
"gateway": {cpu: 0.06, memory: 0.05},
"distributor": {cpu: 0.26, memory: 0.11},
"ingester": {cpu: 0.36, memory: 0.49},
"compactor": {cpu: 0.15, memory: 0.17},
"querier": {cpu: 0.09, memory: 0.14},
"query-frontend": {cpu: 0.04, memory: 0.02},
"jaeger-frontend": {cpu: 0.03, memory: 0.01},
"jaeger-frontend-proxy": {cpu: 0.01, memory: 0.01},
"gateway": {cpu: 0.06, memory: 0.05},
}
)

Expand Down
4 changes: 3 additions & 1 deletion internal/manifests/monolithic/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func BuildAll(opts Options) ([]client.Object, error) {
tempo.Spec.JaegerUI.Authentication,
tempo.Spec.Timeout.Duration,
opts.CtrlConfig,
statefulSet)
statefulSet,
tempo.Spec.Resources,
)
oauthproxy.PatchQueryFrontEndService(getJaegerUIService(services, tempo), tempo.Name)
if serviceAccount != nil {
oauthproxy.AddServiceAccountAnnotations(serviceAccount, route.Name)
Expand Down
18 changes: 13 additions & 5 deletions internal/manifests/oauthproxy/oauth_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ func PatchStatefulSetForOauthProxy(
authSpec *v1alpha1.JaegerQueryAuthenticationSpec,
timeout time.Duration,
config configv1alpha1.ProjectConfig,
statefulSet *v1.StatefulSet) {
statefulSet *v1.StatefulSet,
defaultResources *corev1.ResourceRequirements,
) {
statefulSet.Spec.Template.Spec.Volumes = append(statefulSet.Spec.Template.Spec.Volumes, corev1.Volume{
Name: getTLSSecretNameForFrontendService(tempo.Name),
VolumeSource: corev1.VolumeSource{
Expand All @@ -86,7 +88,8 @@ func PatchStatefulSetForOauthProxy(
})

statefulSet.Spec.Template.Spec.Containers = append(statefulSet.Spec.Template.Spec.Containers,
oAuthProxyContainer(tempo.Name, statefulSet.Spec.Template.Spec.ServiceAccountName, authSpec, timeout, config.DefaultImages.OauthProxy))
oAuthProxyContainer(tempo.Name, statefulSet.Spec.Template.Spec.ServiceAccountName, authSpec, timeout,
config.DefaultImages.OauthProxy, defaultResources))
}

// PatchDeploymentForOauthProxy returns a modified deployment with the oauth sidecar container and the right service account.
Expand All @@ -96,7 +99,9 @@ func PatchDeploymentForOauthProxy(
authSpec *v1alpha1.JaegerQueryAuthenticationSpec,
timeout time.Duration,
imageSpec configv1alpha1.ImagesSpec,
dep *v1.Deployment) {
dep *v1.Deployment,
defaultResources *corev1.ResourceRequirements,
) {
dep.Spec.Template.Spec.Volumes = append(dep.Spec.Template.Spec.Volumes, corev1.Volume{
Name: getTLSSecretNameForFrontendService(tempo.Name),
VolumeSource: corev1.VolumeSource{
Expand All @@ -118,7 +123,9 @@ func PatchDeploymentForOauthProxy(
naming.Name(manifestutils.QueryFrontendComponentName, tempo.Name),
authSpec,
timeout,
oauthProxyImage))
oauthProxyImage,
defaultResources,
))
}

func getTLSSecretNameForFrontendService(tempoName string) string {
Expand Down Expand Up @@ -154,6 +161,7 @@ func oAuthProxyContainer(
authSpec *v1alpha1.JaegerQueryAuthenticationSpec,
timeout time.Duration,
oauthProxyImage string,
defaultResources *corev1.ResourceRequirements,
) corev1.Container {
args := proxyInitArguments(serviceAccountName, timeout)

Expand All @@ -163,7 +171,7 @@ func oAuthProxyContainer(

resources := authSpec.Resources
if resources == nil {
resources = &corev1.ResourceRequirements{}
resources = defaultResources
}

return corev1.Container{
Expand Down
9 changes: 7 additions & 2 deletions internal/manifests/oauthproxy/oauth_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestOauthProxyContainer(t *testing.T) {
params.Tempo.Spec.Template.QueryFrontend.JaegerQuery.Authentication,
time.Second*5,
customImage,
&corev1.ResourceRequirements{},
)
expected := corev1.Container{
Image: test.expectedImage,
Expand Down Expand Up @@ -346,7 +347,9 @@ func TestPatchDeploymentForOauthProxy(t *testing.T) {
params.Tempo.Spec.Template.QueryFrontend.JaegerQuery.Authentication,
time.Second*5,
params.Tempo.Spec.Images,
dep)
dep,
&corev1.ResourceRequirements{},
)

assert.Equal(t, 2, len(dep.Spec.Template.Spec.Containers))
assert.Equal(t, "oauth-proxy", dep.Spec.Template.Spec.Containers[1].Name)
Expand Down Expand Up @@ -485,7 +488,9 @@ func TestPatchStatefulSetForOauthProxy(t *testing.T) {
params.Tempo.Spec.Template.QueryFrontend.JaegerQuery.Authentication,
time.Second*5,
params.CtrlConfig,
statefulSet)
statefulSet,
&corev1.ResourceRequirements{},
)

assert.Equal(t, 2, len(statefulSet.Spec.Template.Spec.Containers))
assert.Equal(t, "oauth-proxy", statefulSet.Spec.Template.Spec.Containers[1].Name)
Expand Down
5 changes: 4 additions & 1 deletion internal/manifests/queryfrontend/query_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ func BuildQueryFrontend(params manifestutils.Params) ([]client.Object, error) {
jaegerUIAuthentication := tempo.Spec.Template.QueryFrontend.JaegerQuery.Authentication

if jaegerUIAuthentication != nil && jaegerUIAuthentication.Enabled {
defaultOauthProxyResources := manifestutils.Resources(tempo, manifestutils.QueryFrontendComponentName, tempo.Spec.Template.QueryFrontend.Replicas)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should take the resources from jaeger-frontend-proxy, not from manifestutils.QueryFrontendComponentName, or am I reading it wrong?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh true! a mistake! good catch thanks

oauthproxy.PatchDeploymentForOauthProxy(
tempo.ObjectMeta,
params.CtrlConfig,
tempo.Spec.Template.QueryFrontend.JaegerQuery.Authentication,
tempo.Spec.Timeout.Duration,
tempo.Spec.Images,
d)
d,
&defaultOauthProxyResources,
)

oauthproxy.PatchQueryFrontEndService(getQueryFrontendService(tempo, svcs), tempo.Name)
manifests = append(manifests, oauthproxy.OAuthServiceAccount(params))
Expand Down
Loading