【问题标题】:helm chart will not expose ip address to ping localhost:porthelm chart 不会向 ping localhost:port 公开 IP 地址
【发布时间】:2018-11-22 09:35:39
【问题描述】:

我在 MacOS 上运行 minikube,并希望公开 ip 地址和端口以运行此示例舵图 - https://docs.bitnami.com/kubernetes/how-to/create-your-first-helm-chart/

我尝试 ping localhost:58064,但无法连接。

helm install --dry-run --debug ./mychart --set service.internalPort=8080
[debug] Created tunnel using local port: '58064'

[debug] SERVER: "127.0.0.1:58064"

[debug] Original chart version: ""
[debug] CHART PATH: /Users/me/Desktop/HelmTest/mychart

NAME:   messy-penguin
REVISION: 1
RELEASED: Tue Jun 12 17:56:41 2018
CHART: mychart-0.1.0
USER-SUPPLIED VALUES:
service:
  internalPort: 8080

COMPUTED VALUES:
affinity: {}
image:
  pullPolicy: IfNotPresent
  repository: nginx
  tag: stable
ingress:
  annotations: {}
  enabled: false
  hosts:
  - chart-example.local
  path: /
  tls: []
nodeSelector: {}
replicaCount: 1
resources: {}
service:
  internalPort: 8080
  port: 80
  type: ClusterIP
tolerations: []

HOOKS:
MANIFEST:

---
# Source: mychart/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: messy-penguin-mychart
  labels:
    app: mychart
    chart: mychart-0.1.0
    release: messy-penguin
    heritage: Tiller
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app: mychart
    release: messy-penguin
---
# Source: mychart/templates/deployment.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: messy-penguin-mychart
  labels:
    app: mychart
    chart: mychart-0.1.0
    release: messy-penguin
    heritage: Tiller
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mychart
      release: messy-penguin
  template:
    metadata:
      labels:
        app: mychart
        release: messy-penguin
    spec:
      containers:
        - name: mychart
          image: "nginx:stable"
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {}
MacBook-Pro:~/Desktop/HelmTest quantum-fusion$ curl 127.0.0.1:58064
curl: (7) Failed to connect to 127.0.0.1 port 58064: Connection refused

【问题讨论】:

    标签: kubernetes minikube kubernetes-helm


    【解决方案1】:

    因为 minikube 来自 docker-machine 系列,运行 minikube ip 将输出虚拟机的 IP 地址,而 那个 是您应该尝试联系集群的 IP ,而不是本地主机。

    此外,[debug] Created tunnel using local port: '58064'helm 为集群内的嵌入式 tiller Pod 建立隧道,根本不应该使用任何东西。这实际上就是为什么它以 [debug]: 为前缀的原因,因为它只在极端情况下有用。

    最后,您将需要使用 kubectl port-forward 来访问您部署的 Pod,因为 Service 使用的是 ClusterIP,顾名思义,它只在集群内部有效。您还可以创建type: NodePort 的第二个Service,它将在虚拟机的IP 上分配一个TCP/IP 端口,该端口路由到Serviceport:。您也许可以通知您的 Helm 图表为您执行此操作,具体取决于作者是否通过图表的 values.yaml 公开了这种决定。

    port-forwardtype: NodePort 部分的 Service 的另一个“星号”是我在输出中看到提到了 chart-example.localIngress 资源,但这实际上只有在你有一个正在运行的“入口控制器”,但如果你这样做了,那么它已经有一个 TCP/IP 端口,你应该在该端口上联系你的集群,只要确保你提供了一个 curl -H "host: chart-example.local" http://$(minikube ip):${the_ingress_port} 的连接,所以入口控制器可以将请求路由到正确的Ingress

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2013-09-08
      • 2012-07-15
      • 1970-01-01
      相关资源
      最近更新 更多