This Go application connects to a PostgreSQL database and a Kafka broker. It consumes messages from a Kafka topic, parses them as JSON into a CVE struct, and stores them in the database with versioning support. The application also exposes readiness and liveness endpoints for health checks. The readiness probe verifies database and Kafka connectivity and the existence of a specific Kafka topic, while the liveness probe confirms the application is running. This application is designed to run as a container in a pod with appropriate environment variables.
The application uses environment variables that are retrieved using os.Getenv() and used to establish connections to the database and Kafka broker.
Once the Docker image is built, appropriate environment variables like db_host, db_port, db_name, db_user, db_password, kafka_host, kafka_port and kafka_topic need to be supplied to the container to ensure that the pod does not fail.
-
Build and push Docker Image using buildx:
docker buildx build --platform linux/amd64,linux/arm64 -t DOCKER_USERNAME/cve-consumer:latest --push .