Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space FUNCTDEV and version SVC2025.1

...

Once the prerequisites have been met, you can deploy CTP in Kubernetes. If  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.

...

Code Block
languageyml
titlectp-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: ctp-pod
  namespace: parasoft-ctp-namespace
  labels:
    app: ctp
spec:
  securityContext:
    runAsNonRoot: true
  serviceAccountName: parasoft-account
  automountServiceAccountToken: true
  containers:
  - name: ctp
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop: ["ALL"]
      seccompProfile:
        type: RuntimeDefault     
    image: parasoft/ctp:latest
    ports:
    - name: http
      containerPort: 8080
    - name: https
      containerPort: 8443
    # 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 /usr/local/parasoft &&
        ./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"
    - name: CATALINA_OPTS
      value: "-Dparasoft.cloudvm=true
               -Dparasoft.cloudvm.config=Kubernetes"
    - name: PARASOFT_POD_NAME
      valueFrom:
        fieldRef:
          fieldPath: metadata.name
    - name: PARASOFT_POD_NAMESPACE
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    # === 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

Use the yaml file to create service that can be used to access CTP in Kubernetes:

Code Block
languagetext
kubectl create -f ctp-pod.yaml

Create the service that can be used to access the CTP server in Kubernetes. The example shown below exposes it using a node port, which provides a stable endpoint for applications to access Virtual Assets.

Code Block
languageyml
titlectp-service.yaml
--
# ==== CTP Service Definition ====
apiVersion: v1
kind: Service
metadata:
  name: ctp-service
  namespace: parasoft-ctp-namespace
spec:
  selector:spec:
  selector:
    app: ctp
  type: NodePort
  ports:
  - name: http
    protocol: TCP
    port: 8080
    apptargetPort: ctp8080
  type  nodePort: NodePort30000
  ports- name: https
   - protocol: TCP
    port: 80808443
    targetPort: 80808443
    nodePort: 30000

Use the yaml file to create service that can be used to access CTP in Kubernetes:

Code Block
languagetext
kubectl create -f ctp-pod.yaml30083