<p>I'm trying to figure out how the docker command <code>docker run -p 8080:80 webapp</code> to kubernetes yaml. I have a nginx dockerized and the image works fine when I start it with the command mentioned above. When I push it to kubernetes, nothing happens. </p>

<p>Dockerfile:</p>

<pre><code>FROM nginx:1.13.3-alpine

COPY nginx/default.conf /etc/nginx/conf.d/

RUN rm -rf /usr/share/nginx/html/*

COPY ./dist /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]
</code></pre>

<p>My Kubernetes deployment</p>

<pre><code>kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: webapp-production
spec:
  replicas: 1
  template:
    metadata:
      name: webapp
      labels:
        app: webapp
        role: frontend
        env: production
    spec:
      containers:
      - name: webapp
        image: eu.gcr.io/projectxyz/webapp:1.0.0
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: ENVIRONMENT
          value: "production"
        resources:
          limits:
            memory: "500Mi"
            cpu: "100m"
        imagePullPolicy: Always
        ports:
        - name: webapp
          containerPort: 8080
</code></pre>

<p>My Service</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: webapp
spec:
  selector:
    app: webapp
    role: frontend
  type: NodePort
  ports:
  - name: http
    port: 8080
  - name: external
    port: 80
    targetPort: 8080
</code></pre>

<p>Do I have to run a command in kubernetes? Are the ports configured correct? Thanks for the help.</p>

<p>/////// Edit /////
Message from pod logs: <code>The selected container has not logged any messages yet.</code></p>

<p>You are targeting the wrong port here. From what I see this app starts nginx on port 80, yet your service definition targets port 8080 on endpoint pods. As there is no traffic reaching nginx, nothing will get logged on stdout access log. Change your service definition to direct traffic on correct port (80) and that should do the trick.</p>

<p>Sidenote: if container would not start / terminate prematurely you would probably see a crashloop state on your pod.</p>
