如何设置k8来访问在Kubernetes上部署的tomcat中运行的应用程序?

问题描述 投票:0回答:1

我对Kubernetes还是很陌生,所以我已经使用头盔3将castlemock应用程序部署在Kubernetes容器中。

这里是舵对象。

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 objets来访问由tomcat运行的应用程序?

tomcat kubernetes kubernetes-helm castlemock
1个回答
0
投票

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

也要检查此question

© www.soinside.com 2019 - 2024. All rights reserved.