gpt4 book ai didi

kubernetes - 在 Kubernetes 上安装 nginx-ingress 以在 localhost MacOs 上运行 - Docker for Mac(Edge)

转载 作者:行者123 更新时间:2023-12-04 15:07:12 24 4
gpt4 key购买 nike

更新:

我让 NodePort 正常工作:kubectl get services

NAME                                       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7d
my-release-nginx-ingress-controller NodePort 10.105.64.135 <none> 80:32706/TCP,443:32253/TCP 10m
my-release-nginx-ingress-default-backend ClusterIP 10.98.230.24 <none> 80/TCP 10m

那我要转发吗?

在 Docker for Mac(Edge with Kubernetes)上使用 Helm 安装 Ingress

https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress

这将在本地主机上工作 - 如果是这样,如何访问服务?

脚步:
  • helm install stable/nginx-ingress

  • 输出:
    NAME:   washing-jackal
    LAST DEPLOYED: Thu Jan 18 12:57:40 2018
    NAMESPACE: default
    STATUS: DEPLOYED

    RESOURCES:
    ==> v1/ConfigMap
    NAME DATA AGE
    washing-jackal-nginx-ingress-controller 1 1s

    ==> v1/Service
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    washing-jackal-nginx-ingress-controller LoadBalancer 10.105.122.1 <pending> 80:31494/TCP,443:32136/TCP 1s
    washing-jackal-nginx-ingress-default-backend ClusterIP 10.103.189.14 <none> 80/TCP 1s

    ==> v1beta1/Deployment
    NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
    washing-jackal-nginx-ingress-controller 1 1 1 0 0s
    washing-jackal-nginx-ingress-default-backend 1 1 1 0 0s

    ==> v1/Pod(related)
    NAME READY STATUS RESTARTS AGE
    washing-jackal-nginx-ingress-controller-5b4d86c948-xxlrt 0/1 ContainerCreating 0 0s
    washing-jackal-nginx-ingress-default-backend-57947f94c6-h4sz6 0/1 ContainerCreating 0 0s


    NOTES:
    The nginx-ingress controller has been installed.
    It may take a few minutes for the LoadBalancer IP to be available.
    You can watch the status by running 'kubectl --namespace default get services -o wide -w washing-jackal-nginx-ingress-controller'

    An example Ingress that makes use of the controller:

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
    annotations:
    kubernetes.io/ingress.class: nginx
    name: example
    namespace: foo
    spec:
    rules:
    - host: www.example.com
    http:
    paths:
    - backend:
    serviceName: exampleService
    servicePort: 80
    path: /
    # This section is only required if TLS is to be enabled for the Ingress
    tls:
    - hosts:
    - www.example.com
    secretName: example-tls

    If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:

    apiVersion: v1
    kind: Secret
    metadata:
    name: example-tls
    namespace: foo
    data:
    tls.crt: <base64 encoded cert>
    tls.key: <base64 encoded key>
    type: kubernetes.io/tls

    最佳答案

    据我从您发布的输出中可以看出,一切都应该在您本地的 kubernetes 集群中顺利运行。

    但是,您的入口 Controller 使用 LoadBalancer Service 公开从您发布的输出的以下部分可以看出:

    ==> v1/Service
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    washing-jackal-nginx-ingress-controller LoadBalancer 10.105.122.1 <pending> 80:31494/TCP,443:32136/TCP 1s

    LoadBalancer 类型的服务需要底层基础架构的支持,并且不会在您的本地环境中运行。

    但是,LoadBalancer 服务也是 NodePort服务。事实上,您可以在上面的输出片段中看到您的入口 Controller 正在监听以下端口:
    80:31494/TCP,443:32136/TCP

    这意味着您应该能够通过节点 IP 地址的端口 31494 和 32136 访问入口 Controller 。

    您可以让入口 Controller 监听更多标准端口,例如 80 和 443,但您可能必须手动编辑由 helm chart 创建的资源才能这样做。

    关于kubernetes - 在 Kubernetes 上安装 nginx-ingress 以在 localhost MacOs 上运行 - Docker for Mac(Edge),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48320992/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com