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

2/29/2020

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?

-- 3logy
castlemock
kubernetes
kubernetes-helm
tomcat

2 Answers

3/10/2020

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

-- 3logy
Source: StackOverflow

2/29/2020

Follow this guide to deploy a war file on tomcat running on kubernetes. You should be able to access it via the service itself and don't necessarily need ingress. Once you are able to access it via service then introduce ingress as an extra layer if needed.

Check this question as well.

-- Arghya Sadhu
Source: StackOverflow