<p>I would like to run a container in kubernetes with a static ip. I found out that only a service can provide an ip address. </p>

<p>Is it possible to map a Service to one pod and forward all ports? </p>

Mr Mueseli
<p>A service discovers pods based on <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/" rel="nofollow noreferrer">labels and selectors</a>. So it is not necessary to use an IP Address to statically reference a pod from a service. However, if you so wish, you can override the autonomy behind this and <a href="https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address" rel="nofollow noreferrer">manually configure</a> your own <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">ClusterIP</a> for the service. </p>

<p>Once the Pod and Service have been created, other pods in your cluster will be able to interact with the pod via the Name of the Service provided they are in the same namespace. If they are not, you will need to pass the <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">FQDN</a> of the service.</p>

<p>If you are trying to access the pod from <a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/" rel="nofollow noreferrer">outside of Kubernetes</a>, then you will need to use a Service with a different <code>type</code> than ClusterIP. For example, a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer">NodePort</a> or a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer">LoadBalancer</a>. Alternatively, if you have an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress Controller</a> with a gateway already provisioned you could use that. </p>

<p>With regards to you desire to <code>forward all ports</code>, this is not possible as port declarations in Service files must be <a href="https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services" rel="nofollow noreferrer">statically mapped</a>. It is not currently possible to pass a Port Range but there is a long standing <a href="https://www.google.com/search?q=kubernetes%20support%20port%20range%20github&amp;oq=kubernetes%20support%20port%20range%20github&amp;aqs=chrome..69i57.4531j0j1&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow noreferrer">feature request</a> for it. </p>
