Created
January 29, 2024 14:24
-
-
Save arov00/32822162ebd32763a2aa78cc8ec07a4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the XRD (composite resource definition). To view the corresponding composition, scroll further down. | |
apiVersion: apiextensions.crossplane.io/v1 | |
kind: CompositeResourceDefinition | |
metadata: | |
name: mysqlcdcs.spoud.io | |
spec: | |
group: spoud.io | |
names: | |
kind: MySqlCDC | |
plural: mysqlcdcs | |
versions: | |
- name: v1alpha1 | |
schema: | |
openAPIV3Schema: | |
type: object | |
properties: | |
spec: | |
type: object | |
properties: | |
databaseHostname: | |
type: string | |
databasePort: | |
type: integer | |
default: 3306 | |
databaseUser: | |
type: string | |
databasePassword: | |
type: string | |
databaseName: | |
type: string | |
required: | |
- databaseHostname | |
- databaseUser | |
- databasePassword | |
- databaseName | |
served: true | |
referenceable: true | |
claimNames: | |
kind: MySqlCDCClaim | |
plural: mysqlcdcclaims | |
--- | |
apiVersion: apiextensions.crossplane.io/v1 | |
kind: Composition | |
metadata: | |
name: mysqlcdc-composition | |
spec: | |
patchSets: | |
- name: name-patchset | |
patches: | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.metadata.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
resources: | |
- name: connect-user | |
base: | |
apiVersion: kubernetes.crossplane.io/v1alpha1 | |
kind: Object | |
metadata: | |
name: connect-user-xxx | |
spec: | |
providerConfigRef: | |
name: kubernetes-provider | |
forProvider: | |
manifest: | |
apiVersion: kafka.strimzi.io/v1beta2 | |
kind: KafkaUser | |
metadata: | |
namespace: kafka | |
name: connect-user-xxx | |
labels: | |
strimzi.io/cluster: poc-cluster # for now, let's use the same cluster for everything | |
spec: | |
authentication: | |
type: scram-sha-512 | |
authorization: | |
type: simple | |
acls: | |
- resource: | |
type: topic | |
name: "*" | |
patternType: prefix | |
operations: | |
- Describe | |
- Read | |
- Write | |
- Create | |
- Delete | |
host: "*" | |
- resource: | |
type: group | |
name: "*" | |
patternType: prefix | |
operations: | |
- Read | |
host: "*" | |
patches: | |
# Name patches | |
- type: PatchSet | |
patchSetName: name-patchset | |
- type: CombineFromComposite | |
toFieldPath: metadata.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-user" | |
variables: | |
- fromFieldPath: metadata.name | |
# ACL patches | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.authorization.acls[0].resource.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.authorization.acls[1].resource.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
- name: connect-cluster | |
base: | |
apiVersion: kubernetes.crossplane.io/v1alpha1 | |
kind: Object | |
metadata: | |
name: connect-cluster-xxx # patch | |
spec: | |
providerConfigRef: | |
name: kubernetes-provider | |
forProvider: | |
manifest: | |
apiVersion: kafka.strimzi.io/v1beta2 | |
kind: KafkaConnect | |
metadata: | |
namespace: kafka | |
name: connect-cluster-xxx # patch | |
annotations: | |
strimzi.io/use-connector-resources: "true" | |
spec: | |
version: 3.6.0 | |
replicas: 1 | |
bootstrapServers: poc-cluster-kafka-bootstrap:9093 # for now, let's use the same kafka cluster for everything | |
authentication: | |
type: scram-sha-512 | |
username: connect-user # patch | |
passwordSecret: | |
secretName: connect-user # patch | |
password: password | |
tls: | |
trustedCertificates: | |
- secretName: poc-cluster-cluster-ca-cert | |
certificate: ca.crt | |
externalConfiguration: | |
env: | |
- name: MY_JAAS_CONFIG | |
valueFrom: | |
secretKeyRef: | |
name: connect-user # patch | |
key: sasl.jaas.config | |
config: | |
group.id: connect-cluster-xxx # patch | |
offset.storage.topic: connect-cluster-xxx-offsets # patch | |
config.storage.topic: connect-cluster-xxx-configs # patch | |
status.storage.topic: connect-cluster-xxx-status # patch | |
# -1 means it will use the default replication factor configured in the broker | |
config.storage.replication.factor: -1 | |
offset.storage.replication.factor: -1 | |
status.storage.replication.factor: -1 | |
connector.client.config.override.policy: All | |
config.providers: env | |
config.providers.env.class: org.apache.kafka.common.config.provider.EnvVarConfigProvider | |
build: | |
output: | |
type: docker | |
# This image will last only for 8 hours. | |
image: ttl.sh/connect-example-3.6.0:8h | |
plugins: | |
- name: debezium-connector-mysql | |
artifacts: | |
- type: maven | |
group: io.debezium | |
artifact: debezium-connector-mysql | |
version: 2.4.1.Final | |
patches: | |
# Name patches | |
- type: PatchSet | |
patchSetName: name-patchset | |
- type: CombineFromComposite | |
toFieldPath: metadata.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-cluster" | |
variables: | |
- fromFieldPath: metadata.name | |
# User patches | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.externalConfiguration.env[0].valueFrom.secretKeyRef.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.authentication.username | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.authentication.passwordSecret.secretName | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
# Config patches | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.config["group.id"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.config["offset.storage.topic"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-offsets" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.config["config.storage.topic"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-config" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.config["status.storage.topic"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-status" | |
variables: | |
- fromFieldPath: metadata.name | |
- name: mysql-cdc-connector | |
patches: | |
# Name patches | |
- type: PatchSet | |
patchSetName: name-patchset | |
- type: CombineFromComposite | |
toFieldPath: metadata.name | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-connector" | |
variables: | |
- fromFieldPath: metadata.name | |
# Connect cluster reference | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.metadata.labels["strimzi.io/cluster"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
# Config patches | |
- fromFieldPath: spec.databaseHostname | |
toFieldPath: spec.forProvider.manifest.spec.config["database.hostname"] | |
- fromFieldPath: spec.databasePort | |
toFieldPath: spec.forProvider.manifest.spec.config["database.port"] | |
- fromFieldPath: spec.databaseUser | |
toFieldPath: spec.forProvider.manifest.spec.config["database.user"] | |
- fromFieldPath: spec.databasePassword | |
toFieldPath: spec.forProvider.manifest.spec.config["database.password"] | |
- fromFieldPath: spec.databaseName | |
toFieldPath: spec.forProvider.manifest.spec.config["database.include.list"] | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.config["topic.prefix"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s" | |
variables: | |
- fromFieldPath: metadata.name | |
- type: CombineFromComposite | |
toFieldPath: spec.forProvider.manifest.spec.config["schema.history.internal.kafka.topic"] | |
combine: | |
strategy: string | |
string: | |
fmt: "mysql-cdc-connect-%s-schema-history" | |
variables: | |
- fromFieldPath: metadata.name | |
base: | |
apiVersion: kubernetes.crossplane.io/v1alpha1 | |
kind: Object | |
metadata: | |
name: connect-cluster-xxx # patch | |
spec: | |
providerConfigRef: | |
name: kubernetes-provider | |
forProvider: | |
manifest: | |
apiVersion: kafka.strimzi.io/v1beta2 | |
kind: KafkaConnector | |
metadata: | |
name: manual-debezium-connector # patch | |
namespace: kafka | |
labels: | |
# The strimzi.io/cluster label identifies the KafkaConnect instance | |
# in which to create this connector. That KafkaConnect instance | |
# must have the strimzi.io/use-connector-resources annotation | |
# set to true. | |
strimzi.io/cluster: mysql-cdc-connect # patch | |
spec: | |
class: io.debezium.connector.mysql.MySqlConnector | |
tasksMax: 1 | |
# Config more or less taken directly from the Debezium tutorial | |
config: { | |
"database.hostname": "mysql.tt-27-project.svc.cluster.local", # patch | |
"database.port": "3306", # patch | |
"database.user": "root", # patch | |
"database.password": "8R4fR0hexi", # patch | |
"database.server.id": "184054", | |
"topic.prefix": "dbserver1", # patch | |
"database.include.list": "inventory", # patch | |
"schema.history.internal.kafka.bootstrap.servers": "poc-cluster-kafka-bootstrap:9092", | |
"schema.history.internal.kafka.topic": "schema-changes.inventory", # patch | |
"schema.history.internal.consumer.sasl.mechanism": "SCRAM-SHA-512", | |
"schema.history.internal.consumer.sasl.jaas.config": "${env:MY_JAAS_CONFIG}", # patch | |
"schema.history.internal.consumer.security.protocol": "SASL_PLAINTEXT", | |
"schema.history.internal.producer.sasl.mechanism": "SCRAM-SHA-512", | |
"schema.history.internal.producer.sasl.jaas.config": "${env:MY_JAAS_CONFIG}", # patch | |
"schema.history.internal.producer.security.protocol": "SASL_PLAINTEXT", | |
} | |
compositeTypeRef: | |
apiVersion: spoud.io/v1alpha1 | |
kind: MySqlCDC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment