-
Notifications
You must be signed in to change notification settings - Fork 363
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
fix: rateLimitDeployment ignoring pod labels and annotation merge #4228
Merged
zirain
merged 19 commits into
envoyproxy:main
from
oscarboher:fix/ratelimit-deployment-labels
Oct 1, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
84f6958
fix labels and annotation merges for rate limit deployment
oscarboher 6e5f6a0
fix tests and label merge
oscarboher c0f680d
fix annotation merge if prometheus was disabled and annotations were …
oscarboher 6a57aeb
renamed labels and annotations to specify they apply to pods only
oscarboher cd58565
Merge branch 'main' into fix/ratelimit-deployment-labels
oscarboher 45e0263
linter
oscarboher cfe9bab
Merge branch 'fix/ratelimit-deployment-labels' of github.com:oscarboh…
oscarboher 2db9a57
fix resource provider tests to new annotation behavior
oscarboher 4b86c45
Merge branch 'main' into fix/ratelimit-deployment-labels
oscarboher 138ecda
Merge branch 'main' into fix/ratelimit-deployment-labels
zirain 92a2b13
go linter
oscarboher 1d3f357
Merge branch 'fix/ratelimit-deployment-labels' of github.com:oscarboh…
oscarboher d831f49
fix gen-check
oscarboher e005c19
Merge branch 'main' into fix/ratelimit-deployment-labels
oscarboher a6b00f3
Merge branch 'main' into fix/ratelimit-deployment-labels
arkodg c3220c6
pod labels selector comment
oscarboher 2e8a961
Merge branch 'fix/ratelimit-deployment-labels' of github.com:oscarboh…
oscarboher 11e8504
Merge branch 'main' into fix/ratelimit-deployment-labels
oscarboher 1eb1c07
Merge branch 'main' into fix/ratelimit-deployment-labels
oscarboher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
156 changes: 156 additions & 0 deletions
156
internal/infrastructure/kubernetes/ratelimit/testdata/deployments/merge-annotations.yaml
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,156 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app.kubernetes.io/component: ratelimit | ||
app.kubernetes.io/managed-by: envoy-gateway | ||
app.kubernetes.io/name: envoy-ratelimit | ||
name: envoy-ratelimit | ||
namespace: envoy-gateway-system | ||
ownerReferences: | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
name: envoy-gateway | ||
uid: test-owner-reference-uid-for-deployment | ||
spec: | ||
progressDeadlineSeconds: 600 | ||
revisionHistoryLimit: 10 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/component: ratelimit | ||
app.kubernetes.io/managed-by: envoy-gateway | ||
app.kubernetes.io/name: envoy-ratelimit | ||
strategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
annotations: | ||
key1: value1 | ||
key2: value2 | ||
prometheus.io/path: /metrics | ||
prometheus.io/port: "19001" | ||
prometheus.io/scrape: "true" | ||
creationTimestamp: null | ||
labels: | ||
app.kubernetes.io/component: ratelimit | ||
app.kubernetes.io/managed-by: envoy-gateway | ||
app.kubernetes.io/name: envoy-ratelimit | ||
spec: | ||
automountServiceAccountToken: false | ||
containers: | ||
- command: | ||
- /bin/ratelimit | ||
env: | ||
- name: RUNTIME_ROOT | ||
value: /data | ||
- name: RUNTIME_SUBDIRECTORY | ||
value: ratelimit | ||
- name: RUNTIME_IGNOREDOTFILES | ||
value: "true" | ||
- name: RUNTIME_WATCH_ROOT | ||
value: "false" | ||
- name: LOG_LEVEL | ||
value: info | ||
- name: USE_STATSD | ||
value: "false" | ||
- name: CONFIG_TYPE | ||
value: GRPC_XDS_SOTW | ||
- name: CONFIG_GRPC_XDS_SERVER_URL | ||
value: envoy-gateway:18001 | ||
- name: CONFIG_GRPC_XDS_NODE_ID | ||
value: envoy-ratelimit | ||
- name: GRPC_SERVER_USE_TLS | ||
value: "true" | ||
- name: GRPC_SERVER_TLS_CERT | ||
value: /certs/tls.crt | ||
- name: GRPC_SERVER_TLS_KEY | ||
value: /certs/tls.key | ||
- name: GRPC_SERVER_TLS_CA_CERT | ||
value: /certs/ca.crt | ||
- name: CONFIG_GRPC_XDS_SERVER_USE_TLS | ||
value: "true" | ||
- name: CONFIG_GRPC_XDS_CLIENT_TLS_CERT | ||
value: /certs/tls.crt | ||
- name: CONFIG_GRPC_XDS_CLIENT_TLS_KEY | ||
value: /certs/tls.key | ||
- name: CONFIG_GRPC_XDS_SERVER_TLS_CACERT | ||
value: /certs/ca.crt | ||
- name: FORCE_START_WITHOUT_INITIAL_CONFIG | ||
value: "true" | ||
- name: REDIS_SOCKET_TYPE | ||
value: tcp | ||
- name: REDIS_URL | ||
value: redis.redis.svc:6379 | ||
- name: USE_PROMETHEUS | ||
value: "true" | ||
- name: PROMETHEUS_ADDR | ||
value: :19001 | ||
- name: PROMETHEUS_MAPPER_YAML | ||
value: /etc/statsd-exporter/conf.yaml | ||
image: envoyproxy/ratelimit:master | ||
imagePullPolicy: IfNotPresent | ||
name: envoy-ratelimit | ||
ports: | ||
- containerPort: 8081 | ||
name: grpc | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 1 | ||
httpGet: | ||
path: /healthcheck | ||
port: 8080 | ||
scheme: HTTP | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
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 | ||
startupProbe: | ||
failureThreshold: 30 | ||
httpGet: | ||
path: /healthcheck | ||
port: 8080 | ||
scheme: HTTP | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /certs | ||
name: certs | ||
readOnly: true | ||
- mountPath: /etc/statsd-exporter | ||
name: statsd-exporter-config | ||
readOnly: true | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
serviceAccountName: envoy-ratelimit | ||
terminationGracePeriodSeconds: 300 | ||
volumes: | ||
- name: certs | ||
secret: | ||
defaultMode: 420 | ||
secretName: envoy-rate-limit | ||
- configMap: | ||
defaultMode: 420 | ||
name: statsd-exporter-config | ||
optional: true | ||
name: statsd-exporter-config | ||
status: {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can L195 be removed ? since L192 is already setting it
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.
So
maps.Copy(dest, src)
overwrites keys existing in both maps with thesrc
value. I want to make sure noone can override one of the selector labels from therateLimitLabels
, so I'm doing the last maps.Copy to overwrite with the selector labels in case someone added one of those labels in their values.Also the destination map must not be nil so I cannot do something like:
as it will fail if no pod labels are provided.
It looks a bit funny, I just didn't want to implement a function that merges two maps, but maybe it's worth it for clarity's sake. Let me know if you think so.
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 thats a good way to ensure the labels can't be overridden
nit: this as a code comment would be helpful so the next dev gets the "why"