Running Pro*COBOL Programs in Kubernetes

5 hours ago 1

A Proof of Concept (PoC) for building and running Pro*COBOL programs in containers for deployment on Kubernetes.

This project demonstrates how to containerize and run a Pro*COBOL application with Oracle database connectivity in a modern Kubernetes environment. It leverages several open-source tools to create a fully containerized workflow.

  • melange - For building packages
  • apko - For building container images
  • k3d - For running a local Kubernetes cluster
  • kubectl - For interacting with Kubernetes
  • maru - For running tasks
  • Docker runtime
  • Oracle Instant Client libraries (see below)

Oracle Instant Client Files

Due to Oracle licensing restrictions, you need to download the Oracle Instant Client files yourself. See the detailed instructions in src/libs/README.md for:

  • Direct download links for the required packages
  • Oracle account and license agreement requirements
  • Specific version information and compatibility notes
  • Proper placement of the downloaded files

The required files are:

  • instantclient-basic-linux.x64-19.27.0.0.0dbru.zip
  • instantclient-precomp-linux.x64-19.27.0.0.0dbru.zip
  • src/cobolite.pco - The Pro*COBOL example application source code
  • src/container.yaml - Configuration for building the container image
  • src/package.yaml - Configuration for building the Wolfi package
  • src/pipelines/procob.yaml - Pipeline for compiling Pro*COBOL code
  • manifests/ - Kubernetes deployment manifests
    • database.yaml - Oracle database deployment
    • worker.yaml - COBOL application deployment
  1. The Pro*COBOL source code is pre-compiled and compiled using the Oracle Instant Client and GNU COBOL
  2. Melange builds a package with the compiled COBOL program and its dependencies
  3. Apko creates a minimal container image with the package
  4. K3d deploys a local Kubernetes cluster with:
    • An Oracle database container
    • A COBOL worker container that connects to the database

The full development workflow can be run with:

This command will:

  1. Check for required tools
  2. Generate necessary keys for Melange
  3. Build the COBOL package
  4. Build a container image
  5. Deploy to a local k3d Kubernetes cluster
  6. Run the COBOL application

COBOL Application Details

The sample application (cobolite.pco) demonstrates:

  • Connecting to an Oracle database using Pro*COBOL
  • Retrieving environment variables for configuration
  • Executing SQL queries
  • Reading from and writing to files
  • Processing command-line arguments

It can run in two modes:

  • import - Reads data from a file and inserts it into the database
  • export - Exports data from the database to a file (default mode in the demo)

To modify the application:

  1. Edit src/cobolite.pco
  2. Run maru run dev to rebuild and deploy

To change database connection details, modify the environment variables in manifests/worker.yaml.

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Read Entire Article