Skip to content

Commit 84be537

Browse files
committed
Deploy a SASL_PLAIN Kafka listener & test notifications against it
Issue: ZENKO-5106 Signed-off-by: Thomas Flament <[email protected]>
1 parent 13c5e85 commit 84be537

File tree

7 files changed

+63
-1
lines changed

7 files changed

+63
-1
lines changed

.github/scripts/end2end/configs/notification_destinations.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,21 @@ spec:
2323
host: ${NOTIF_KAFKA_HOST}
2424
port: ${NOTIF_KAFKA_PORT}
2525
destinationTopic: ${NOTIF_ALT_DEST_TOPIC}
26+
27+
---
28+
29+
apiVersion: zenko.io/v1alpha2
30+
kind: ZenkoNotificationTarget
31+
metadata:
32+
name: ${NOTIF_AUTH_DEST_NAME}
33+
labels:
34+
app.kubernetes.io/instance: ${ZENKO_NAME}
35+
spec:
36+
type: kafka
37+
host: ${NOTIF_KAFKA_HOST}
38+
port: ${NOTIF_KAFKA_PORT}
39+
destinationTopic: ${NOTIF_AUTH_DEST_TOPIC}
40+
auth: basic
41+
basic:
42+
username: ${NOTIF_AUTH_DEST_USERNAME}
43+
password: ${NOTIF_AUTH_DEST_PASSWORD}

.github/scripts/end2end/configure-e2e-ctst.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@ KAFKA_HOST_PORT=${KAFKA_HOST_PORT:1:-1}
1111
export NOTIF_KAFKA_HOST=${KAFKA_HOST_PORT%:*}
1212
export NOTIF_KAFKA_PORT=${KAFKA_HOST_PORT#*:}
1313

14+
# Add an extra SASL_PLAIN Kafka listener, to support testing authenticated Kafka for bucket notifications
15+
KAFKA_CLUSTER="${ZENKO_NAME}-base-queue"
16+
KAFKA_CONFIG=$(kubectl get kafkacluster "$KAFKA_CLUSTER" -o jsonpath='{.spec.readOnlyConfig}')
17+
KAFKA_CONFIG="$KAFKA_CONFIG"$(cat << 'EOF'
18+
19+
sasl.enabled.mechanisms=PLAIN
20+
listener.name.auth.plain.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
21+
username="admin" \
22+
password="admin-secret" \
23+
user_admin="admin-secret";
24+
25+
EOF
26+
)
27+
KAFKA_PATCH=$(jq -n --arg config "$KAFKA_CONFIG" '[
28+
{"op": "add", "path": "/spec/listenersConfig/internalListeners/-", "value": {"containerPort": 9094, "name": "auth", "type": "sasl_plaintext", "usedForInnerBrokerCommunication": false}},
29+
{"op": "replace", "path": "/spec/readOnlyConfig", "value": $config}
30+
]')
31+
kubectl patch kafkacluster "$KAFKA_CLUSTER" --type='json' -p="$KAFKA_PATCH"
32+
kubectl wait --for=jsonpath='{.status.state}'=ClusterRunning --timeout 10m kafkacluster "$KAFKA_CLUSTER"
33+
1434
UUID=$(kubectl get secret -l app.kubernetes.io/name=backbeat-config,app.kubernetes.io/instance=end2end \
1535
-o jsonpath='{.items[0].data.config\.json}' | base64 -di | jq .extensions.replication.topic)
1636
UUID=${UUID%.*}
@@ -48,6 +68,7 @@ kubectl run kafka-topics \
4868
--command -- bash -c \
4969
"kafka-topics.sh --create --topic $NOTIF_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
5070
kafka-topics.sh --create --topic $NOTIF_ALT_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
71+
kafka-topics.sh --create --topic $NOTIF_AUTH_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
5172
kafka-topics.sh --create --topic $AZURE_ARCHIVE_STATUS_TOPIC --partitions 10 --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
5273
kafka-topics.sh --create --topic $AZURE_ARCHIVE_STATUS_TOPIC_2_NV --partitions 10 --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
5374
kafka-topics.sh --create --topic $AZURE_ARCHIVE_STATUS_TOPIC_2_V --partitions 10 --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \

.github/scripts/end2end/configure-e2e.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ kubectl run kafka-topics \
6767
"kafka-topics.sh --create --topic $UUID.backbeat-replication-replay-0 --partitions 5 --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
6868
kafka-topics.sh --create --topic $UUID.backbeat-data-mover --partitions 5 --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
6969
kafka-topics.sh --create --topic $NOTIF_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
70-
kafka-topics.sh --create --topic $NOTIF_ALT_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists "
70+
kafka-topics.sh --create --topic $NOTIF_ALT_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists ; \
71+
kafka-topics.sh --create --topic $NOTIF_AUTH_DEST_TOPIC --bootstrap-server $KAFKA_HOST_PORT --if-not-exists "
7172

7273
kubectl run ${POD_NAME} \
7374
--image ${E2E_IMAGE} \

.github/scripts/end2end/run-e2e-ctst.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ WORLD_PARAMETERS="$(jq -c <<EOF
9393
"NotificationDestinationTopic":"${NOTIF_DEST_TOPIC}",
9494
"NotificationDestinationAlt":"${NOTIF_ALT_DEST_NAME}",
9595
"NotificationDestinationTopicAlt":"${NOTIF_ALT_DEST_TOPIC}",
96+
"NotificationDestinationAuth":"${NOTIF_AUTH_DEST_NAME}",
97+
"NotificationDestinationTopicAuth":"${NOTIF_AUTH_DEST_TOPIC}",
98+
"NotificationDestinationAuthUsername":"${NOTIF_AUTH_DEST_USERNAME}",
99+
"NotificationDestinationAuthPassword":"${NOTIF_AUTH_DEST_PASSWORD}",
96100
"KafkaExternalIps": "${KAFKA_EXTERNAL_IP:-}",
97101
"PrometheusService":"${PROMETHEUS_NAME}-operated.default.svc.cluster.local",
98102
"KafkaHosts":"${KAFKA_HOST_PORT}",

.github/workflows/end2end.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ env:
9595
NOTIF_DEST_TOPIC: "destination-topic-1"
9696
NOTIF_ALT_DEST_NAME: "destination2"
9797
NOTIF_ALT_DEST_TOPIC: "destination-topic-2"
98+
NOTIF_AUTH_DEST_NAME: "destination3"
99+
NOTIF_AUTH_DEST_TOPIC: "destination-topic-3"
100+
NOTIF_AUTH_DEST_USERNAME: "admin"
101+
NOTIF_AUTH_DEST_PASSWORD: "admin-secret"
98102
SUBDOMAIN: "zenko.local"
99103
DR_SUBDOMAIN: "dr.zenko.local"
100104
SKOPEO_PATH: "/tmp"

tests/ctst/steps/notifications.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ Given('two notification destinations', function (this: Zenko) {
128128
this.addToSaved('notificationDestinations', notificationDestinations);
129129
});
130130

131+
Given('one authenticated notification destination', function (this: Zenko) {
132+
const notificationDestinations = [];
133+
notificationDestinations.push({
134+
destinationName: this.parameters.NotificationDestinationAuth,
135+
topic: this.parameters.NotificationDestinationAuthTopic,
136+
hosts: this.parameters.KafkaHosts,
137+
});
138+
this.addToSaved('notificationDestinations', notificationDestinations);
139+
});
140+
131141
When('i subscribe to {string} notifications for destination {int}',
132142
async function (this: Zenko, notificationType: string, destination: number) {
133143
const notificationsPerDestination : Record<string, string[]> = {};

tests/ctst/world/Zenko.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export interface ZenkoWorldParameters extends ClientOptions {
5555
NotificationDestinationTopic: string;
5656
NotificationDestinationAlt: string;
5757
NotificationDestinationTopicAlt: string;
58+
NotificationDestinationAuth: string;
59+
NotificationDestinationTopicAuth: string;
60+
NotificationDestinationAuthUsername: string;
61+
NotificationDestinationAuthPassword: string;
5862
KafkaExternalIps: string;
5963
KafkaHosts: string;
6064
PrometheusService: string;

0 commit comments

Comments
 (0)