【问题标题】:How set k8s to access the application running in tomcat deployed on Kubernetes?如何设置 k8s 访问部署在 Kubernetes 上的 tomcat 中运行的应用程序?
【发布时间】:2020-03-10 22:08:33
【问题描述】:

我对 Kubernetes 很陌生,所以我使用 helm 3 在 Kubernetes pod 中部署了 castlemock 应用程序。

这里是 helm 对​​象。

values.yml(不是全部内容):

replicaCount: 1

image:
  repository: castlemock/castlemock
  tag: 1.39
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 80

ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: traefik
  hosts:
    - host: chart-example.local
      paths:
      - /castlemock

deployment.yml(不是全部内容):

containers:
    - name: {{ .Chart.Name }}
      securityContext:
        {{- toYaml .Values.securityContext | nindent 12 }}
      image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
      imagePullPolicy: {{ .Values.image.pullPolicy }}
      ports:
        - name: http
          containerPort: 8080
          protocol: TCP
      livenessProbe:
        httpGet:
          path: /
          port: http
      readinessProbe:
        httpGet:
          path: /
          port: http

然后我做端口转发:kubectl port-forward svc/castlemock 3000:8080

从 castlemock 背后的人那里,可以通过路径 /castlemock 访问应用程序。

但是当我尝试 localhost:3000 时,我看到了 tomcat 主页,当我尝试 localhost:3000/castlemock 时,我看到了 404。

我是不是搞砸了,或者应该如何设置 Kubernetes 对象以访问由 tomcat 运行的应用程序?

【问题讨论】:

    标签: tomcat kubernetes kubernetes-helm


    【解决方案1】:

    按照这个guide 在运行在 kubernetes 上的 tomcat 上部署一个 war 文件。您应该能够通过服务本身访问它,并且不一定需要入口。一旦您能够通过服务访问它,然后在需要时将入口作为额外层引入。

    也检查这个question

    【讨论】:

      【解决方案2】:

      我按照 dev.to 上的 castlemock tutorial 中列出的步骤使其工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多