|
1 | | -As the README describes, you can reuse the Docker daemon from Minikube with eval $(minikube docker-env). |
2 | | - |
3 | | -So to use an image without uploading it, you can follow these steps: |
4 | | - |
5 | | -Set the environment variables with eval $(minikube docker-env) |
6 | | -Build the image with the Docker daemon of Minikube (eg docker build -t my-image .) |
7 | | -Set the image in the pod spec like the build tag (eg my-image) |
8 | | -Set the imagePullPolicy to Never, otherwise Kubernetes will try to download the image. |
9 | | -Important note: You have to run eval $(minikube docker-env) on each terminal you want to use, since it only sets the environment variables for the current shell session |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | -/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "nbBg8G4DkR83Xs" |
15 | | - |
16 | | -select name from sys.databases |
17 | | -go |
18 | | - |
19 | | -/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "nbBg8G4DkR83Xs" |
20 | | -USE AdventureWorks |
21 | | -GO |
22 | | -EXEC sys.sp_cdc_enable_db |
23 | | -GO |
24 | | - |
25 | | -Deploying a connector: |
26 | | - |
27 | | -curl -X POST -H "Content-Type: application/json" --data @config.json http://localhost:8083/connectors |
28 | | - |
29 | | -Connect REST API Docs: |
30 | | -https://docs.confluent.io/platform/current/connect/references/restapi.html |
31 | | - |
32 | | - |
33 | | -curl -X POST -H "Content-Type: application/json" https://localhost:8083/connectors |
34 | | - |
35 | | - |
36 | | -https://debezium.io/documentation/reference/1.0/connectors/sqlserver.html |
37 | | - |
38 | | - |
39 | | --- ==== |
40 | | --- Enable Database for CDC template |
41 | | --- ==== |
42 | | -USE MyDB |
43 | | -GO |
44 | | -EXEC sys.sp_cdc_enable_db |
45 | | -GO |
46 | | - |
47 | | --- ========= |
48 | | --- Enable a Table Specifying Filegroup Option Template |
49 | | --- ========= |
50 | | -USE MyDB |
51 | | -GO |
52 | | - |
53 | | -EXEC sys.sp_cdc_enable_table |
54 | | -@source_schema = N'dbo', |
55 | | -@source_name = N'Person', |
56 | | -@role_name = N'MyRole', |
57 | | -@filegroup_name = N'MyDB_CT', |
58 | | -@supports_net_changes = 0 |
59 | | -GO |
60 | | - |
61 | | -sqlcmd -S myServer\instanceName -i C:\myScript.sql |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
| 1 | +## Custom Connect Image / Debezium SQL Server |
| 2 | +In this example we go through the following process: |
| 3 | + |
| 4 | +* Build a 'custom' kafka connect image with [Debezium](https://debezium.io/) plug-in, and make available to the internal (minikube) kubernetes cluster |
| 5 | +* Initiate a SQLServer stub populated with the traditional '[AdventureWorks](https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver15&tabs=ssms)' database, and enable [CDC](https://en.wikipedia.org/wiki/Change_data_capture) on select tables |
| 6 | +* Deploy a connector via a cURL command |
| 7 | +* Observe how changes to CDC enabled tables will trigger events in Kafka |
| 8 | + |
| 9 | +NOTE: For ease of readability, we will simply reference the scripts that perform the actions of the following stages. For better understanding of what is actually being done, please review the scripts themselves which will have their own comments/notations. **Assumptions are that you will be running all commands from the present directory** |
| 10 | + |
| 11 | +### Building the custom docker image |
| 12 | +The Dockerfile installs a custom plugin with the following line: `RUN confluent-hub install --no-prompt debezium/debezium-connector-sqlserver:1.6.0`. To build, run: |
| 13 | + |
| 14 | +```shell |
| 15 | +./build-inside.sh |
| 16 | +``` |
| 17 | +### Deploy CRDs |
| 18 | +Deploy the CRDS using the standard way: |
| 19 | +```shell |
| 20 | +kubectl apply -k ../../kustomize/crds |
| 21 | +``` |
| 22 | +### Deploy Confluent Operator and Confluent Services |
| 23 | +Deploy the confluent operator and services: |
| 24 | +```shell |
| 25 | +kubectl apply -k . |
| 26 | +``` |
| 27 | +### Enable CDC on 'person' table of AdventureWorks Database |
| 28 | +CDC needs to be enabled on a table by table basis. This table is also referenced in the prod-mssql-connnector.json file. |
| 29 | +```shell |
| 30 | +./enable_cdc.sh |
| 31 | +Context "minikube" modified. |
| 32 | +Changed database context to 'AdventureWorks'. |
| 33 | +Job 'cdc.AdventureWorks_capture' started successfully. |
| 34 | +Job 'cdc.AdventureWorks_cleanup' started successfully. |
| 35 | +``` |
| 36 | +### Deploy Debezium Connector |
| 37 | +A curl request is sent to the 'connect pod' to install the connector. |
| 38 | +```shell |
| 39 | +./deploy_connector.sh |
| 40 | +``` |
| 41 | + |
| 42 | +At this stage, if you log onto Control Center, you should see a running connector: |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +### Update CDC enabled 'Person' table |
| 47 | +Now we will send a SQL Command that will update all users in the person.Person table on the AdventureWorks database: |
| 48 | + |
| 49 | +```shell |
| 50 | +./update_person.sh |
| 51 | +Context "minikube" modified. |
| 52 | +Changed database context to 'AdventureWorks'. |
| 53 | + |
| 54 | +(19972 rows affected) |
| 55 | +``` |
| 56 | +If you observe the automatically created topic `adventureworks-connect.Person.Person` you will see the update event messages streaming through |
| 57 | + |
| 58 | + |
| 59 | + |
0 commit comments