首页 文章

helm chart不会将ip地址暴露给ping localhost:port

提问于
浏览
0

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

我试图ping本地主机: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

1 回答

  • 2

    由于 minikube 来自docker-machine系列,因此运行 minikube ip 将输出虚拟机的IP地址, that 是您应尝试联系群集的IP,而不是localhost .

    此外, [debug] Created tunnel using local port: '58064'helm Build 到集群内嵌入式 tiller Pod的隧道,并不是您应该使用的任何东西 . 这实际上是为什么它以 [debug] 为前缀:因为它仅适用于极端情况 .

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

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

相关问题