【问题标题】:cannot expose specific Nodeport via kubectl无法通过 kubectl 公开特定的 Nodeport
【发布时间】:2019-10-25 04:17:57
【问题描述】:

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

【问题讨论】:

    标签: kubectl


    【解决方案1】:

    您混淆了目标端口、节点端口和端口。

    Here你可以找到完美的解释有什么区别。

    使用 nodePort 代替目标端口。更方便的公开应用程序的方法是创建和应用 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
    

    【讨论】:

    • yaml 文件有效,但我想知道是否可以通过 kubeclt 参数实现
    • 据我所知 - 这是不可能的
    猜你喜欢
    • 2019-07-26
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 1970-01-01
    • 2019-04-16
    • 2021-05-06
    • 2023-02-01
    • 1970-01-01
    相关资源
    最近更新 更多