<p>In kubernetes, I always see the service's definition like this:</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: random-exporter
  labels:
    app: random-exporter
spec:
  type: ClusterIP
  selector:
    app: random-exporter
  ports:
    - port: 9800
      targetPort: http
      name: random-port
</code></pre>

<p>whose targetPort is <code>http</code>, it's human friendly！ </p>

<p>And what I'm interested is that is there more named port such as <code>http</code> in kubernetes? Maybe <code>https</code>？</p>

Liqang Liu
<p>Usually you refer to target port by its number. 
But you can give a specific name to each pod`s port 
and refer this name in your service specification. </p>

<p>This will make your service clearer.
Here you have example where you named your ports in pod. </p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - name: test
    ports:
    - name: http
      containerPort: 8080
    - name: https
      containerPort: 8443 
</code></pre>

<p>And here you refer to those ports by name in the service yaml. </p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: test-svc
spec:
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: https 
</code></pre>

<p>Also from the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#serviceport-v1-core" rel="nofollow noreferrer">kubernetes documention</a> you may find this information: </p>

<p><code>targetPort</code> - Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. 
If this is a string, it will be looked up as a named port in the target Pod's container ports. </p>
