<p>Here is an example of yaml file for deploying:</p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  backend:
    serviceName: gateway-service
    servicePort: 4001
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway-deployment
spec:
  selector:
    matchLabels:
      app: gateway
  replicas: 2
  template:
    metadata:
      labels:
        app: gateway
    spec:
      containers:
      - name: gateway
        image: hello-go-microservices_gateway
        imagePullPolicy: Never
        ports:
        - containerPort: 4001
          protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: gateway-service
spec:
  selector:
    app: gateway
  ports:
  - protocol: TCP
    port: 4001
    targetPort: 4001
    nodePort: 30001
  type: NodePort
</code></pre>

<p>As you can see, the service is called <strong>gateway-service</strong>. The problem is when I rename it to just <strong>gateway</strong>, it's pods won't start. When I rename it to <strong>gateway-service</strong> back, or rename it to <strong>gateway1</strong>, or to <strong>gateway-blablabla</strong>, everytging works well. </p>

<p>Kubectl's logs show: </p>

<pre><code>Failed to decode: strconv.ParseInt: parsing "tcp://10.101.177.91:4001": invalid syntax
</code></pre>

ligowsky
<p>Thanks to <a href="https://stackoverflow.com/questions/58445138/naming-a-service-in-kubernetes-prevents-it-from-starting/58446435#">P Ekambaram</a> suggestion and just to provide more information for other community members in case they will have the same issue:</p>

<p>According to the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services" rel="nofollow noreferrer">Discovering services</a> mechanism - once the service was created all information where applied to the PODS env:</p>

<p>Note:</p>

<blockquote>
  <p>When a Pod is run on a Node, the kubelet adds a set of environment variables for each active Service. It supports both Docker links compatible variables (see makeLinkVariables) and simpler {SVCNAME}_SERVICE_HOST and {SVCNAME}_SERVICE_PORT variables, where the Service name is upper-cased and dashes are converted to underscores.</p>
</blockquote>

<p>Proper env variables should looks like:</p>

<pre><code>GATEWAY_PORT_8080_TCP=tcp://10.4.13.154:8080
GATEWAY_PORT_8080_TCP_PROTO=tcp
GATEWAY_PORT_8080_TCP_PORT=8080
GATEWAY_PORT_8080_TCP_ADDR=10.4.13.154

GATEWAY_SERVICE_HOST=10.4.13.154
GATEWAY_SERVICE_PORT=8080
</code></pre>

<p>and values for:
 GATEWAY_PORT=tcp://10.4.13.154:8080
were overridden by your custom settings:</p>

<pre><code> GATEWAY_PORT=8080
</code></pre>
