|
| 1 | +apiVersion: template.openshift.io/v1 |
| 2 | +kind: Template |
| 3 | +metadata: |
| 4 | + name: example-components-template |
| 5 | +labels: |
| 6 | + template: example-components-template |
| 7 | +objects: |
| 8 | + |
| 9 | + |
| 10 | + # MySQL |
| 11 | + |
| 12 | + |
| 13 | + - kind: ConfigMap |
| 14 | + apiVersion: v1 |
| 15 | + metadata: |
| 16 | + name: example-components-mysql-init |
| 17 | + namespace: ${NAMESPACE} |
| 18 | + immutable: false |
| 19 | + data: |
| 20 | + init.sql: | |
| 21 | + USE inventory; |
| 22 | +
|
| 23 | + # Create and populate our products using a single insert with many rows |
| 24 | +
|
| 25 | + CREATE TABLE products ( |
| 26 | + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 27 | + name VARCHAR(255) NOT NULL, |
| 28 | + description VARCHAR(512), |
| 29 | + weight FLOAT |
| 30 | + ); |
| 31 | +
|
| 32 | + ALTER TABLE products AUTO_INCREMENT = 101; |
| 33 | +
|
| 34 | + INSERT INTO products |
| 35 | + VALUES (default,"scooter","Small 2-wheel scooter",3.14), |
| 36 | + (default,"car battery","12V car battery",8.1), |
| 37 | + (default,"12-pack drill bits","12-pack of drill bits with sizes ranging from #40 to #3",0.8), |
| 38 | + (default,"hammer","12oz carpenter's hammer",0.75), |
| 39 | + (default,"hammer","14oz carpenter's hammer",0.875), |
| 40 | + (default,"hammer","16oz carpenter's hammer",1.0), |
| 41 | + (default,"rocks","box of assorted rocks",5.3), |
| 42 | + (default,"jacket","water resistant black wind breaker",0.1), |
| 43 | + (default,"spare tire","24 inch spare tire",22.2); |
| 44 | +
|
| 45 | + # Create and populate the products on hand using multiple inserts |
| 46 | +
|
| 47 | + CREATE TABLE products_on_hand ( |
| 48 | + product_id INTEGER NOT NULL PRIMARY KEY, |
| 49 | + quantity INTEGER NOT NULL, |
| 50 | + FOREIGN KEY (product_id) REFERENCES products(id) |
| 51 | + ); |
| 52 | +
|
| 53 | + INSERT INTO products_on_hand VALUES (101,3); |
| 54 | + INSERT INTO products_on_hand VALUES (102,8); |
| 55 | + INSERT INTO products_on_hand VALUES (103,18); |
| 56 | + INSERT INTO products_on_hand VALUES (104,4); |
| 57 | + INSERT INTO products_on_hand VALUES (105,5); |
| 58 | + INSERT INTO products_on_hand VALUES (106,0); |
| 59 | + INSERT INTO products_on_hand VALUES (107,44); |
| 60 | + INSERT INTO products_on_hand VALUES (108,2); |
| 61 | + INSERT INTO products_on_hand VALUES (109,5); |
| 62 | +
|
| 63 | + # Create some customers ... |
| 64 | +
|
| 65 | + CREATE TABLE customers ( |
| 66 | + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 67 | + first_name VARCHAR(255) NOT NULL, |
| 68 | + last_name VARCHAR(255) NOT NULL, |
| 69 | + email VARCHAR(255) NOT NULL UNIQUE KEY |
| 70 | + ) AUTO_INCREMENT=1001; |
| 71 | +
|
| 72 | + INSERT INTO customers |
| 73 | + VALUES (default,"Sally","Thomas","sally.thomas@acme.com"), |
| 74 | + (default,"George","Bailey","gbailey@foobar.com"), |
| 75 | + (default,"Edward","Walker","ed@walker.com"), |
| 76 | + (default,"Anne","Kretchmar","annek@noanswer.org"); |
| 77 | +
|
| 78 | + # Create some fake addresses |
| 79 | +
|
| 80 | + CREATE TABLE addresses ( |
| 81 | + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 82 | + customer_id INTEGER NOT NULL, |
| 83 | + street VARCHAR(255) NOT NULL, |
| 84 | + city VARCHAR(255) NOT NULL, |
| 85 | + state VARCHAR(255) NOT NULL, |
| 86 | + zip VARCHAR(255) NOT NULL, |
| 87 | + type enum('SHIPPING','BILLING','LIVING') NOT NULL, |
| 88 | + FOREIGN KEY address_customer (customer_id) REFERENCES customers(id) |
| 89 | + ) AUTO_INCREMENT = 10; |
| 90 | +
|
| 91 | + INSERT INTO addresses |
| 92 | +
|
| 93 | + VALUES (default,1001,'3183 Moore Avenue','Euless','Texas','76036','SHIPPING'), |
| 94 | + (default,1001,'2389 Hidden Valley Road','Harrisburg','Pennsylvania','17116','BILLING'), |
| 95 | + (default,1002,'281 Riverside Drive','Augusta','Georgia','30901','BILLING'), |
| 96 | + (default,1003,'3787 Brownton Road','Columbus','Mississippi','39701','SHIPPING'), |
| 97 | + (default,1003,'2458 Lost Creek Road','Bethlehem','Pennsylvania','18018','SHIPPING'), |
| 98 | + (default,1003,'4800 Simpson Square','Hillsdale','Oklahoma','73743','BILLING'), |
| 99 | + (default,1004,'1289 University Hill Road','Canehill','Arkansas','72717','LIVING'); |
| 100 | +
|
| 101 | + # Create some very simple orders |
| 102 | +
|
| 103 | + CREATE TABLE orders ( |
| 104 | + order_number INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 105 | + order_date DATE NOT NULL, |
| 106 | + purchaser INTEGER NOT NULL, |
| 107 | + quantity INTEGER NOT NULL, |
| 108 | + product_id INTEGER NOT NULL, |
| 109 | + FOREIGN KEY order_customer (purchaser) REFERENCES customers(id), |
| 110 | + FOREIGN KEY ordered_product (product_id) REFERENCES products(id) |
| 111 | + ) AUTO_INCREMENT = 10001; |
| 112 | +
|
| 113 | + INSERT INTO orders |
| 114 | + VALUES (default, '2016-01-16', 1001, 1, 102), |
| 115 | + (default, '2016-01-17', 1002, 2, 105), |
| 116 | + (default, '2016-02-19', 1002, 2, 106), |
| 117 | + (default, '2016-02-21', 1003, 1, 107); |
| 118 | +
|
| 119 | + - kind: Deployment |
| 120 | + apiVersion: apps/v1 |
| 121 | + metadata: |
| 122 | + name: example-components-mysql |
| 123 | + namespace: ${NAMESPACE} |
| 124 | + labels: |
| 125 | + app: example-components-mysql |
| 126 | + spec: |
| 127 | + replicas: 1 |
| 128 | + selector: |
| 129 | + matchLabels: |
| 130 | + app: example-components-mysql |
| 131 | + template: |
| 132 | + metadata: |
| 133 | + labels: |
| 134 | + app: example-components-mysql |
| 135 | + spec: |
| 136 | + containers: |
| 137 | + - resources: |
| 138 | + limits: |
| 139 | + cpu: 1000m |
| 140 | + memory: 1024Mi |
| 141 | + requests: |
| 142 | + cpu: 500m |
| 143 | + memory: 512Mi |
| 144 | + terminationMessagePath: /dev/termination-log |
| 145 | + name: mysql |
| 146 | + env: |
| 147 | + - name: MYSQL_ROOT_PASSWORD |
| 148 | + value: ${MYSQL_ROOT_PASSWORD} |
| 149 | + - name: MYSQL_USER |
| 150 | + value: ${MYSQL_USER} |
| 151 | + - name: MYSQL_PASSWORD |
| 152 | + value: ${MYSQL_PASSWORD} |
| 153 | + - name: MYSQL_DATABASE |
| 154 | + value: ${MYSQL_DATABASE} |
| 155 | + ports: |
| 156 | + - containerPort: 3306 |
| 157 | + protocol: TCP |
| 158 | + imagePullPolicy: IfNotPresent |
| 159 | + terminationMessagePolicy: File |
| 160 | + image: mysql:latest |
| 161 | + securityContext: |
| 162 | + allowPrivilegeEscalation: false |
| 163 | + runAsNonRoot: true |
| 164 | + capabilities: |
| 165 | + drop: |
| 166 | + - ALL |
| 167 | + seccompProfile: |
| 168 | + type: RuntimeDefault |
| 169 | + livenessProbe: |
| 170 | + exec: |
| 171 | + command: [ "mysqladmin", "--user=${MYSQL_ROOT_USER}", "--password=${MYSQL_ROOT_PASSWORD}", "ping" ] |
| 172 | + initialDelaySeconds: 30 |
| 173 | + periodSeconds: 10 |
| 174 | + timeoutSeconds: 5 |
| 175 | + volumeMounts: |
| 176 | + - name: mysql-init-volume |
| 177 | + mountPath: /docker-entrypoint-initdb.d |
| 178 | + volumes: |
| 179 | + - name: mysql-init-volume |
| 180 | + configMap: |
| 181 | + name: example-components-mysql-init |
| 182 | + restartPolicy: Always |
| 183 | + terminationGracePeriodSeconds: 30 |
| 184 | + dnsPolicy: ClusterFirst |
| 185 | + securityContext: { } |
| 186 | + schedulerName: default-scheduler |
| 187 | + strategy: |
| 188 | + type: RollingUpdate |
| 189 | + rollingUpdate: |
| 190 | + maxUnavailable: 25% |
| 191 | + maxSurge: 25% |
| 192 | + revisionHistoryLimit: 10 |
| 193 | + progressDeadlineSeconds: 600 |
| 194 | + |
| 195 | + |
| 196 | + - kind: Service |
| 197 | + apiVersion: v1 |
| 198 | + metadata: |
| 199 | + name: example-components-mysql |
| 200 | + namespace: ${NAMESPACE} |
| 201 | + labels: |
| 202 | + app: example-components-mysql |
| 203 | + spec: |
| 204 | + selector: |
| 205 | + app: example-components-mysql |
| 206 | + ports: |
| 207 | + - protocol: TCP |
| 208 | + port: 3306 |
| 209 | + targetPort: 3306 |
| 210 | + |
| 211 | + |
| 212 | + # Kafka |
| 213 | + |
| 214 | + |
| 215 | + - kind: Kafka |
| 216 | + apiVersion: kafka.strimzi.io/v1beta2 |
| 217 | + metadata: |
| 218 | + name: example-components-kafka |
| 219 | + namespace: ${NAMESPACE} |
| 220 | + spec: |
| 221 | + entityOperator: |
| 222 | + topicOperator: { } # Required |
| 223 | + userOperator: { } # Required |
| 224 | + kafka: |
| 225 | + config: |
| 226 | + offsets.topic.replication.factor: 1 |
| 227 | + transaction.state.log.min.isr: 1 |
| 228 | + transaction.state.log.replication.factor: 1 |
| 229 | + listeners: |
| 230 | + - name: plain |
| 231 | + port: 9092 |
| 232 | + tls: false |
| 233 | + type: internal |
| 234 | + - name: tls |
| 235 | + port: 9093 |
| 236 | + tls: true |
| 237 | + type: internal |
| 238 | + replicas: 1 |
| 239 | + storage: |
| 240 | + type: ephemeral |
| 241 | + version: 3.4.0 |
| 242 | + zookeeper: |
| 243 | + replicas: 1 |
| 244 | + storage: |
| 245 | + type: ephemeral |
| 246 | + |
| 247 | + |
| 248 | + - apiVersion: kafka.strimzi.io/v1beta2 |
| 249 | + kind: KafkaConnect |
| 250 | + metadata: |
| 251 | + annotations: |
| 252 | + strimzi.io/use-connector-resources: "true" |
| 253 | + name: example-components-kafka-connect |
| 254 | + namespace: ${NAMESPACE} |
| 255 | + spec: |
| 256 | + bootstrapServers: example-components-kafka-kafka-bootstrap.${NAMESPACE}.svc:9093 |
| 257 | + build: |
| 258 | + output: |
| 259 | + image: ${KAFKA_CONNECT_IMAGE} |
| 260 | + type: docker |
| 261 | + pushSecret: example-components-pull-secret |
| 262 | + plugins: |
| 263 | + - name: debezium-connector-mysql |
| 264 | + artifacts: |
| 265 | + - type: zip |
| 266 | + url: https://repo1.maven.org/maven2/io/debezium/debezium-connector-mysql/2.3.3.Final/debezium-connector-mysql-2.3.3.Final-plugin.zip |
| 267 | + - type: zip |
| 268 | + url: https://repo1.maven.org/maven2/io/debezium/debezium-scripting/2.3.3.Final/debezium-scripting-2.3.3.Final.zip |
| 269 | + - type: jar |
| 270 | + url: https://repo1.maven.org/maven2/org/apache/groovy/groovy/4.0.9/groovy-4.0.9.jar |
| 271 | + - type: jar |
| 272 | + url: https://repo1.maven.org/maven2/org/apache/groovy/groovy-json/4.0.9/groovy-json-4.0.9.jar |
| 273 | + - type: jar |
| 274 | + url: https://repo1.maven.org/maven2/org/apache/groovy/groovy-jsr223/4.0.9/groovy-jsr223-4.0.9.jar |
| 275 | + - type: zip |
| 276 | + url: https://repo1.maven.org/maven2/io/apicurio/apicurio-registry-distro-connect-converter/2.4.4.Final/apicurio-registry-distro-connect-converter-2.4.4.Final.zip |
| 277 | + config: |
| 278 | + config.storage.replication.factor: 1 |
| 279 | + offset.storage.replication.factor: 1 |
| 280 | + status.storage.replication.factor: 1 |
| 281 | + replicas: 1 |
| 282 | + tls: |
| 283 | + trustedCertificates: |
| 284 | + - certificate: ca.crt |
| 285 | + secretName: example-components-kafka-cluster-ca-cert |
| 286 | + |
| 287 | + |
| 288 | + - apiVersion: kafka.strimzi.io/v1beta2 |
| 289 | + kind: KafkaConnector |
| 290 | + metadata: |
| 291 | + labels: |
| 292 | + strimzi.io/cluster: example-components-kafka-connect |
| 293 | + name: example-components-kafka-connector |
| 294 | + namespace: ${NAMESPACE} |
| 295 | + spec: |
| 296 | + class: io.debezium.connector.mysql.MySqlConnector |
| 297 | + config: |
| 298 | + |
| 299 | + value.converter: io.apicurio.registry.utils.converter.AvroConverter |
| 300 | + value.converter.apicurio.registry.auto-register: true |
| 301 | + value.converter.apicurio.registry.find-latest: true |
| 302 | + value.converter.apicurio.registry.url: http://example-components-registry-service.${NAMESPACE}.svc.cluster.local:8080/apis/registry/v2 |
| 303 | + |
| 304 | + key.converter: io.apicurio.registry.utils.converter.AvroConverter |
| 305 | + key.converter.apicurio.registry.auto-register: true |
| 306 | + key.converter.apicurio.registry.find-latest: true |
| 307 | + key.converter.apicurio.registry.url: http://example-components-registry-service.${NAMESPACE}.svc.cluster.local:8080/apis/registry/v2 |
| 308 | + |
| 309 | + database.server.id: 1 |
| 310 | + database.hostname: example-components-mysql.${NAMESPACE}.svc.cluster.local |
| 311 | + database.port: 3306 |
| 312 | + database.user: ${MYSQL_ROOT_USER} |
| 313 | + database.password: ${MYSQL_ROOT_PASSWORD} |
| 314 | + database.dbname: inventory |
| 315 | + database.cdcschema: ASNCDC |
| 316 | + |
| 317 | + schema.name.adjustment.mode: avro |
| 318 | + topic.prefix: example |
| 319 | + |
| 320 | + schema.history.internal.kafka.topic: schema-changes.inventory |
| 321 | + schema.history.internal.kafka.bootstrap.servers: example-components-kafka-kafka-bootstrap.${NAMESPACE}.svc:9092 # TODO TLS? |
| 322 | + tasksMax: 1 |
| 323 | + |
| 324 | + |
| 325 | + # Apicurio Registry |
| 326 | + |
| 327 | + |
| 328 | + - kind: ApicurioRegistry |
| 329 | + apiVersion: registry.apicur.io/v1 |
| 330 | + metadata: |
| 331 | + name: example-components-registry |
| 332 | + namespace: ${NAMESPACE} |
| 333 | + spec: |
| 334 | + configuration: |
| 335 | + persistence: kafkasql |
| 336 | + kafkasql: |
| 337 | + bootstrapServers: example-components-kafka-kafka-bootstrap.${NAMESPACE}.svc:9092 |
| 338 | + logLevel: DEBUG |
| 339 | + registryLogLevel: DEBUG |
| 340 | + |
| 341 | + |
| 342 | +parameters: |
| 343 | + - name: NAMESPACE |
| 344 | + required: true |
| 345 | + - name: MYSQL_ROOT_USER |
| 346 | + value: root # From MySQL image |
| 347 | + required: true |
| 348 | + - name: MYSQL_ROOT_PASSWORD |
| 349 | + value: debezium |
| 350 | + required: true |
| 351 | + - name: MYSQL_USER |
| 352 | + value: mysqluser |
| 353 | + required: true |
| 354 | + - name: MYSQL_PASSWORD |
| 355 | + value: mysqlpassword |
| 356 | + required: true |
| 357 | + - name: MYSQL_DATABASE |
| 358 | + value: inventory |
| 359 | + required: true |
| 360 | + - name: KAFKA_CONNECT_IMAGE |
| 361 | + required: true |
0 commit comments