blob: b6ba36fbf213dc6f1ac1259ef69223b4706edc82 [file] [log] [blame]
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion: apps/v1
kind: Deployment
metadata:
name: camel-quarkus-examples-derby-database-deployment
labels:
app.kubernetes.io/name: camel-quarkus-examples-derby-database
app.kubernetes.io/version: 3.6.0
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: camel-quarkus-examples-derby-database
app.kubernetes.io/version: 3.6.0
template:
metadata:
labels:
app.kubernetes.io/name: camel-quarkus-examples-derby-database
app.kubernetes.io/version: 3.6.0
spec:
containers:
- name: derby-database
# Use a default configured derby database for example purpose, think twice before deploying to production
image: az82/docker-derby:10.16
ports:
- containerPort: 1527
volumeMounts:
# The /derby-init folder contains the SQL init script to create the database, the table and the sequence
- name: derby-database-init-script-volume
mountPath: /derby-init
# The /dbs folder is where the actual database content is stored
- name: derby-database-data-volume
mountPath: /dbs
lifecycle:
postStart:
# Execute the SQL init script after the derby container has started
exec:
command: ["java", "-Djdbc.drivers=org.apache.derbbc.EmbeddedDriver", "org.apache.derby.tools.ij", "/derby-init/init.sql"]
volumes:
# Create a volume in order to store the SQL init file
- name: derby-database-init-script-volume
configMap:
name: derby-database-init-script-config-map
defaultMode: 0744
# Explicitly create an empty dir volume in order to ensure read/write access needed to store database files
- name: derby-database-data-volume
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: camel-quarkus-examples-derby-database
app.kubernetes.io/version: 3.6.0
name: derby-database
spec:
ports:
- name: derby
port: 1527
targetPort: 1527
selector:
app.kubernetes.io/name: camel-quarkus-examples-derby-database
app.kubernetes.io/version: 3.6.0
type: ClusterIP
---
apiVersion: v1
kind: ConfigMap
metadata:
name: derby-database-init-script-config-map
labels:
app.kubernetes.io/name: camel-quarkus-examples-derby-database
app.kubernetes.io/version: 3.6.0
data:
init.sql: |
CONNECT 'jdbc:derby:my-db;create=true';
CREATE TABLE CAMEL_MESSAGEPROCESSED ( processorName VARCHAR(255), messageId VARCHAR(100), createdAt TIMESTAMP, PRIMARY KEY (processorName, messageId) );
CREATE SEQUENCE CAMEL_MESSAGEPROCESSED_SEQ AS INT MAXVALUE 999999 CYCLE;
---