How to show hostname or pod infos in kubernetes with an echoserver?

5/29/2018

I am searching for the command to print out the podname (or hostname) when I call my echoserver (gcr.io/google_containers/echoserver. I saw that in a video, regarding loadbalancing and ingress as a proof of concept, to show which server responds when I hit the refresh button in the browser. But I cannot remember how that worked or where that was. I searched the web but didn't find any hint.

At the moment my ReplicaSet looks like this: Maybe I am missing an env variable or something like this.

apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
  name: echoserver
spec:
  replicas: 1
  template:
    metadata:
      name: echoserver
      labels:
        project: chapter5
        service: echoserver
    spec:
      containers:
      - name: echoserver
        image: gcr.io/google_containers/echoserver:1.4
        ports:
        - containerPort: 8080
-- Jan
kubernetes

1 Answer

5/29/2018

I got it: I have to raise the Version!

With versions greater than 1.4 it works :-)

So the correct one is the actual version 1.10:

apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
  name: echoserver
spec:
  replicas: 1
  template:
    metadata:
      name: echoserver
      labels:
        project: chapter5
        service: echoserver
    spec:
      containers:
      - name: echoserver
        image: gcr.io/google_containers/echoserver:1.10
        ports:
        - containerPort: 8080
-- Jan
Source: StackOverflow