The legacy version of Train Ticket had become outdated and lacked active maintenance. To address this, we've built a new, modernized version with improved functionality, streamlined processes, and enhanced observability.
- Simplified Development and Deployment: The development workflow now fully integrates with Kubernetes (k8s) and Helm, making setup and deployment more straightforward.
- Pruned Redundancies: We've removed outdated or unnecessary components to improve efficiency and reduce complexity.
- Enhanced Monitoring: Robust monitoring is now built-in, with support for tools like SkyWalking, OpenTelemetry, APO, providing deep insights into system performance.
Before you begin, ensure you have the following tools installed:
- Helm: For managing Kubernetes applications.
- Skaffold: For building Docker images.
- Minikube: For running a local Kubernetes cluster (optional for local development).
- Docker: For building container images.
- JDK and Maven: For building the Java-based project. (JDK 8 or 17 is recommended; ensure your
JAVA_HOMEis set correctly.)- You can check your Java version with:
java -version
- Maven can be installed via package managers or downloaded from the Apache Maven website.
- You can check your Java version with:
You’ll also need access to a container registry (e.g., Docker Hub, a private registry) to push and pull images.
Follow these steps to build the project:
-
Build the Project:
mvn clean package -Dmaven.test.skip=true
-
Build Docker Images with Skaffold:
skaffold build --default-repo=<your-registry>
- Replace
<your-registry>with a registry you have push access to (e.g.,docker.io/yourusername,gcr.io/yourproject). - Example:
skaffold build --default-repo=docker.io/myuser. - This builds and pushes images to the specified registry.
- Replace
Before deploying the application, you must build the Helm dependencies:
-
Build Helm Dependencies:
helm dependency build manifests/helm/generic_service
This step is mandatory and will fetch all required dependencies specified in Chart.yaml (mysql, postgresql, rabbitmq, etc.).
-
Basic Deployment with Specific Image Tag:
# alter: use the published helm chart
helm repo add train-ticket https://lgu-se-internal.github.io/train-ticket
helm repo update
helm search repo train-tickethelm install ts manifests/helm/generic_service -n ts --create-namespace \
--set global.monitoring=opentelemetry \
--set skywalking.enabled=false \
--set global.image.tag=3384da1cts: Release name (customizable).-n ts: Namespace (created if it doesn’t exist).--set: Customizes deployment options (e.g., monitoring type, image tag).
-
Using Custom Image Registry:
helm install ts manifests/helm/generic_service -n ts --create-namespace \ --set global.monitoring=opentelemetry \ --set skywalking.enabled=false \ --set global.image.tag=latest \ --set global.image.repository=registry.cn-shenzhen.aliyuncs.com/lincyaw
-
Advanced Example (with APO): To enable specific configurations (e.g., nodePort for UI):
helm upgrade ts manifests/helm/generic_service -n ts-dev --create-namespace \ --set global.monitoring=opentelemetry \ --set opentelemetry.enabled=false \ --set services.tsUiDashboard.nodePort=30081 \ --set global.image.tag=310a67e0
-
Uninstall: To remove the deployment:
helm uninstall ts -n ts
Note: If you change the release name, you must also update the values.yaml file accordingly. For instance, when disabling the PostgreSQL component for demo purposes (not recommended for production), ensure you configure the host to match your PostgreSQL service's hostname, as shown below:
postgresql:
enabled: false # To disable the demo PostgreSQL deployment (not for production use).
config:
# Specify your PostgreSQL service's hostname (effective when postgresql.enabled is false).
host: ts-postgresql # Important: Update this to match your service name!
auth:This new version is designed to offer a more streamlined, efficient, and powerful solution for managing train ticket services, leveraging the latest in technology and best practices.