|
| 1 | +# Demo |
| 2 | + |
| 3 | +How to load plugins to Kafka Connect installations. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +To run the demo, you need: |
| 8 | +- Docker compose |
| 9 | +- `curl` |
| 10 | +- `jq` |
| 11 | + |
| 12 | +## Demo |
| 13 | + |
| 14 | +To install transforms into a Kafka Connect installation, it needs: |
| 15 | + |
| 16 | +- Build `transforms-for-apache-kafka-connect` libraries |
| 17 | +- Add libraries to Kafka Connect nodes |
| 18 | +- Configure Kafka Connect `plugin.path` |
| 19 | + |
| 20 | +### Build `transforms-for-apache-kafka-connect` libraries |
| 21 | + |
| 22 | +To build libraries, use `gradlew installDist` command. |
| 23 | +e.g. Dockerfile build: |
| 24 | + |
| 25 | +```dockerfile |
| 26 | +FROM eclipse-temurin:11-jdk AS base |
| 27 | + |
| 28 | +ADD ./ transforms |
| 29 | +WORKDIR transforms |
| 30 | + |
| 31 | +RUN ./gradlew installDist |
| 32 | +``` |
| 33 | + |
| 34 | +This generates the set of libraries to be installed in Kafka Connect workers. |
| 35 | + |
| 36 | +### Add libraries to Kafka Connect nodes |
| 37 | + |
| 38 | +Copy the directory with libraries into your Kafka Connect nodes. |
| 39 | +e.g. add directory to Docker images: |
| 40 | + |
| 41 | +```dockerfile |
| 42 | +FROM confluentinc/cp-kafka-connect:7.3.3 |
| 43 | + |
| 44 | +COPY --from=base /transforms/build/install/transforms-for-apache-kafka-connect /transforms |
| 45 | +``` |
| 46 | + |
| 47 | +### Configure Kafka Connect `plugin.path` |
| 48 | + |
| 49 | +On Kafka Connect configuration file, set `plugin.path` to indicate where to load plugins from, |
| 50 | +e.g. with Docker compose: |
| 51 | + |
| 52 | +```yaml |
| 53 | +connect: |
| 54 | + # ... |
| 55 | + environment: |
| 56 | + # ... |
| 57 | + CONNECT_PLUGIN_PATH: /usr/share/java,/transforms # /transforms added on Dockerfile build |
| 58 | +``` |
| 59 | +
|
| 60 | +## Running |
| 61 | +
|
| 62 | +1. Build docker images: `make build` or `docker compose build` |
| 63 | +2. Start environment: `make up` or `docker compose up -d` |
| 64 | +3. Test connect plugins are loaded: `make test` |
| 65 | + |
| 66 | +Sample response: |
| 67 | +```json lines |
| 68 | +{ |
| 69 | + "class": "io.aiven.kafka.connect.transforms.ConcatFields$Key", |
| 70 | + "type": "transformation" |
| 71 | +} |
| 72 | +{ |
| 73 | + "class": "io.aiven.kafka.connect.transforms.ConcatFields$Value", |
| 74 | + "type": "transformation" |
| 75 | +} |
| 76 | +{ |
| 77 | + "class": "io.aiven.kafka.connect.transforms.ExtractTimestamp$Key", |
| 78 | + "type": "transformation" |
| 79 | +} |
| 80 | +{ |
| 81 | + "class": "io.aiven.kafka.connect.transforms.ExtractTimestamp$Value", |
| 82 | + "type": "transformation" |
| 83 | +} |
| 84 | +{ |
| 85 | + "class": "io.aiven.kafka.connect.transforms.ExtractTopic$Key", |
| 86 | + "type": "transformation" |
| 87 | +} |
| 88 | +{ |
| 89 | + "class": "io.aiven.kafka.connect.transforms.ExtractTopic$Value", |
| 90 | + "type": "transformation" |
| 91 | +} |
| 92 | +{ |
| 93 | + "class": "io.aiven.kafka.connect.transforms.FilterByFieldValue$Key", |
| 94 | + "type": "transformation" |
| 95 | +} |
| 96 | +{ |
| 97 | + "class": "io.aiven.kafka.connect.transforms.FilterByFieldValue$Value", |
| 98 | + "type": "transformation" |
| 99 | +} |
| 100 | +{ |
| 101 | + "class": "io.aiven.kafka.connect.transforms.Hash$Key", |
| 102 | + "type": "transformation" |
| 103 | +} |
| 104 | +{ |
| 105 | + "class": "io.aiven.kafka.connect.transforms.Hash$Value", |
| 106 | + "type": "transformation" |
| 107 | +} |
| 108 | +{ |
| 109 | + "class": "io.aiven.kafka.connect.transforms.MakeTombstone", |
| 110 | + "type": "transformation" |
| 111 | +} |
| 112 | +{ |
| 113 | + "class": "io.aiven.kafka.connect.transforms.TombstoneHandler", |
| 114 | + "type": "transformation" |
| 115 | +} |
| 116 | +``` |
0 commit comments