2
2
title : Integrate Aiven for Apache Kafka® Connect with PostgreSQL using Debezium with mutual TLS
3
3
---
4
4
5
- Integrate Aiven for Apache Kafka Connect with PostgreSQL using Debezium with mutual TLS (mTLS) to enhance security with mutual authentication.
5
+ Integrate Aiven for Apache Kafka® Connect with PostgreSQL using Debezium with mutual TLS (mTLS) to enhance security with mutual authentication.
6
6
7
7
This configuration establishes a secure and efficient data synchronization channel
8
- between Aiven for Apache Kafka Connect and a PostgreSQL database.
8
+ between Aiven for Apache Kafka® Connect and a PostgreSQL database.
9
9
10
10
## Prerequisites
11
11
12
- Before you begin, ensure you have the following:
13
-
14
- - Access to an Aiven for Apache Kafka service with
15
- [ Apache Kafka Connect] ( /docs/products/kafka/kafka-connect/howto/enable-connect )
16
- enabled.
12
+ - Access to an Aiven for Apache Kafka® and Aiven for Apache Kafka® Connect service.
17
13
- Administrative access to a PostgreSQL database with SSL enabled.
18
- - The following SSL certificates and keys obtained from your PostgreSQL database:
19
- - SSL client certificate: The public certificate for client authentication.
20
- - SSL root certificate: The certificate of the Certificate Authority (CA) that signed
21
- the servers' and clients' certificates.
22
- - SSL client key: The client's private key is used to encrypt the data sent to the
23
- server.
24
- For additional details, see
25
- [ Certificate requirements] ( /docs/platform/concepts/tls-ssl-certificates#certificate-requirements ) .
14
+ - The following SSL certificates and keys from your PostgreSQL database:
15
+ - Client certificate: Public certificate for client authentication.
16
+ - Root certificate: Certificate authority (CA) certificate used to sign the server
17
+ and client certificates.
18
+ - Client key: Private key for encrypting data sent to the server.
19
+
20
+ For additional details, see [ Certificate requirements] ( /docs/platform/concepts/tls-ssl-certificates#certificate-requirements ) .
26
21
27
22
### For CloudSQL PostgreSQL databases
28
23
29
- If you're integrating with a CloudSQL database, perform these additional steps only if
30
- they are not already configured:
24
+ If you are using CloudSQL, complete these additional steps if they are not already
25
+ configured:
31
26
32
- - ** IP whitelisting** : Whitelist Aiven's IP addresses to allow connections
33
- from Apache Kafka Connect to reach your CloudSQL database.
34
- - ** Configure WAL and logical decoding** :
35
- - To capture database change events, ` set cloudsql.logical_decoding ` to ` on ` .
36
- - To configure the Write-Ahead Log (WAL) for logical replication, set
37
- ` cloudsql.enable_pglogical ` to` on ` .
38
- - Restart the CloudSQL instance to apply changes.
39
- - ** Activate the ` pgoutput ` extension** : In your
40
- CloudSQL instance, enable the extension Debezium uses for logical decoding:
27
+ - ** Allow Aiven IP addresses** : Whitelist Aiven IP addresses to enable connections
28
+ from Apache Kafka Connect to your CloudSQL instance.
29
+
30
+ - ** Enable WAL and logical decoding** :
31
+ - Set ` cloudsql.logical_decoding ` to ` on ` to capture database change events.
32
+ - Set ` cloudsql.enable_pglogical ` to ` on ` to configure the Write-Ahead Log (WAL)
33
+ for logical replication.
34
+ - Restart the CloudSQL instance to apply the changes.
35
+ - ** Enable the ` pgoutput ` extension**
36
+ In your CloudSQL instance, enable the extension that Debezium uses for logical decoding:
41
37
42
38
``` SQL
43
39
CREATE EXTENSION pgoutput;
44
40
```
45
41
46
- - ** Verify SSL certificates ** : After whitelisting IPs, ensure your SSL configuration is
47
- correct by testing the database connection :
42
+ - ** Verify SSL configuration ** : After whitelisting IP addresses, test the SSL
43
+ connection to ensure your certificates are configured correctly :
48
44
49
45
``` bash
50
46
psql " sslmode=verify-ca \
@@ -57,18 +53,34 @@ they are not already configured:
57
53
dbname=<YOUR_DB_NAME>"
58
54
```
59
55
60
- - ** Set Debezium output plugin** : Use ` pgoutput ` or ` decoderbufs ` as the ` plugin.name ` in
61
- your Debezium connector for logical decoding .
56
+ - ** Set the Debezium output plugin** : Set the ` plugin.name ` field in the connector
57
+ configuration to either ` pgoutput ` or ` decoderbufs ` .
62
58
63
- ::: note
64
- Starting with Debezium 2.5, the `wal2json` plugin is deprecated. You can use
65
- either `pgoutput` or `decoderbufs` as the recommended replacement plugin.
66
- :::
59
+ ::: note
60
+ Starting with Debezium 2.5, the ` wal2json ` plugin is deprecated. Use ` pgoutput ` or
61
+ ` decoderbufs ` as the recommended replacement.
62
+ :::
63
+
64
+ ## Limitations
65
+
66
+ - The integration is not yet available in the Aiven Console. Use the Aiven CLI or Aiven
67
+ API instead.
68
+ - A dedicated Aiven for Apache Kafka® Connect service is required. Enabling Kafka Connect
69
+ within the same Aiven for Apache Kafka® service is not supported for this integration.
70
+ - The ` kafka_connect_postgresql ` integration type is not yet available in the Aiven
71
+ Console.
72
+ - Delivering SSL keys to Aiven for Apache Kafka Connect is asynchronous. There may be a
73
+ delay of up to five minutes between creating the integration and using the keys.
74
+ - Mutual authentication in ` verify-full ` SSL mode is not supported in the Apache Kafka
75
+ setup. The ` verify-ca ` mode remains secure because the Certificate Authority (CA) is
76
+ unique to the instance.
77
+ - For CloudSQL PostgreSQL databases, enable logical decoding and the ` pgoutput `
78
+ extension to ensure replication compatibility.
67
79
68
80
## Variables
69
81
70
- The following table lists the variables for the configuration steps. Replace them with
71
- your actual environment values in the provided code snippets:
82
+ Replace the placeholders in the following table with values from your environment. Use
83
+ these values in the configuration steps and code snippets.
72
84
73
85
| Variable | Description |
74
86
| -------------------------------| ----------------------------------------------------|
@@ -83,8 +95,8 @@ your actual environment values in the provided code snippets:
83
95
84
96
## Configure the integration
85
97
86
- 1 . Verify your existing Aiven for Apache Kafka service is active and accessible.
87
- If you don't have one , create an Apache Kafka cluster using this command :
98
+ 1 . Verify that your Aiven for Apache Kafka® service is active and accessible. If you do
99
+ not have a Kafka service , create one :
88
100
89
101
``` bash
90
102
avn service create < kafka_cluster_name> \
@@ -100,8 +112,9 @@ your actual environment values in the provided code snippets:
100
112
manually create topics before starting the connector.
101
113
:::
102
114
103
- 1. Create an Apache Kafka Connect service and configure it to communicate with your
104
- Aiven for Apache Kafka service:
115
+ 1. Verify that your Aiven for Apache Kafka® Connect service is active and accessible. If
116
+ you do not have one, use the following command to create it and connect it to your
117
+ Kafka service:
105
118
106
119
` ` ` bash
107
120
avn service create < kafka_connect_name> \
@@ -111,10 +124,10 @@ your actual environment values in the provided code snippets:
111
124
--project $PROJECT
112
125
` ` `
113
126
114
- 1. Create an external PostgreSQL integration endpoint to represent your PostgreSQL
115
- database. Use the following JSON configuration and replace the placeholders :
127
+ 1. Create an external PostgreSQL integration endpoint. This endpoint represents your
128
+ PostgreSQL database. Replace the placeholders in the following JSON configuration :
116
129
117
- ` ` ` bash
130
+ ` ` ` bash
118
131
INTEGRATION_CONFIG=$( cat << -END
119
132
{
120
133
"ssl_mode": "verify-ca",
@@ -136,7 +149,7 @@ your actual environment values in the provided code snippets:
136
149
137
150
` ` `
138
151
139
- 1. Retrieve endpoint ID of the integration endpoint you just created using this command :
152
+ 1. Retrieve the ID of the external PostgreSQL integration endpoint :
140
153
141
154
` ` ` bash
142
155
INTEGRATION_ENDPOINT_ID=$(
@@ -146,7 +159,7 @@ your actual environment values in the provided code snippets:
146
159
)
147
160
` ` `
148
161
149
- 1. Connect PostgreSQL endpoint to Apache Kafka Connect:
162
+ 1. Integrate the Apache Kafka® Connect service with the external PostgreSQL endpoint :
150
163
151
164
` ` ` bash
152
165
avn service integration-create \
@@ -157,7 +170,7 @@ your actual environment values in the provided code snippets:
157
170
` ` `
158
171
159
172
1. Create the Debezium connector configuration to monitor your PostgreSQL database.
160
- Replace the placeholders with your PostgreSQL and Apache Kafka Connect information:
173
+ Replace the placeholders with your PostgreSQL and Apache Kafka® Connect information:
161
174
162
175
` ` ` bash
163
176
CONNECTOR_CONFIG=$( cat << -END
@@ -189,7 +202,7 @@ your actual environment values in the provided code snippets:
189
202
--config "$CONNECTOR_CONFIG "
190
203
` ` `
191
204
192
- where,
205
+ Parameters:
193
206
194
207
- ` name` : The connector instance name. For example, ` debezium-postgres-connector` .
195
208
- ` connector.class` : The class of the PostgreSQL connector.
@@ -204,28 +217,14 @@ your actual environment values in the provided code snippets:
204
217
- ` topic.prefix` : The prefix for Kafka topics receiving database change events.
205
218
- ` database.tcpKeepAlive` : If set to ` true` , it prevents database connection timeouts
206
219
during inactivity.
207
- - ` transforms` and ` transforms.unwrap.type` : he data transformations.
220
+ - ` transforms` and ` transforms.unwrap.type` : The data transformations.
208
221
` ExtractNewRecordState` extracts the latest data state. These transformations are
209
222
optional and should be used based on your specific requirements.
210
223
211
224
# # Verification
212
225
213
- Confirm the following after completing the setup :
226
+ After completing the setup, confirm the following :
214
227
215
228
1. Apache Kafka Connect establishes a secure SSL connection with the PostgreSQL database.
216
229
1. Apache Kafka topics exist as expected, whether created automatically or manually.
217
- 1. Data is correctly streaming into topics using the naming pattern
218
- ` {connector_name}.{database_name}.{table_name}` .
219
-
220
- # # Limitations
221
-
222
- - The process of delivering SSL keys to Apache Kafka Connect is asynchronous.
223
- Therefore, a delay of approximately five minutes may occur from the creation of
224
- the integration to the operational use of the keys.
225
- - The Apache Kafka setup does not support mutual authentication in ` verify-full` SSL mode.
226
- However, the ` verify-ca` mode is secure since the Certificate Authority (CA) is
227
- specific to the instance.
228
- - For CloudSQL PostgreSQL databases, ensure logical decoding and the ` pgoutput` extension
229
- are enabled for replication compatibility.
230
- - As of Debezium 2.5, ` wal2json` is deprecated. It is recommended to use ` pgoutput`
231
- or ` decoderbufs` for WAL output plugins.
230
+ 1. Data is streaming into topics using the naming pattern ` {connector_name}.{database_name}.{table_name}` .
0 commit comments