As we reach the end of September 2024, ThreadFix version 3.x on-premises has officially reached its End-of-Life. Therefore, there is no longer support or updates for this version of the product. We have fully transitioned our product and development teams to focus ThreadFix SaaS and migrating all customers over from the on-premises versions. Our Customer Success and Support teams are here to help you in migrating to ThreadFix SaaS and maximizing the value you see from this improved offering from Coalfire. This is the next phase of ThreadFix and our team is looking forward to continuing to support you on this journey.

Docker Compose to Kubernetes Migration

You will learn

How to migrate from ThreadFix on Docker Compose to ThreadFix on Kubernetes.

Prerequisites

Audience: IT Professional
Difficulty: Intermediate
Time needed: Approximately 30 minutes
Tools required: compose-to-k8s.sh (provided below), db-only.yaml (provided below), Helm > 3.5, kubectl

Prior to beginning any upgrades or migration, ThreadFix strongly recommends users review the Upgrade & Migration Guidelines.

Migration with Automated Scripts

The following instructions assume there is an existing ThreadFix application running in Docker Compose and a functional Kubernetes instance with kubectl access and Helm 3.5 or greater.

Create Migration Files

  1. Download the following files (provided above):

    • compose-to-k8s.sh

    • db-only.yaml

  2. Copy compose-to-k8s.sh to the existing ThreadFix application server.

  3. Log into the existing ThreadFix application server.

  4. Make migration script executable with: chmod +x compose-to-k8s.sh.

  5. Create migration data with: ./compose-to-k8s.sh

    • By default this will use /opt/threadfix as the ThreadFix directory and will
      output data to the current directory. Run ./compose-to-k8s.sh --help to view
      all configurable items

    • The script will create the following files:

      • migrated_values.yaml

      • migrated_db.sql

      • appsec-data.zip

      • appsec-secrets.yaml (optional)

      • migrated_tls.yaml (optional)

  6. Review the output from the script and make any necessary adjustments.

  7. Validate all appropriate files have been created.

  8. Copy the generated files and db-only.yaml to the server with Kubernetes access.

External Database

Reuse Existing Database

If reusing the existing external database:

  • In migrated_values.yaml, validate appsec.db.urlOverride and auth.db.urlOverride are set and point to the correct database

If the external database has separate credentials than the internal database:

  1. Validate the appsec.db.existingSecret and auth.db.existingSecret fields exist in migrated_values.yaml and a corresponding appsec-secrets.yaml file has been created.

  2. On the server with kubectl access, run kubectl apply -f appsec-secrets.yaml to create the Kubernetes Secret for the AppSec database.

New External Database

If using a new external database, first migrate all data from the existing database to the new database following the vendor's instructions, then:

  1. In migrated_values.yaml, remove the appsec.db.urlOverride and auth.db.urlOverride items.

  2. Follow the External Database guide for setting up the external database. Then proceed with the remainder of this guide.

Installing ThreadFix on Kubernetes with Helm

  1. Follow any necessary preparation tasks before continuing.

  2. Make any modifications to the migrated_values.yaml file if needed.

  3. Setup TLS:

    • If reusing the existing TLS certificate, add the TLS certificate and keys with:

    kubectl apply -f migrated_tls.yaml
    • If using a new TLS certificate, add to Kubernetes with:

    kubectl create secret tls threadfix-cert --key <key_file> --cert <cert_file>

     

  4. Setup an external database (Optional).

    • If appsec-secrets.yaml was created and an existing external database is being reused, apply with:

    kubectl apply -f appsec-secrets.yaml
    • If an new external database is being used, follow applicable instructions on the External Database guide to add credentials for the external database

  5. Add the ThreadFix Helm repository:

    1. Add the ThreadFix Helm repository by running:

    2. Update the repositories by running:

       

  6. Make myValues dir if not present.

     

  7. Generate a unique password for PostgreSQL.

     

  8. Copy migrated_values.yaml in the to myValues dir.

     

  9. Generate a helm args for all of the user values files.

     

  10. Start the application in database only mode with:

     

  11. Wait until the database has started to proceed. Check status with kubectl get po -w. Use Ctrl-C to exit the command.

  12. Upload the exported database to the Kubernetes with:

     

  13. Start the application with:

     

  14. Follow the on-screen instructions to access the application.

    • Use kubectl get po -w to watch the installation progress

Manual Migration

Export the Database

  1. Change directory to the location of the ThreadFix install. ex. cd /opt/threadfix.

  2. Stop ThreadFix with:

     

  3. Start the database only with:

     

  4. Export the database (replacing <db_dump_file> with the desired file name to create the database dump with):

     

  5. Copy the dump file to the machine with kubectl access.

Create Helm Values

Create a Helm Values file from the existing ThreadFix .env file (default location /opt/threadfix/.env) where appropriate. The table below shows Compose variables with equivalent Helm values. If any value has not been changed from the default, it can safely be ignored.

Docker Compose Value

Helm Value

TFN_DB_USER

db.username

TFN_DB_PASS

db.password

APPSEC_DB_URL

appsec.db.urlOverride,auth.db.urlOverride

APPSEC_DB_GLOBALLY_QUOTED

appsec.db.globallyQuoted,auth.db.globallyQuoted

APPSEC_DB_VIBUR_CACHE_SIZE

appsec.vibur.cacheSize,auth.vibur.cacheSize

APPSEC_DB_VIBUR_MIN_POOL

appsec.db.vibur.minPool,auth.db.vibur.minPool

APPSEC_DB_VIBUR_MAX_POOL

appsec.db.vibur.maxPool,auth.db.vibur.maxPool

APPSEC_DB_VIBUR_IDLE_CONN_LIMIT

appsec.db.vibur.idleConnectionLimit,auth.db.vibur.idleConnectionLimit

SESSION_TIMEOUT_INACTIVE

auth.sessionTimeoutInactive

SPRING_PROFILES_ACTIVE

global.threadfix.springProfilesActive

Add Properties Files as YAML String

The following values need the contents of the listed file input as yaml strings.

Docker Compose Value

Helm Value

tn_license

"threadfix.license"

tn_prop_loc

"network.properties

tn_log_loc

"logback-all.xml"

appsec_license

"threadfix.license"

esapi_properties

"ESAPI.properties"

LOGBACK_CONFIG_FILE

"logback-all.xml"

saml_properties

"onelogin.saml.properties"

Example:

Other Values

The following values have no Helm equivalent and must be created as Kubernetes Secrets and linked to the ThreadFix installation.

  • External AppSec database credentials:

    • APPSEC_DB_USER

    • APPSEC_DB_PASSWORD

  • TLS certificates:

    • ssl_cert

    • ssl_key

External AppSec Database Credentials Setup

If using an internal Appsec database or sharing the same database credentials for Appsec and network, the AppSec database credentials values can be ignored. Otherwise, follow the External Database setup to prepare the external database.

TLS Setup

On the Kubernetes instance, create a TLS Secret with the following command (replacing <> placeholders with actual values):

Then add the following to the Helm values yaml file from above:

Install ThreadFix with Helm

  1. Make any other modifications to the Helm values file if needed.

  2. Install Helm >= 3.5 or greater if not already installed. Perform one of the following:

    • Install from script with curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | sudo bash

    • Follow the instructions for Helm installation: https://helm.sh/docs/intro/install/

  3. Add the ThreadFix Helm repository:

    1. Add the ThreadFix Helm repository by running:

    2. Update the repositories by running:

       

  4. Create db-only.yaml file with the following contents:

     

  5. Make myValues dir if not present.

     

  6. Generate a unique password for PostgreSQL.

     

  7. Create a myValues.yaml file.

     

  8. Copy any created helm values files the to myValues dir.

  9. Generate a helm args for all of the user values files.

     

  10. Start the application in Database Only mode with:

     

  11. Wait until the database has started to proceed. Check the status with kubectl get po -w. Use Ctrl-C to exit the command.

  12. Upload the exported database to the Kubernetes with:

     

  13. Start the application with (replacing <helm_values_file> with the values file created earlier):

     

  14. Follow the on screen instructions to access the application.

    • Use kubectl get po -w to watch the installation progress

 

www.threadfix.it | www.coalfire.com
Copyright © 2024 Coalfire. All rights reserved.

This Information Security Policy is CoalFire - Public: Distribution of this material is not limited.