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
1diff --git a/examples/README.md b/examples/README.md
2new file mode 100644
3index 0000000..0ea1490
4--- /dev/null
5+++ b/examples/README.md
6@@ -0,0 +1,55 @@
7+# Running the examples
8+
9+## docker-compose
10+
11+Install `docker-compose` from the Ubuntu archive:
12+
13+```
14+$ sudo apt install -y docker-compose
15+```
16+
17+Call `docker-compose` from the examples directory:
18+
19+```
20+$ docker-compose up -d
21+```
22+
23+You can now access your service on the network used by your docker-compose
24+setup. The default should be `$DIRNAME_default`. If you are in the `examples`
25+directory, you could use this service with:
26+
27+```
28+docker run --rm -it \
29+ --network=examples_default \
30+ ubuntu/kafka:edge \
31+ SOME_KAFKA_BINARY_AND_OPTIONS
32+```
33+
34+and use `kafka:9092` as your kafka server parameter.
35+
36+To stop `docker-compose`, run:
37+
38+```
39+$ docker-compose down
40+```
41+
42+# Microk8s
43+
44+Install microk8s from snap:
45+
46+```
47+$ snap install microk8s --classic
48+```
49+
50+Apply the `kafka-deployment.yml`:
51+
52+```
53+$ microk8s kubectl apply -f kafka-deployment.yml
54+```
55+
56+You can now try your Kafka setup within microk8s. For instance, you could
57+use some of the Kafka shipped binaries with
58+
59+`microk8s kubectl run -it --rm kafka-client --restart=Never --image ubuntu/kafka:edge -- SOME_KAFKA_BINARY_AND_OPTIONS`
60+
61+and use `kafka-service:9092` as your kafka server parameter.
62diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
63new file mode 100644
64index 0000000..2ff529b
65--- /dev/null
66+++ b/examples/docker-compose.yml
67@@ -0,0 +1,15 @@
68+version: '2'
69+
70+services:
71+ kafka:
72+ image: ubuntu/kafka:edge
73+ command: kafka-server-start.sh /etc/kafka/server.properties --override zookeeper.connect=zookeeper:2181
74+ ports:
75+ - '9092:9092'
76+ depends_on:
77+ - zookeeper
78+ zookeeper:
79+ image: ubuntu/kafka:edge
80+ command: zookeeper-server-start.sh /etc/kafka/zookeeper.properties
81+ ports:
82+ - '2181:2181'
83diff --git a/examples/kafka-deployment.yml b/examples/kafka-deployment.yml
84new file mode 100644
85index 0000000..44dc71b
86--- /dev/null
87+++ b/examples/kafka-deployment.yml
88@@ -0,0 +1,70 @@
89+---
90+apiVersion: v1
91+kind: Service
92+metadata:
93+ name: kafka-service
94+ labels:
95+ app: kafka
96+spec:
97+ ports:
98+ - port: 9092
99+ selector:
100+ app: kafka
101+---
102+apiVersion: apps/v1
103+kind: Deployment
104+metadata:
105+ name: kafka-deployment
106+spec:
107+ replicas: 1
108+ selector:
109+ matchLabels:
110+ app: kafka
111+ template:
112+ metadata:
113+ labels:
114+ app: kafka
115+ spec:
116+ containers:
117+ - name: kafka
118+ image: ubuntu/kafka:edge
119+ args: ["kafka-server-start.sh", "/etc/kafka/server.properties", "--override", "zookeeper.connect=zookeeper-service:2181", "--override", "advertised.listeners=PLAINTEXT://kafka-service:9092"]
120+ ports:
121+ - containerPort: 9092
122+ name: kafka
123+ protocol: TCP
124+---
125+apiVersion: v1
126+kind: Service
127+metadata:
128+ name: zookeeper-service
129+ labels:
130+ app: zookeeper
131+spec:
132+ ports:
133+ - port: 2181
134+ selector:
135+ app: zookeeper
136+---
137+apiVersion: apps/v1
138+kind: Deployment
139+metadata:
140+ name: zookeeper-deployment
141+spec:
142+ replicas: 1
143+ selector:
144+ matchLabels:
145+ app: zookeeper
146+ template:
147+ metadata:
148+ labels:
149+ app: zookeeper
150+ spec:
151+ containers:
152+ - name: zookeeper
153+ image: ubuntu/kafka:edge
154+ args: ["zookeeper-server-start.sh", "/etc/kafka/zookeeper.properties"]
155+ ports:
156+ - containerPort: 2181
157+ name: zookeeper
158+ protocol: TCP

Subscribers

People subscribed via source and target branches