Skip to content

Commit e919456

Browse files
committed
Starts scripting, but the API call gets 403 for anonymous user
1 parent b7f95d2 commit e919456

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

10broker-config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ data:
1111
export KAFKA_BROKER_ID=${HOSTNAME##*-}
1212
sed -i "s/\${KAFKA_BROKER_ID}/$KAFKA_BROKER_ID/" /etc/kafka/server.properties
1313
14+
PODNAME=$HOSTNAME
15+
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
16+
17+
# todo add curl to kafka image, switch to a curl image for init or write the whole lookup in java
18+
hash curl 2>/dev/null || { apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install curl -y --no-install-recommends; }
19+
20+
API=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api
21+
AUTH="--cacert /run/secrets/kubernetes.io/serviceaccount/ca.crt --header \"Authorization: Bearer $(cat /run/secrets/kubernetes.io/serviceaccount/token)\""
22+
23+
curl -s $AUTH $API/namespaces/kafka/pods/$PODNAME -I --fail-early || {
24+
echo "Access problems. Could be RBAC."
25+
}
26+
1427
server.properties: |-
1528
# Licensed to the Apache Software Foundation (ASF) under one or more
1629
# contributor license agreements. See the NOTICE file distributed with

0 commit comments

Comments
 (0)