I created a singlePod.yaml file to properly describe the kubernetes pod service that passes arguments, and can run like this:
kubectl create -f ./singlePod.yaml
I want the arguments called to match Docker:
docker run -it -p 8080:8080 joethecoder2/spring-boot-web cassandra_ip=127.0.0.1 cassandra_port=9042
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
env:
- name: "cassandra_ip"
value: "127.0.0.1"
- name: "cassandra_port"
value: "9042"
command: ["java","-jar", "spring-boot-web-0.0.1-SNAPSHOT.jar", "cassandra_ip=127.0.0.1", "cassandra_port=9042"]
args: ["$(cassandra_ip)", "$(cassandra_port)"]
restartPolicy: OnFailure
<!-- Paste the part of the code that shows the problem. (Please indent 4 spaces.) -->
The problem is that although the arguments have been added to the below service, the arguments do not take effect to the calling program (spring-boot-web-0.0.1-SNAPSHOT.jar)
Name: spring-boot-web-demo
Namespace: default
Node: minikube/192.168.64.3
Start Time: Thu, 07 Dec 2017 12:08:10 -0500
Labels: purpose=demonstrate-spring-boot-web
Annotations: <none>
Status: Running
IP: 172.17.0.2
Controllers: <none>
Containers:
spring-boot-web:
Container ID: docker://1c9543e412b50b36182528d690121014dfe7c9dd6409ce689d1a08fbad7c2436
Image: docker.io/joethecoder2/spring-boot-web
Image ID: docker-pullable://joethecoder2/spring-boot-web@sha256:ebf94365075e0ee16a50cab41d8e1307785a93c60be600f94bb82a4dbefb6bc0
Port:
Command:
java
-jar
spring-boot-web-0.0.1-SNAPSHOT.jar
cassandra_ip=127.0.0.1
cassandra_port=9042
Args:
$(cassandra_ip)
$(cassandra_port)
State: Running
Started: Thu, 07 Dec 2017 12:08:11 -0500
Ready: True
Restart Count: 0
Environment:
cassandra_ip: 127.0.0.1
cassandra_port: 9042
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-wgdn6 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-wgdn6:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-wgdn6
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
8m 8m 1 default-scheduler Normal Scheduled Successfully assigned spring-boot-web-demo to minikube
8m 8m 1 kubelet, minikube Normal SuccessfulMountVolume MountVolume.SetUp succeeded for volume "default-token-wgdn6"
8m 8m 1 kubelet, minikube spec.containers{spring-boot-web} Normal Pulling pulling image "docker.io/joethecoder2/spring-boot-web"
8m 8m 1 kubelet, minikube spec.containers{spring-boot-web} Normal Pulled Successfully pulled image "docker.io/joethecoder2/spring-boot-web"
8m 8m 1 kubelet, minikube spec.containers{spring-boot-web} Normal Created Created container
8m 8m 1 kubelet, minikube spec.containers{spring-boot-web} Normal Started Started container
I am expecting the results from the calling java program:
to use the cassandra_ip and cassandra_port
The service, does not properly show the arguments being displayed by the service, and also the running java program inside docker, does not show that the arguments are called.
Command:
java
-jar
spring-boot-web-0.0.1-SNAPSHOT.jar
cassandra_ip=127.0.0.1
cassandra_port=9042
Args:
$(cassandra_ip)
$(cassandra_port)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…