...
Deploying CTP in Kubernetes
Using the Embedded HyperSQL Database
To deploy CTP in Kubernetes using the embedded HyperSQL database, follow the process outlined below.
...
Code Block |
---|
|
kubectl create -f ctp-hsqldb.yaml |
CTP
...
Deployment
Once the prerequisites have been met, you can deploy CTP in Kubernetes. If custom Persistent Volume Claim names were used in previous steps, make sure to update the appropriate 'volumeMounts:name' and 'claimName' fields to match the custom name.
...
Code Block |
---|
language | yml |
---|
title | ctp-deploymentpod.yaml |
---|
|
apiVersion: apps/v1
kind: DeploymentPod
metadata:
name: ctp-deploymentpod
labels:
app: ctp
spec:
replicascontainers:
1
- selectorname:
matchLabels:ctp
appimage: parasoft/ctp
template:latest
metadataports:
- containerPort: labels:8080
volumeMounts:
- appname: ctp-exports-storage
spec:
containers:mountPath: /usr/local/parasoft/exports
- name: ctp-hsqldb-storage
imagemountPath: /usr/local/parasoft/ctp:latest/hsqldb
env:
ports:
- containerPort: 8080
volumeMounts:
# === USE BELOW TO CONFIGURE ENVIRONMENT VARIABLES ===
# Configures CTP to connect to license server at the specified base URL
- name: ctp-hsqldb-storageLICENSE_SERVER_URL
mountPath: <path>value: https://licenseserver:8443
# Configures CTP to -use name: ctp-exports-storage
basic authentication when connecting to license server
- mountPathname: <path>LICENSE_SERVER_AUTH_ENABLED
envvalue:
# === USE BELOW TO CONFIGURE ENVIRONMENT VARIABLES === "false"
# Configures CTP to connect to license server atas the specified base URLuser
# - name: LICENSE_SERVER_URLUSERNAME
# value: admin
value: https://licenseserver:8443
# # Configures CTP to use basic authentication when connecting connect to license server
with the specified password
# - name: LICENSE_SERVER_AUTH_ENABLEDPASSWORD
# value: "false"admin
# Set to true #or Configures CTPfalse to connectopt-in toor licenseopt-out serverof assending theanonymous specifiedusage user
data to Parasoft
# - name: LICENSEUSAGE_SERVER_USERNAMEDATA
value: "false"
# value:# admin
Accepts the End User License Agreement if set #to Configurestrue
CTP to connect to- license server with the specified password
name: ACCEPT_EULA
value: "false"
# - name: LICENSE_SERVER_PASSWORD=== PROBES ===
startupProbe:
# valuehttpGet: admin
# Set to true or false to opt-in or opt-out of sending anonymous usage data to Parasoftpath: /em/resources/favicon.ico
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
- nametimeoutSeconds: USAGE_DATA30
failureThreshold: 3
value: "false" livenessProbe:
httpGet:
# Accepts the End User License Agreement if set to true
- name: ACCEPT_EULA
value: "false"
volumes:
- name: ctp-hsqldb-storage
persistentVolumeClaim:
claimName: ctp-hsqldb-pvc
- name: ctp-exports-storage
persistentVolumeClaim:
claimName: ctp-exports-pvc
---
path: /em/resources/favicon.ico
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 30
readinessProbe:
httpGet:
path: /em/healthcheck
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 30
volumes:
- name: ctp-exports-storage
persistentVolumeClaim:
claimName: ctp-exports-pvc
- name: ctp-hsqldb-storage
persistentVolumeClaim:
claimName: ctp-hsqldb-pvc
---
apiVersion: v1
kind: Service
metadata:
name: ctp-service
spec:
selector:
app: ctp
type: NodePort
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30000 |
Use the yaml file to create service that can be used to access CTP in Kubernetes:
Code Block |
---|
|
kubectl create -f ctp-pod.yaml |
Using an External Database
To deploy CTP in Kubernetes using one of the supported external databases, follow the process outlined below.
Note |
---|
Deploying multiple CTP servers in Kubernetes is not supported with this version. Support is limited to a single instance of CTP running in a Kubernetes cluster. |
Prerequisites
First, Persistent Volumes and Persistent Volume claims for database configuration and exports storage are needed. They should be provisioned with around 1GB (for the database configuration) to 10GB (for exports storage) of space (this can be increased or decreased according to your needs) and ReadWriteOnce access mode is recommended. This space will be used for the workspace of the CTP server.
The default Persistent Volume Claim names are 'ctp-config-storage' and 'ctp-exports-storage' and these names can be customized by updating the yaml definition of the CTP server. The example shown below is a configuration to set up NFS Persistent Volumes and Persistent Volume Claims. While the example uses NFS, this is not required; use whatever persistent volume type fits your needs.
Warning: For NFS, the exported directory must have the same UID and GID as the Parasoft user that runs the container. For example, execute the command chown 1000:1000 <shared_path>
.
Code Block |
---|
language | yml |
---|
title | ctp-pv.yaml |
---|
|
# ==== Persistent Volume to Mount db_config.xml ====
apiVersion: v1
kind: PersistentVolume
metadata:
name: ctp-config-storage
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: <path>
server: <ip address>
---
# ==== PersistentVolumeClaim for db_config.xml ====
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ctp-config-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs
resources:
requests:
storage: 1Gi
volumeName: "ctp-config-storage"
---
# ==== Persistent Volume for Export Storage ====
apiVersion: v1
kind: PersistentVolume
metadata:
name: ctp-exports-storage
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: <path>
server: <ip address>
---
# ==== PersistentVolumeClaim for CTP exports folder ====
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ctp-exports-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs
resources:
requests:
storage: 10Gi
volumeName: "ctp-exports-storage" |
Use the yaml file to create Persistent Volumes and a Persistent Volume claims:
Code Block |
---|
|
kubectl create -f ctp-pv.yaml |
Second, a Persistent Volume and a Persistent Volume claim for the external database are needed. It should be provisioned with around 50GB of space (this can be increased or decreased according to your needs) and ReadWriteOnce access mode is recommended.
The default Persistent Volume claim names in the example below can be customized by updating the yaml definition of the CTP server. Uncomment the sections for database you are using. While the example uses NFS, this is not required; use whatever persistent volume type fits your needs. Be aware that the Persistent Volume and Persistent Volume claim mounts are for the database JDBC adapters, not the databases themselves.
Different yaml examples are included for each of the supported external databases. Use the one that's right for your environment.
Warning: For NFS, the exported directory must have the same UID and GID as the Parasoft user that runs the container. For example, execute the command chown 1000:1000 <shared_path>
.
MariaDB
Code Block |
---|
language | yml |
---|
title | ctp-db.yaml |
---|
|
# ==== Persistent Volume for MariaDB JDBC Adapter
apiVersion: v1
kind: PersistentVolume
metadata:
name: ctp-mariadbadapter-storage
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: <path>
server: <ip address>
---
# ==== PersistentVolumeClaim for MariaDB JDBC Adapter ====
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ctp-mariadbadapter-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs
resources:
requests:
storage: 1Gi
volumeName: "ctp-mariadbadapter-storage" |
MySQL
Code Block |
---|
language | yml |
---|
title | ctp-db.yaml |
---|
|
# ==== Persistent Volume for MySQL JDBC Adapter
apiVersion: v1
kind: PersistentVolume
metadata:
name: ctp-mysqladapter-storage
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: <path>
server: <ip address>
---
# ==== PersistentVolumeClaim for MySQL JDBC Adapter ====
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ctp-mysqladapter-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs
resources:
requests:
storage: 1Gi
volumeName: "ctp-mysqladapter-storage" |
Oracle
Code Block |
---|
language | yml |
---|
title | ctp-db.yaml |
---|
|
# ==== Persistent Volume for OracleDB JDBC Adapter
apiVersion: v1
kind: PersistentVolume
metadata:
name: ctp-oracleadapter-storage
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: <path>
server: <ip address>
---
# ==== PersistentVolumeClaim for OracleDB JDBC Adapter ====
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ctp-oracleadapter-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs
resources:
requests:
storage: 1Gi
volumeName: "ctp-oracleadapter-storage" |
Use the yaml file to create a Persistent Volume and a Persistent Volume claim:
Code Block |
---|
|
kubectl create -f ctp-db.yaml |
CTP Deployment
Once the prerequisites have been met, you can deploy CTP in Kubernetes. If custom Persistent Volume Claim names were used in previous steps, make sure to update the appropriate 'volumeMounts:name' and 'claimName' fields to match the custom name. Uncomment the sections for the database you are using.
The server EULA must be accepted by setting the ACCEPT_EULA value to "true" in the -env specifier. Additionally, to opt-in to sending anonymous usage data to Parasoft to help improve the product, change the USAGE_DATA value to "true" in the -env specifier.
Code Block |
---|
language | yml |
---|
title | ctp-pod.yaml |
---|
|
apiVersion: v1
kind: Pod
metadata:
name: ctp-pod
labels:
app: ctp
spec:
containers:
- name: ctp
image: parasoft/ctp:latest
ports:
- containerPort: 8080
# Delete database.properties file to prevent overwriting of db_config.xml on pod startup
command: [ "/bin/bash", "-c" ]
args:
-
cd ctp/webapps/em/WEB-INF/classes/META-INF/spring/ &&
rm database.properties &&
cd ~ &&
./entrypoint.sh
volumeMounts:
- name: ctp-config-storage
mountPath: /usr/local/parasoft/ctp/webapps/em/config/db_config.xml
subPath: db_config.xml
- name: ctp-exports-storage
mountPath: /usr/local/parasoft/exports
# - name: ctp-hsqldb-storage
# mountPath: /usr/local/parasoft/ctp/hsqldb
# === DB JDBC Adapter Volume Mounts ===
# - name: ctp-mariadbadapter-storage
# mountPath: /usr/local/parasoft/ctp/webapps/em/WEB-INF/lib/mariadb-java-client-3.0.8.jar
# subPath: mariadb-java-client-3.0.8.jar
# - name: ctp-mysqladapter-storage
# mountPath: /usr/local/parasoft/ctp/webapps/em/WEB-INF/lib/mysql-connector-java-8.0.30.jar
# subPath: mysql-connector-java-8.0.30.jar
# - name: ctp-oracleadapter-storage
# mountPath: /usr/local/parasoft/ctp/webapps/em/WEB-INF/lib/ojdbc8.jar
# subPath: ojdbc8.jar
env:
# === USE BELOW TO CONFIGURE ENVIRONMENT VARIABLES ===
# Configures CTP to connect to license server at the specified base URL
- name: LICENSE_SERVER_URL
value: https://licenseserver:8443
# Configures CTP to use basic authentication when connecting to license server
- name: LICENSE_SERVER_AUTH_ENABLED
value: "false"
# Configures CTP to connect to license server as the specified user
# - name: LICENSE_SERVER_USERNAME
# value: admin
# Configures CTP to connect to license server with the specified password
# - name: LICENSE_SERVER_PASSWORD
# value: admin
# Set to true or false to opt-in or opt-out of sending anonymous usage data to Parasoft
- name: USAGE_DATA
value: "false"
# Accepts the End User License Agreement if set to true
- name: ACCEPT_EULA
value: "false"
# === PROBES ===
startupProbe:
httpGet:
path: /em/resources/favicon.ico
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 30
failureThreshold: 3
livenessProbe:
httpGet:
path: /em/resources/favicon.ico
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 30
readinessProbe:
httpGet:
path: /em/healthcheck
port: 8080
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 30
volumes:
- name: ctp-config-storage
persistentVolumeClaim:
claimName: ctp-config-pvc
- name: ctp-exports-storage
persistentVolumeClaim:
claimName: ctp-exports-pvc
# - name: ctp-hsqldb-storage
# persistentVolumeClaim:
# claimName: ctp-hsqldb-pvc
# === SQL JDBC Adapter Volumes ===
# - name: ctp-mariadbadapter-storage
# persistentVolumeClaim:
# claimName: ctp-mariadbadapter-pvc
# - name: ctp-mysqladapter-storage
# persistentVolumeClaim:
# claimName: ctp-mysqladapter-pvc
# - name: ctp-oracleadapter-storage
# persistentVolumeClaim:
# claimName: ctp-oracleadapter-pvc
---
# ==== CTP Service Definition ====
apiVersion: v1
kind: Service
metadata:
name: ctp-service
spec:
selector:
app: ctp
type: LoadBalancerNodePort
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30000 |
...
Code Block |
---|
|
kubectl create -f ctp-deploymentpod.yaml |