-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A Horizontal Pod Autoscaler (HPA) was added in this PR, along with a new MinReplicas and MaxReplicas. With that, the collector should now automatically scale up and down based on the CPU and/or memory consumption. When none of the new properties are specified, the minimum amount of replicas is 1, while the maximum number of replicas is 100. The HPA configuration is added only when the deployment strategy is either production or streaming. Signed-off-by: Juraci Paixão Kröhling <[email protected]>
- Loading branch information
1 parent
1c151cb
commit 5040bbf
Showing
18 changed files
with
755 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# this is a deployment for the tracegen utility that is delivered with Jaeger | ||
# use with care, as it generates quite some load in the current setting | ||
# this deployment was especially designed to test the autoscaling capabilities | ||
# and requires an instance named 'simple-prod'. | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tracegen | ||
annotations: | ||
"sidecar.jaegertracing.io/inject": "simple-prod" | ||
spec: | ||
replicas: 10 | ||
selector: | ||
matchLabels: | ||
app: tracegen | ||
template: | ||
metadata: | ||
labels: | ||
app: tracegen | ||
spec: | ||
containers: | ||
- name: tracegen | ||
image: jaegertracing/jaeger-tracegen:latest | ||
args: | ||
- -duration=30m | ||
- -workers=10 | ||
- name: jaeger-agent | ||
image: jaegertracing/jaeger-agent:1.16.0 | ||
args: | ||
- --reporter.grpc.host-port=dns:///simple-prod-collector-headless.default:14250 | ||
- --reporter.type=grpc | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.name | ||
ports: | ||
- containerPort: 6831 | ||
name: jg-compact-trft | ||
protocol: UDP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package jaeger | ||
|
||
import ( | ||
"context" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"go.opentelemetry.io/otel/global" | ||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1" | ||
"github.com/jaegertracing/jaeger-operator/pkg/inventory" | ||
"github.com/jaegertracing/jaeger-operator/pkg/tracing" | ||
) | ||
|
||
func (r *ReconcileJaeger) applyHorizontalPodAutoscalers(ctx context.Context, jaeger v1.Jaeger, desired []autoscalingv2beta2.HorizontalPodAutoscaler) error { | ||
tracer := global.TraceProvider().GetTracer(v1.ReconciliationTracer) | ||
ctx, span := tracer.Start(ctx, "applyHorizontalPodAutoscalers") | ||
defer span.End() | ||
|
||
opts := []client.ListOption{ | ||
client.InNamespace(jaeger.Namespace), | ||
client.MatchingLabels(map[string]string{ | ||
"app.kubernetes.io/instance": jaeger.Name, | ||
"app.kubernetes.io/managed-by": "jaeger-operator", | ||
}), | ||
} | ||
hpaList := &autoscalingv2beta2.HorizontalPodAutoscalerList{} | ||
if err := r.client.List(ctx, hpaList, opts...); err != nil { | ||
return tracing.HandleError(err, span) | ||
} | ||
|
||
hpaInventory := inventory.ForHorizontalPodAutoscalers(hpaList.Items, desired) | ||
for _, d := range hpaInventory.Create { | ||
jaeger.Logger().WithFields(log.Fields{ | ||
"hpa": d.Name, | ||
"namespace": d.Namespace, | ||
}).Debug("creating hpa") | ||
if err := r.client.Create(ctx, &d); err != nil { | ||
return tracing.HandleError(err, span) | ||
} | ||
} | ||
|
||
for _, d := range hpaInventory.Update { | ||
jaeger.Logger().WithFields(log.Fields{ | ||
"hpa": d.Name, | ||
"namespace": d.Namespace, | ||
}).Debug("updating hpa") | ||
if err := r.client.Update(ctx, &d); err != nil { | ||
return tracing.HandleError(err, span) | ||
} | ||
} | ||
|
||
for _, d := range hpaInventory.Delete { | ||
jaeger.Logger().WithFields(log.Fields{ | ||
"hpa": d.Name, | ||
"namespace": d.Namespace, | ||
}).Debug("deleting hpa") | ||
if err := r.client.Delete(ctx, &d); err != nil { | ||
return tracing.HandleError(err, span) | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.