<p>Setup on machine:</p>
<ul>
<li>Ubuntu 20.04</li>
<li>Kubernetes cluster started with kubeadm and flannel network plugin</li>
</ul>
<p>On my working machine I installed Jenkins on cluster and want to configure network to be able to access jenkins from port 8081. By default it's possible only to forwarded port (30667 in my case). Is it possible on ubuntu?</p>
<pre><code>NAME                           READY   STATUS    RESTARTS   AGE
pod/jenkins-5b6cb84957-n497l   1/1     Running   4          93m

NAME                 TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
service/jenkins      LoadBalancer   10.96.81.85   &lt;pending&gt;     8081:30667/TCP   93m
service/kubernetes   ClusterIP      10.96.0.1     &lt;none&gt;        443/TCP          94m

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/jenkins   1/1     1            1           93m

NAME                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/jenkins-5b6cb84957   1         1         1       93m

NAME                              COMPLETIONS   DURATION   AGE
job.batch/pv-recycler-generator   1/1           5s         42s
</code></pre>
<p>Tried also with calico network plugin - same result</p>
<p>But before I worked with Docker desktop on Mac and Windows where it was possible out of box</p>

<p>Service type of <code>Loadbalancer</code>  works best when you run it on cloud because cloud provisioners will automate the process of creating external loadbalancer for you and configuring it to work with Kubernetes. In case when working on prem this whole process has to be done by you. You have do it yourself or use 3rd party tools to do that, e.g. <a href="https://metallb.universe.tf/" rel="nofollow noreferrer">Metallb</a>.</p>
<p>Notice the pending field in the <code>External-ip</code> column. The easiest way would be to set it manually to IP address of your node.</p>
<p>First you have get your node ip:</p>
<pre class="lang-sh prettyprint-override"><code>➜  ~ k get node -owide
NAME         STATUS     ROLES    AGE    VERSION      INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION    CONTAINER-RUNTIME
instance-1    Ready      master   221d   v1.17.0  👉 10.128.15.230   &lt;none&gt;        Ubuntu 16.04.6 LTS   4.15.0-1090-gcp   docker://18.6.1
</code></pre>
<p>Then add this IP address in the <code>externalIPs</code> field in the service spec:</p>
<pre class="lang-yaml prettyprint-override"><code>➜  ~ cat loadbalancer.yml 
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  externalIPs: 
  - 10.128.15.230 👈
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer
</code></pre>
<p>One you do that you will be able to see that external IP is no longer pending:</p>
<pre class="lang-sh prettyprint-override"><code>NAME                  TYPE           CLUSTER-IP        EXTERNAL-IP     PORT(S)                      AGE
my-service            LoadBalancer   10.101.150.192 👉 10.128.15.230   80:11438/TCP                 5m1s
</code></pre>
<p>And then you just have use that external IP with the <code>nodePort</code> that <code>kube-proxy</code> opened on that node:</p>
<pre class="lang-sh prettyprint-override"><code>➜  ~ curl 10.128.15.230:11438 
{
  &quot;path&quot;: &quot;/&quot;,
  &quot;headers&quot;: {
    &quot;host&quot;: &quot;10.128.15.230:11438&quot;,
    &quot;user-agent&quot;: &quot;curl/7.47.0&quot;,
    &quot;accept&quot;: &quot;*/*&quot;
  },
  &quot;method&quot;: &quot;GET&quot;,
  &quot;body&quot;: &quot;&quot;,
  &quot;fresh&quot;: false,
  &quot;hostname&quot;: &quot;10.128.15.230&quot;,
  &quot;ip&quot;: &quot;::ffff:10.128.15.230&quot;,
  &quot;ips&quot;: [],
  &quot;protocol&quot;: &quot;http&quot;,
  &quot;query&quot;: {},
  &quot;subdomains&quot;: [],
  &quot;xhr&quot;: false,
  &quot;os&quot;: {
    &quot;hostname&quot;: &quot;label-demo&quot;
  },
  &quot;connection&quot;: {}
</code></pre>
