Search code examples
tomcatkuberneteskubernetes-helm

How set k8s to access the application running in tomcat deployed on Kubernetes?


I'm pretty new to Kubernetes, so i have deployed the castlemock application in a Kubernetes pod using helm 3.

Here are the helm objects.

values.yml (not the whole content):

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 (not the whole content):

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

And then I do the port forward: kubectl port-forward svc/castlemock 3000:8080

From the people behind castlemock, the application can be access behind the path /castlemock.

But when I try localhost:3000 I see the tomcat homepage, when I try localhost:3000/castlemock I have a 404.

Did I messed up something or how should the Kubernetes objets be set to access applications running by tomcat?


Solution

  • I made it works by following the steps listed in this castlemock tutorial on dev.to