Reputation: 334
I am setting up Kubernetes in a RedHat server in my institution, the server has an internal IP of 10.2.3.4. I can only view the pod by using kubectl port-forward. e.g
My traefik service has the following:
#minikube service list
| kube-system | traefik | web/80 | http://172.17.0.3:31909 |
| | | websecure/443 | http://172.17.0.3:30584 |
| | | admin/9001 | http://172.17.0.3:32316 |
|-------------|------------|---------------|-------------------------|
Now I can only curl this link
$curl http://172.17.0.3:32316/dashboard/
<!DOCTYPE html><html><head><title>Traefik</title><meta charset=utf-8> ........
However, if I want to preview the admin dashboard on my browser on 9001 port, the only way I have found yet is though port-forward:
kubectl port-forward -n kube-system $(kubectl get pods --output=name -n kube-system | grep 'traefik') --address 10.2.3.4 9001:9001
I tried to set externalIPs
on service YAML settings but it doesn't work:
# Service
---
apiVersion: v1
kind: Service
metadata:
labels:
app: traefik
release: traefik
name: traefik
namespace: kube-system
spec:
externalIPs:
- 10.2.3.4
externalTrafficPolicy: Local
ports:
- name: web
nodePort: 31909
port: 3838
protocol: TCP
targetPort: 3838
- name: admin
nodePort: 32316
port: 9001
protocol: TCP
targetPort: 9001
selector:
app: traefik
release: traefik
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
I know the port-forward should be used in debug mode, I cannot add my own domain since it is restricted in my institution, I wonder if there are settings I should make the kubernete services exposed to 10.2.3.4?
Upvotes: 0
Views: 1221
Reputation: 151
Simple way to expose your service is
kubectl expose deployment *name* --type=LoadBalancer --name=trafik
name - says deployement name which you should have given in deployment.yaml
I am assuming, you use traefik as Gateway/LoadBalancer here. You can use the same execution for any services to expose internal IP.
Upvotes: 1