This directory contains a copy of the todo application that was previously modernized using Konveyor Kantra. We're now using this modernized version to demonstrate how to deploy a Tomcat-based Java application to Kubernetes using Draft, a tool that helps developers create containerized applications and deploy them to Kubernetes.
./deploytok8s.sh
After deployment, access the application at:
- Main application: http://localhost:18081/todo
- Health check: http://localhost:18081/todo/health
- API: http://localhost:18081/todo/api/todos
This project demonstrates deploying the modernized Todo application (from after-container) to Kubernetes using Draft. While Draft provides good support for modern frameworks, we encountered limitations with its Java template for our Tomcat-based application. We've used AI assistance to enhance the generated artifacts with proper Tomcat configuration.
Draft's Java template works well for Spring Boot apps but didn't fully support our Tomcat-based application. We used Draft to generate initial artifacts and then enhanced them with AI assistance:
# Our Draft configuration
deployType: "Helm"
languageType: "java"
deployVariables:
- name: "PORT"
value: "8080"
- name: "SERVICEPORT"
value: "80"
- name: "APPNAME"
value: "todo-app"
- name: "IMAGENAME"
value: "todo-app"
languageVariables:
- name: "VERSION"
value: "17-jre"
- name: "BUILDERVERSION"
value: "3-jdk-8"
- name: "PORT"
value: "8080"
# Draft command used
draft create -c ./draft-config.yaml --skip-file-detection
The Konveyor AI (KAI) project offers insights into AI-assisted application modernization. While KAI currently focuses on suggesting code modifications based on static analysis, our approach uses AI to enhance deployment artifacts. Combining KAI's code modernization approach with Draft's artifact generation could create a more complete modernization-to-deployment pipeline.
- Runtime: Java 17, Tomcat 9
- Database: PostgreSQL
- Build: Maven
The application uses these environment variables:
DB_HOST
: Database host nameDB_PORT
: Database port (default: 5432)DB_NAME
: Database nameDB_USER
: Database userDB_PASSWORD
: Database password
- Health check endpoint at
/todo/health
- Returns
{"status":"UP"}
when healthy - Returns HTTP 503 when unhealthy
- Draft CLI installed
- Terraform CLI installed
- Azure CLI configured with appropriate permissions
- Container registry access (ACR)
- Podman configured for Azure authentication
The deploytok8s.sh
script automates the entire deployment process:
-
Artifact Generation and Enhancement
- Creates working directory and copies source files
- Generates basic artifacts with Draft
- Enhances artifacts with AI-generated improvements
-
Container Build and Registry Operations
- Builds with Maven
- Creates container image with enhanced Dockerfile
- Pushes to Azure Container Registry
-
Infrastructure Management
- Provisions AKS cluster and ACR with Terraform
- Configures IAM permissions
- Sets up Kubernetes context
-
Application Deployment
- Deploys using Helm
- Configures services and environment
- Enables access through port forwarding
helm uninstall todo-app
kubectl delete pod --all --force
The AI-enhanced deployment artifacts include:
- Multi-stage Dockerfile with Tomcat support
- Comprehensive Helm charts with database integration
- Enhanced Kubernetes manifests with proper configurations
- Database Support: PostgreSQL deployment
- Environment Configuration: Proper secrets management
- Resource Management: Configurable limits and requests
k8s-simulation/helm/
├── Chart.yaml # Chart metadata
├── values.yaml # Configuration values
└── templates/
├── deployment.yaml # Tomcat application
├── service.yaml # Service configuration
├── configmap.yaml # Environment variables
└── postgres.yaml # Required database
migration-draft/
├── deploytok8s.sh # Main deployment script
├── k8s-simulation/ # AI-generated Kubernetes manifests
└── temp-after-container/ # Working directory (created during deployment)
├── src/ # Application source
├── pom.xml # Build configuration
├── dockerfile # AI-enhanced Dockerfile
└── charts/ # Generated Helm charts