COBOL Demo
A Proof of Concept (PoC) for building and running Pro*COBOL programs in containers for deployment on Kubernetes.
Overview
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.
Prerequisites
- 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.zipinstantclient-precomp-linux.x64-19.27.0.0.0dbru.zip
Project Structure
src/cobolite.pco- The Pro*COBOL example application source codesrc/container.yaml- Configuration for building the container imagesrc/package.yaml- Configuration for building the Wolfi packagesrc/pipelines/procob.yaml- Pipeline for compiling Pro*COBOL codemanifests/- Kubernetes deployment manifestsdatabase.yaml- Oracle database deploymentworker.yaml- COBOL application deployment
How It Works
- The Pro*COBOL source code is pre-compiled and compiled using the Oracle Instant Client and GNU COBOL
- Melange builds a package with the compiled COBOL program and its dependencies
- Apko creates a minimal container image with the package
- K3d deploys a local Kubernetes cluster with:
- An Oracle database container
- A COBOL worker container that connects to the database
Getting Started
The full development workflow can be run with:
This command will:
- Check for required tools
- Generate necessary keys for Melange
- Build the COBOL package
- Build a container image
- Deploy to a local k3d Kubernetes cluster
- 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 databaseexport- Exports data from the database to a file (default mode in the demo)
Working with the Demo
To modify the application:
- Edit
src/cobolite.pco - Run
maru run devto rebuild and deploy
To change database connection details, modify the environment variables in manifests/worker.yaml.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.