Skip to content

Commit 4d081c6

Browse files
committed
updated script to allow for global options
1 parent 124676a commit 4d081c6

File tree

7 files changed

+54
-25
lines changed

7 files changed

+54
-25
lines changed

stable/quotas/confluent/kafka.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: platform.confluent.io/v1beta1
2+
kind: Kafka
3+
metadata:
4+
name: kafka
5+
spec:
6+
configOverrides:
7+
server:
8+
- confluent.schema.registry.url=https://schemaregistry:8081
9+
- listener.name.internal.plain.sasl.server.callback.handler.class=io.confluent.security.auth.provider.ldap.LdapAuthenticateCallbackHandler
10+
- listener.name.external.plain.sasl.server.callback.handler.class=io.confluent.security.auth.provider.ldap.LdapAuthenticateCallbackHandler
11+
- listener.name.replication.plain.sasl.server.callback.handler.class=io.confluent.security.auth.provider.ldap.LdapAuthenticateCallbackHandler
12+
- authorizer.class.name=io.confluent.kafka.security.authorizer.ConfluentServerAuthorizer
13+
- confluent.authorizer.access.rule.providers=ZK_ACL,CONFLUENT
14+
- quota.consumer.default = 1024
15+
- quota.producer.default = 1024
16+
- quota.window.num = 11
17+
- quota.window.size.seconds = 1
18+
19+

stable/quotas/kustomization.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ namespace: sandbox
44
resources:
55
- namespace.yaml
66
- ../../base/cfk-components/confluent-rbac
7-
7+
- quota-manager
8+
patchesStrategicMerge:
9+
- confluent/kafka.yaml

stable/quotas/quota-manager/definition/apply-quotas-script.sh renamed to stable/quotas/quota-manager/default/apply-quotas-script.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
2-
32
quota_definition="/tmp/quota-definition/quotas.yaml"
4-
53
for i in $(yq '.platform.quotas | keys' < $quota_definition); do
64
principal="${i:0}"
75
if [[ "$principal" != "-" ]]; then
@@ -20,16 +18,25 @@ for i in $(yq '.platform.quotas | keys' < $quota_definition); do
2018
fi
2119
# Removes white space and the last trailing comma
2220
config=$(echo $config_string | tr -d " \t\n\r" | rev | cut -c 2- | rev)
23-
set -x
2421
echo $config
25-
26-
kafka-configs \
27-
--bootstrap-server kafka:9071 \
28-
--alter \
29-
--entity-type users \
30-
--entity-name $principal \
31-
--command-config /tmp/config-properties/kafka.properties \
32-
--add-config "$config"
22+
set -x
23+
if [[ "$principal" == "global" ]]; then
24+
kafka-configs \
25+
--bootstrap-server kafka:9071 \
26+
--alter \
27+
--entity-type users \
28+
--entity-default \
29+
--command-config /tmp/config-properties/kafka.properties \
30+
--add-config "$config"
31+
else
32+
kafka-configs \
33+
--bootstrap-server kafka:9071 \
34+
--alter \
35+
--entity-type users \
36+
--entity-name $principal \
37+
--command-config /tmp/config-properties/kafka.properties \
38+
--add-config "$config"
39+
fi
3340
set +x
3441
fi
3542
done

stable/quotas/quota-manager/definition/quotas.yaml renamed to stable/quotas/quota-manager/default/quotas.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
---
22
platform:
33
quotas:
4-
app-0:
4+
global:
55
producer_byte_rate: 1024
66
consumer_byte_rate: 1024
77
request_percentage: 50.0
8+
app-0:
9+
producer_byte_rate: 4096
10+
consumer_byte_rate: 2048
11+
request_percentage: 50.0
812
app-2:
913
producer_byte_rate: 2048
1014
consumer_byte_rate: 2048

stable/quotas/quota-manager/kustomization.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ resources:
44
configMapGenerator:
55
- name: oso-quota-example
66
files:
7-
- ./definition/quotas.yaml
7+
- ./default/quotas.yaml
88
- name: config-properties
99
files:
10-
- ./definition/kafka.properties
10+
- ./default/kafka.properties
1111
- name: apply-quota-script
1212
files:
13-
- ./definition/apply-quotas-script.sh
13+
- ./default/apply-quotas-script.sh
1414
generatorOptions:
1515
disableNameSuffixHash: true

stable/quotas/quota-manager/quota-manager.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
---
2-
apiVersion: apps/v1
3-
kind: StatefulSet
2+
apiVersion: batch/v1
3+
kind: Job
44
metadata:
55
name: quota-manager
66
namespace: sandbox
77
spec:
8-
serviceName: quota-manager
9-
podManagementPolicy: OrderedReady
10-
replicas: 1
11-
selector:
12-
matchLabels:
13-
app: quota-manager
8+
149
template:
1510
metadata:
1611
labels:
1712
app: quota-manager
1813
spec:
14+
restartPolicy: OnFailure
1915
containers:
2016
- name: quota-manager
2117
image: quota-manager:latest
2218
imagePullPolicy: Never
2319
command:
20+
- /tmp/quotas/apply-quotas-script.sh
2421
# - "sleep"
2522
# - "10000000"
26-
- /tmp/quotas/apply-quotas-script.sh
23+
2724
resources:
2825
requests:
2926
memory: 512Mi # 768Mi

0 commit comments

Comments
 (0)