Merge ~athos-ribeiro/ubuntu-docker-images/+git/kafka:3.1-22.04-examples into ~ubuntu-docker-images/ubuntu-docker-images/+git/kafka:3.1-22.04

Proposed by Athos Ribeiro
Status: Merged
Merged at revision: 39128b9ea422400ed2f08ec32812f0467aceb65b
Proposed branch: ~athos-ribeiro/ubuntu-docker-images/+git/kafka:3.1-22.04-examples
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/kafka:3.1-22.04
Diff against target: 158 lines (+140/-0)
3 files modified
examples/README.md (+55/-0)
examples/docker-compose.yml (+15/-0)
examples/kafka-deployment.yml (+70/-0)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Approve
Bryce Harrington Pending
Canonical Server Pending
Review via email: mp+418884@code.launchpad.net

Description of the change

Following the pattern of the other OCI images, this MP introduces the docker-compose and the k8s examples on using the new Kafka OCI.

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Athos.

LGTM, +1.

review: Approve
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Thanks, Sergio.

Merged

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/examples/README.md b/examples/README.md
0new file mode 1006440new file mode 100644
index 0000000..0ea1490
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,55 @@
1# Running the examples
2
3## docker-compose
4
5Install `docker-compose` from the Ubuntu archive:
6
7```
8$ sudo apt install -y docker-compose
9```
10
11Call `docker-compose` from the examples directory:
12
13```
14$ docker-compose up -d
15```
16
17You can now access your service on the network used by your docker-compose
18setup. The default should be `$DIRNAME_default`. If you are in the `examples`
19directory, you could use this service with:
20
21```
22docker run --rm -it \
23 --network=examples_default \
24 ubuntu/kafka:edge \
25 SOME_KAFKA_BINARY_AND_OPTIONS
26```
27
28and use `kafka:9092` as your kafka server parameter.
29
30To stop `docker-compose`, run:
31
32```
33$ docker-compose down
34```
35
36# Microk8s
37
38Install microk8s from snap:
39
40```
41$ snap install microk8s --classic
42```
43
44Apply the `kafka-deployment.yml`:
45
46```
47$ microk8s kubectl apply -f kafka-deployment.yml
48```
49
50You can now try your Kafka setup within microk8s. For instance, you could
51use some of the Kafka shipped binaries with
52
53`microk8s kubectl run -it --rm kafka-client --restart=Never --image ubuntu/kafka:edge -- SOME_KAFKA_BINARY_AND_OPTIONS`
54
55and use `kafka-service:9092` as your kafka server parameter.
diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
0new file mode 10064456new file mode 100644
index 0000000..2ff529b
--- /dev/null
+++ b/examples/docker-compose.yml
@@ -0,0 +1,15 @@
1version: '2'
2
3services:
4 kafka:
5 image: ubuntu/kafka:edge
6 command: kafka-server-start.sh /etc/kafka/server.properties --override zookeeper.connect=zookeeper:2181
7 ports:
8 - '9092:9092'
9 depends_on:
10 - zookeeper
11 zookeeper:
12 image: ubuntu/kafka:edge
13 command: zookeeper-server-start.sh /etc/kafka/zookeeper.properties
14 ports:
15 - '2181:2181'
diff --git a/examples/kafka-deployment.yml b/examples/kafka-deployment.yml
0new file mode 10064416new file mode 100644
index 0000000..44dc71b
--- /dev/null
+++ b/examples/kafka-deployment.yml
@@ -0,0 +1,70 @@
1---
2apiVersion: v1
3kind: Service
4metadata:
5 name: kafka-service
6 labels:
7 app: kafka
8spec:
9 ports:
10 - port: 9092
11 selector:
12 app: kafka
13---
14apiVersion: apps/v1
15kind: Deployment
16metadata:
17 name: kafka-deployment
18spec:
19 replicas: 1
20 selector:
21 matchLabels:
22 app: kafka
23 template:
24 metadata:
25 labels:
26 app: kafka
27 spec:
28 containers:
29 - name: kafka
30 image: ubuntu/kafka:edge
31 args: ["kafka-server-start.sh", "/etc/kafka/server.properties", "--override", "zookeeper.connect=zookeeper-service:2181", "--override", "advertised.listeners=PLAINTEXT://kafka-service:9092"]
32 ports:
33 - containerPort: 9092
34 name: kafka
35 protocol: TCP
36---
37apiVersion: v1
38kind: Service
39metadata:
40 name: zookeeper-service
41 labels:
42 app: zookeeper
43spec:
44 ports:
45 - port: 2181
46 selector:
47 app: zookeeper
48---
49apiVersion: apps/v1
50kind: Deployment
51metadata:
52 name: zookeeper-deployment
53spec:
54 replicas: 1
55 selector:
56 matchLabels:
57 app: zookeeper
58 template:
59 metadata:
60 labels:
61 app: zookeeper
62 spec:
63 containers:
64 - name: zookeeper
65 image: ubuntu/kafka:edge
66 args: ["zookeeper-server-start.sh", "/etc/kafka/zookeeper.properties"]
67 ports:
68 - containerPort: 2181
69 name: zookeeper
70 protocol: TCP

Subscribers

People subscribed via source and target branches