【问题标题】:Helm: How to access an MVC Core WebAPI Endpoint?Helm:如何访问 MVC Core WebAPI 端点?
【发布时间】:2018-03-09 16:59:09
【问题描述】:

首先,我是 Helm 的新手。我正在尝试从 Docker Hub 部署一个名为 mooo999/webapi 的 .Net Core WebApi。我在本地测试过,效果很好。几天来我一直在摆弄这个,无法运行最简单的图表。 Deployment.yaml 是:

    apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "foochart.fullname" . }}
  labels:
    app: {{ template "foochart.name" . }}
    chart: {{ template "foochart.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "foochart.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "foochart.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: mooo999/webapi
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /api/values
              port: http
          readinessProbe:
            httpGet:
              path: /api/values
              port: http
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}

service.yaml 是:

apiVersion: v1
kind: Service
metadata:
  name: {{ template "foochart.fullname" . }}
  labels:
    app: {{ template "foochart.name" . }}
    chart: {{ template "foochart.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app: {{ template "foochart.name" . }}
    release: {{ .Release.Name }}

不确定它会比这简单得多。我正在部署 Azure AKS,它部署良好,没有错误。我可以使用以下方法获取端点:端口:

kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services callous-guppy kubectl 获取节点 --namespace default -o jsonpath="{.items[0].status.addresses[0].address}" 但是在浏览器中使用此信息时出现 [Fiddler] 错误 与“10.240.0.4”的连接失败。 错误:超时 (0x274c)。

System.Net.Sockets.SocketException 连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应 10.240.0.4:32678

我需要入口服务吗?有没有人有一个简单的图表,实际上以某种方式公开了一个公共端点?我已经经历了无数的例子,但没有一个是成功的。

【问题讨论】:

    标签: kubernetes-helm


    【解决方案1】:

    创建chart时默认的ingress.yaml就足够了,只需要在后端服务中添加服务名,并设置ingress为启用即可。

    您也可以尝试使用负载均衡器作为服务类型来测试端点

    【讨论】:

      猜你喜欢
      • 2019-12-27
      • 2018-12-11
      • 1970-01-01
      • 2013-12-16
      • 1970-01-01
      • 2021-07-07
      • 1970-01-01
      • 2014-09-02
      • 2018-11-19
      相关资源
      最近更新 更多