Problem Statement:
I have a created a Docker image successfully from docker.io/joethecoder2/spring-boot-web
. It has been tested with command line argum
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.
apiVersion: v1
kind: Pod
metadata:
name: spring-boot-web-demo
labels:
purpose: demonstrate-spring-boot-web
spec:
containers:
- name: spring-boot-web
image: docker.io/joethecoder2/spring-boot-web
command: ["java","-jar", "spring-boot-web-0.0.1-SNAPSHOT.jar"]
env:
- name: DCASSANDRA_IP
valueFrom:
configMapKeyRef:
key: Dcassandra_ip
name: env-values
- name: DCASSANDRA_PORT
valueFrom:
configMapKeyRef:
key: Dcassandra_port
name: env-values
restartPolicy: OnFailure
---
apiVersion: v1
kind: ConfigMap
metadata:
name: env-values
data:
Dcassandra_port=9042
Dcassandra_ip=127.0.0.1
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