не может выставить определенный Nodeport через kubectl - PullRequest
0 голосов
/ 10 июня 2019

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#expose Нет необходимой документации

kubectl expose deployment hello-minikube --type=NodePort --port=8080 --target-port=30006
service/hello-minikube exposed

$ kubectl get svc 
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
hello-minikube   NodePort    10.110.117.25    <none>        8080:30751/TCP    21s

1 Ответ

0 голосов
/ 11 июня 2019

Вы путаете Target Port, Nodeport и Port.

Здесь вы можете найти идеальное объяснение, в чем разница.

Используйте nodePort вместо target-port.И более удобный способ выставить ваше приложение - создать и применить yaml:

apiVersion: v1
kind: Service
metadata:
  name: hello-minikube
spec:
  type: NodePort
  ports:
  - name: hello-minikube
    port: 8080
    targetPort: 8080
    nodePort: 30006
  selector:
    run: hello-minikube
...