Problem Statement:
I have a created a Docker image successfully from docker.io/joethecoder2/spring-boot-web
. It has been tested with command line arguments, and those work correctly locally with Docker.
I am trying to pass java arguments that are passed to Docker to a Kubernetes POD that is defined with a single image docker.io/joethecoder2/spring-boot-web
The purpose of passing the arguments is to let the POD know what the IP address and port number are for the database service.
Problem Definition:
I have defined a Kubernetes POD here, however I believe the arguments are not passed correctly from singlePod.yaml when the POD is running the service.
Expected Result:
I expect that the Kubernetes POD be compatible with the Docker image defined here.
I expect that the Kubernetes POD accept arguments just like Docker does here:
docker run -it -p 8080:8080 joethecoder2/spring-boot-web -Dcassandra_ip=127.0.0.1 -Dcassandra_port=9042
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' 'http://localhost:8080/restaurant/arguments'
Correct result is returned-> 127.0.0.1:9042
Wrong Result:
I know that the actual arguments are not passed to the POD, because when I run the following service, I receive no arguments returned.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' 'http://192.168.64.3:32308/restaurant/arguments'
Wrong result is returned-> :
Expected result -> 127.0.0.1:9042
, as defined in the singlePod.yaml
file
Why are the arguments missing, even though the POD definition file knows that the arguments have been defined staticly?
If you want to inject environment variable into the container.It's better to use ConfigMap so it provides flexibility as well as separation of concern.
Now You need to write a Service Manifest file to expose this container in order to access it. I have attached links for further research.
ConfigMap
Service