<p>spec.rules[0].http.backend.servicePort: Invalid value: &quot;80&quot;: must contain at least one letter or number (a-z, 0-9)&quot;, Error while calling NetworkingV1beta1Api.createNamespacedIngress() api</p>
<p>I am using io.kubernetes:client-java-api:12.0.1 version as a dependency in gradle</p>
<p>Below is my ingress yaml file</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: myserver-userid
  namespace: myserver
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: userid-myserver
      http:
        paths:
          - backend:
              serviceName:  myserver
              servicePort: 80
  tls:
    - hosts:
        - userid-myserver
      secretName: myserver-tls
</code></pre>
<p>with below line I am creating NetworkingV1beta1Ingress object.</p>
<pre><code>NetworkingV1beta1Ingress codeServerV1Ingress = yaml.loadAs(ingressYamlFile, NetworkingV1beta1Ingress.class);
</code></pre>
<p>by calling below api I get error</p>
<pre><code>NetworkingV1beta1Ingress namespacedIngress = networkingV1beta1Api.createNamespacedIngress(&quot;myserver&quot;, codeServerV1Ingress, &quot;true&quot;, null, null);
</code></pre>
<p>error :</p>
<pre><code>spec.rules[0].http.backend.servicePort: Invalid value: \&quot;80\&quot;: must contain at least one letter or number (a-z, 0-9)
</code></pre>
<p>I could see this error is related to IntOrString Class but not sure Why it. is throwing error and. failing the api call ? can someone pls help on this ?</p>
<p>even I tried with both approaches below</p>
<pre><code>approach 1:  servicePort: 80
approach 2:  servicePort: &quot;80&quot;
</code></pre>
<p>I have also done google search on existing issues but none of them were helpful for me.</p>

ss-ss-v1
<p>For starters, v1beta1 annotation is deprecated and v1 should be used instead. <strong>Pathtype</strong> should also be specified.</p>
<p><strong>PathType</strong> determines the interpretation of the Path matching, and can be one of the following values:</p>
<ol>
<li><strong>Exact</strong>: Matches the URL path exactly.</li>
<li><strong>Prefix</strong>: Matches based on a URL path prefix split by '/'. Matching is done on a path element by element basis. A path element refers is the list of labels in the path split by the '/' separator. A request is a match for path p if every p is an element-wise prefix of p of the request path. Note that if the last element of the path is a substring of the last element in request path, it is not a match (e.g. /foo/bar matches /foo/bar/baz, but does not match /foo/barbaz).</li>
<li><strong>ImplementationSpecific</strong>: Interpretation of the Path matching is up to the IngressClass. Implementations can treat this as a separate PathType or treat it identically to Prefix or Exact path types. Implementations are required to support all path types.</li>
</ol>
<p>Lastly, the backend service definition has changed. Try the bellow example:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-router
  namespace: example-router
  annotations:
    cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;
    #acme.cert-manager.io/http01-edit-in-place: &quot;true&quot;
    #acme.cert-manager.io/http01-ingress-class: &quot;nginx&quot;
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  tls:
  - hosts:
    - examlpe.com
    - www.examlpe.com
    secretName: example-tls-secret
  rules:
  - host: examlpe.com
    http:
      paths:
      - pathType: ImplementationSpecific
        path: &quot;/&quot;
        backend:
          service:
            name: backend-service
            port: 
              number: 80
</code></pre>
<p>Keep in mind that the backed service, and the ingress <strong>must</strong> belong to the <strong>same namespace</strong>.</p>
<p>PS: The first 3 annotations are essential if you will use CertManager to issue valid certificates in the future.</p>
