<p>I'm trying to expose a port 8080 on a pod, so I can wget directly from server. With port-forward everything works fine (<code>kubectl --namespace jenkins port-forward pods/jenkins-6f8b486759-6vwkj 9000:8080</code>) , I'm able to connect to 127.0.0.1:9000</p>
<p>But when I try to avoid port-forward and open ports permanently (<code>kubectl expose deployment jenkins --type=LoadBalancer -njenkins</code>):
I see it in svc (<code>kubectl describe svc jenkins -njenkins</code>):</p>
<pre><code>Name:                     jenkins
Namespace:                jenkins
Labels:                   &lt;none&gt;
Annotations:              &lt;none&gt;
Selector:                 app=jenkins
Type:                     LoadBalancer
IP Families:              &lt;none&gt;
IP:                       10.111.244.192
IPs:                      10.111.244.192
Port:                     port-1  8080/TCP
TargetPort:               8080/TCP
NodePort:                 port-1  31461/TCP
Endpoints:                172.17.0.2:8080
Port:                     port-2  50000/TCP
TargetPort:               50000/TCP
NodePort:                 port-2  30578/TCP
Endpoints:                172.17.0.2:50000
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;
</code></pre>
<p>but port is still not up, <code>netstat</code> does not show anything. How it should be done correctly?</p>
<p>Using minikube version: v1.20.0 , pod yaml just in case:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      securityContext:

      containers:
      - name: jenkins
        image: jenkins/jenkins:lts

        ports:
          - name: http-port
            containerPort: 8080
            hostPort: 8080
          - name: jnlp-port
            containerPort: 50000
        volumeMounts:
          - name: task-pv-storage
            mountPath: /var/jenkins_home
      volumes:
        - name: task-pv-storage
          persistentVolumeClaim:
            claimName: task-pv-claim

</code></pre>

Lev Bystritskiy
<p>I see that you are running your k8s cluster locally, in this case, LoadBalancer ServiceType is not recommended as this type uses cloud providers' load balancer to expose services externally. You might use a self-hosted or hardware load balancer but I suppose it's a bit overkill for minikube cluster.</p>
<p>In your minikube deployment, I'd suggest using NodePort Service Type as it uses IP address of your node to expose service. Example YAML:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
spec:
  type: NodePort
  selector:
    app: jenkins
  ports:
    - port: 8080
      targetPort: 8080
      # nodePort field is optional, Kubernetes will allocate port from a range 30000-32767, but you can choose 
      nodePort: 30007
    - port: 50000
      targetPort: 50000     
      nodePort: 30008
  
</code></pre>
<p>Then, you can access your app on <code>&lt;NodeIP&gt;:&lt;nodePort&gt;</code>. If you want to read more about k8s Services go <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">here</a>.</p>
