I'm trying to expose a port 8080 on a pod, so I can wget directly from server. With port-forward everything works fine (kubectl --namespace jenkins port-forward pods/jenkins-6f8b486759-6vwkj 9000:8080
) , I'm able to connect to 127.0.0.1:9000
But when I try to avoid port-forward and open ports permanently (kubectl expose deployment jenkins --type=LoadBalancer -njenkins
):
I see it in svc (kubectl describe svc jenkins -njenkins
):
Name: jenkins
Namespace: jenkins
Labels: <none>
Annotations: <none>
Selector: app=jenkins
Type: LoadBalancer
IP Families: <none>
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: <none>
but port is still not up, netstat does not show anything. How it should be done correctly?
Using minikube version: v1.20.0 , pod yaml just in case:
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
CodePudding user response:
What is your environment ? Are you running your local k8s cluster with docker desktop/minikube/kubeadm ?
CodePudding user response:
Check that your Pods have external IPs with kubectl get pods -o=wide
Load Balancing is not supposed to be implemented on your single node machine (with Minikube), there is a somehow a "hack"
If you are deploying your cluster on a Cloud provider, Load Balancer would be fully-managed
For the "hack" i talk about, look at this tutorial video section on Ingress component explained : https://youtu.be/X48VuDVv0do?t=7312
You are expected to place a Pod with a nginx server in front of your ingress, in front of your loadbalancer, in front of your deployment Pods