I have a Micronaut Application with the controller class like this:
@Controller("/murugesso")
public class Server {
@Get("debug/loadVins")
public MutableHttpResponse<String> loadVins(HttpRequest<?> request) {
new VinLoader().load();
return HttpResponse.ok().body("VIN load in progress...");
}
}
Kubernetest manifest looks like this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: murugesso
labels:
app: murugesso
spec:
selector:
matchLabels:
app: murugesso
template:
metadata:
labels:
app: murugesso
spec:
containers:
- name: murugesso
image: murugesso:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
name: murugesso
hostPort: 8080
When I run the app locally (through IDE or JAR), the following URL works:
http://localhost:8080/murugesso/debug/loadVins
But when I deploy the same application to kubernetes, I get a Micronaut error saying the URL was not found like this:
{"message":"Page Not Found","_links":{"self":{"href":"/murugesso/debug/loadVins","templated":false}}}
I have checked that I am using the same URL and also that the error is a Micronaut error, not kubernetes or network error.
EDIT: I checked the /routes
endpoint and it looks like none of the routes defined in my controller show up. Why is Micronaut not recognizing any of them? (Again, I've tried deploying the same image on minikube and it works perfectly!)
I figured this one out. The issue was never with Micronaut or with Kubernetes.
I had redundant entries in my pom, specifically the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.11</source>
<target>1.11</target>
</configuration>
</plugin>
This was causing an empty JAR to be built. The reason it was working locally was because IntelliJ was able to build the correct JAR somehow (and it seems like it was circumventing the pom).
Once I fixed my pom, the correct JAR was built and it worked in kubernetes.