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

moving away from promStatsdExporterContainer #4272

Merged
merged 10 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
56 changes: 11 additions & 45 deletions internal/infrastructure/kubernetes/ratelimit/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,49 +193,9 @@ func expectedRateLimitContainers(rateLimit *egv1a1.RateLimit, rateLimitDeploymen
},
}

if enablePrometheus(rateLimit) {
containers = append(containers, promStatsdExporterContainer())
}

return containers
}

func promStatsdExporterContainer() corev1.Container {
return corev1.Container{
Name: "prom-statsd-exporter",
Image: "prom/statsd-exporter:v0.18.0",
ImagePullPolicy: corev1.PullIfNotPresent,
Command: []string{
"/bin/statsd_exporter",
fmt.Sprintf("--web.listen-address=:%d", PrometheusPort),
"--statsd.mapping-config=/etc/statsd-exporter/conf.yaml",
},
Ports: []corev1.ContainerPort{
{
Name: "statsd",
ContainerPort: StatsdPort,
Protocol: corev1.ProtocolTCP,
},
{
Name: "metrics",
ContainerPort: PrometheusPort,
Protocol: corev1.ProtocolTCP,
},
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "statsd-exporter-config",
ReadOnly: true,
MountPath: "/etc/statsd-exporter",
},
},
TerminationMessagePolicy: corev1.TerminationMessageReadFile,
TerminationMessagePath: "/dev/termination-log",
SecurityContext: defaultSecurityContext(),
Resources: *egv1a1.DefaultResourceRequirements(),
}
}

// expectedContainerVolumeMounts returns expected rateLimit container volume mounts.
func expectedContainerVolumeMounts(rateLimit *egv1a1.RateLimit, rateLimitDeployment *egv1a1.KubernetesDeploymentSpec) []corev1.VolumeMount {
var volumeMounts []corev1.VolumeMount
Expand Down Expand Up @@ -331,11 +291,7 @@ func expectedRateLimitContainerEnv(rateLimit *egv1a1.RateLimit, rateLimitDeploym
},
{
Name: UseStatsdEnvVar,
Value: "true",
},
{
Name: StatsdPortEnvVar,
Value: strconv.Itoa(StatsdPort),
Value: "false",
},
{
Name: ConfigTypeEnvVar,
Expand Down Expand Up @@ -420,6 +376,16 @@ func expectedRateLimitContainerEnv(rateLimit *egv1a1.RateLimit, rateLimitDeploym
}
}

if enablePrometheus(rateLimit) {
env = append(env, corev1.EnvVar{
Name: "USE_PROMETHEUS",
Value: "true",
}, corev1.EnvVar{
Name: "PROMETHEUS_ADDR",
Value: ":19001",
})
}

if enableTracing(rateLimit) {
sampleRate := 1.0
if rateLimit.Telemetry.Tracing.SamplingRate != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ spec:
- name: LOG_LEVEL
value: info
- name: USE_STATSD
value: "true"
- name: STATSD_PORT
value: "9125"
value: "false"
- name: CONFIG_TYPE
value: GRPC_XDS_SOTW
- name: CONFIG_GRPC_XDS_SERVER_URL
Expand Down Expand Up @@ -81,6 +79,10 @@ spec:
value: tcp
- name: REDIS_URL
value: redis.redis.svc:6379
- name: USE_PROMETHEUS
value: "true"
- name: PROMETHEUS_ADDR
value: :19001
image: custom-image
imagePullPolicy: IfNotPresent
name: envoy-ratelimit
Expand Down Expand Up @@ -121,42 +123,6 @@ spec:
- mountPath: /certs
name: certs
readOnly: true
- command:
- /bin/statsd_exporter
- --web.listen-address=:19001
- --statsd.mapping-config=/etc/statsd-exporter/conf.yaml
image: prom/statsd-exporter:v0.18.0
imagePullPolicy: IfNotPresent
name: prom-statsd-exporter
ports:
- containerPort: 9125
name: statsd
protocol: TCP
- containerPort: 19001
name: metrics
protocol: TCP
resources:
requests:
cpu: 100m
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsGroup: 65534
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/statsd-exporter
name: statsd-exporter-config
readOnly: true
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ spec:
- name: LOG_LEVEL
value: info
- name: USE_STATSD
value: "true"
- name: STATSD_PORT
value: "9125"
value: "false"
- name: CONFIG_TYPE
value: GRPC_XDS_SOTW
- name: CONFIG_GRPC_XDS_SERVER_URL
Expand Down Expand Up @@ -81,6 +79,10 @@ spec:
value: tcp
- name: REDIS_URL
value: redis.redis.svc:6379
- name: USE_PROMETHEUS
value: "true"
- name: PROMETHEUS_ADDR
value: :19001
image: custom-image
imagePullPolicy: IfNotPresent
name: envoy-ratelimit
Expand Down Expand Up @@ -121,42 +123,6 @@ spec:
- mountPath: /certs
name: certs
readOnly: true
- command:
- /bin/statsd_exporter
- --web.listen-address=:19001
- --statsd.mapping-config=/etc/statsd-exporter/conf.yaml
image: prom/statsd-exporter:v0.18.0
imagePullPolicy: IfNotPresent
name: prom-statsd-exporter
ports:
- containerPort: 9125
name: statsd
protocol: TCP
- containerPort: 19001
name: metrics
protocol: TCP
resources:
requests:
cpu: 100m
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsGroup: 65534
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/statsd-exporter
name: statsd-exporter-config
readOnly: true
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ spec:
- name: LOG_LEVEL
value: info
- name: USE_STATSD
value: "true"
- name: STATSD_PORT
value: "9125"
value: "false"
- name: CONFIG_TYPE
value: GRPC_XDS_SOTW
- name: CONFIG_GRPC_XDS_SERVER_URL
Expand Down Expand Up @@ -82,6 +80,10 @@ spec:
value: tcp
- name: REDIS_URL
value: redis.redis.svc:6379
- name: USE_PROMETHEUS
value: "true"
- name: PROMETHEUS_ADDR
value: :19001
image: envoyproxy/ratelimit:master
imagePullPolicy: IfNotPresent
name: envoy-ratelimit
Expand Down Expand Up @@ -129,42 +131,6 @@ spec:
- mountPath: /certs
name: certs
readOnly: true
- command:
- /bin/statsd_exporter
- --web.listen-address=:19001
- --statsd.mapping-config=/etc/statsd-exporter/conf.yaml
image: prom/statsd-exporter:v0.18.0
imagePullPolicy: IfNotPresent
name: prom-statsd-exporter
ports:
- containerPort: 9125
name: statsd
protocol: TCP
- containerPort: 19001
name: metrics
protocol: TCP
resources:
requests:
cpu: 100m
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsGroup: 65534
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/statsd-exporter
name: statsd-exporter-config
readOnly: true
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ spec:
- name: LOG_LEVEL
value: info
- name: USE_STATSD
value: "true"
- name: STATSD_PORT
value: "9125"
value: "false"
- name: CONFIG_TYPE
value: GRPC_XDS_SOTW
- name: CONFIG_GRPC_XDS_SERVER_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ spec:
- name: LOG_LEVEL
value: info
- name: USE_STATSD
value: "true"
- name: STATSD_PORT
value: "9125"
value: "false"
- name: CONFIG_TYPE
value: GRPC_XDS_SOTW
- name: CONFIG_GRPC_XDS_SERVER_URL
Expand Down Expand Up @@ -82,6 +80,10 @@ spec:
value: tcp
- name: REDIS_URL
value: redis.redis.svc:6379
- name: USE_PROMETHEUS
value: "true"
- name: PROMETHEUS_ADDR
value: :19001
- name: TRACING_ENABLED
value: "true"
- name: TRACING_SERVICE_NAME
Expand Down Expand Up @@ -144,42 +146,6 @@ spec:
- mountPath: /certs
name: certs
readOnly: true
- command:
- /bin/statsd_exporter
- --web.listen-address=:19001
- --statsd.mapping-config=/etc/statsd-exporter/conf.yaml
image: prom/statsd-exporter:v0.18.0
imagePullPolicy: IfNotPresent
name: prom-statsd-exporter
ports:
- containerPort: 9125
name: statsd
protocol: TCP
- containerPort: 19001
name: metrics
protocol: TCP
resources:
requests:
cpu: 100m
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsGroup: 65534
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/statsd-exporter
name: statsd-exporter-config
readOnly: true
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
Expand Down
Loading
Loading