I am testing out a kubernetes 1.1.7 setup (on AWS). This has been installed following standard procedures (http://kubernetes.io/v1.1/docs/getting-started-guides/aws.html) and it's all working fine.
I have tried to fireup the most simple replication controller of a pod with two containers (because I wanted to play around multi-container pods, which are not the norm but still something that could be done). This is the RC:
apiVersion: v1
kind: Pod
metadata:
name: test
labels:
app: web
spec:
containers:
- name: "80"
image: "jonlangemak/docker:web_container_80"
ports:
- containerPort: 80
- name: "8080"
image: "jonlangemak/docker:web_container_8080"
ports:
- containerPort: 8080
I was expecting this to generate 2 application containers as well as a system container "pause" which would hold the two port mappings (80 and 8080).
However, if I go on the landing host and I do a docker ps this is what I see:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a15f633fff9 jonlangemak/docker:web_container_8080 "/usr/bin/supervisor 23 seconds ago Up 22 seconds k8s_8080.cf4f64ab_test_default_1dc9f591-d976-11e5-88b3-06da266e4957_6e389304
0ff0b6cdd4ae jonlangemak/docker:web_container_80 "/usr/bin/supervisor 23 seconds ago Up 23 seconds k8s_80.b7c46373_test_default_1dc9f591-d976-11e5-88b3-06da266e4957_90173279
84e3d7ea12c9 gcr.io/google_containers/pause:0.8.0 "/pause" 23 seconds ago Up 23 seconds k8s_POD.c16231a_test_default_1dc9f591-d976-11e5-88b3-06da266e4957_78c2a5e9
Interestingly, everything works fine and I can curl the pod IP for both port 80 and port 8080 and I get what I am expecting to get BUT the fact that I don't see the proper port mappings on the "pause" container leaves me a bit "uh? why?".
Thoughts?
Thanks.
There won't be any port mapping unless you set the HostPort property on the corresponding port
.
Instead of doing that, you should use a Service to expose your application. This abstraction will give your application a single IP adress and act as a local load balancer within your cluster.
You can read more about Kubernetes service
resource in the official Kubernetes user documentation