HTTP Client (Declarative or Low Level) could not access internet from the pod [Micronaut 1.1.4]

7/18/2019

I built a simple micronaut project, which fetch Bintray like show in this tutorial.

When i access the container like this:

kubectl exec -it -n namespace demo sh

i can then execute a curl looking like this

curl -x proxy:port https://bintray.com/path

And it's work. Unfortunately the client inside my application calling the same url cannot succeed.

MyController.java

...
@Client("https://bintray.com/path/")
@Inject
RxHttpClient myclient;
...

application-k8s.yml

micronaut:
  http:
    client:
      proxy-address: proxy:port
      proxy-type: HTTP

While running test and testing on my local machine all is working.

But on Kubernetes i have the error :

io.micronaut.http.server.netty.RoutingInBoundHandler
io.micronaut.http.server.netty.RoutingInBoundHandler: 
Unexpected error occurred: Connect Error: bintray.com : System error

Edit 1

Dockerfile

FROM adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim
COPY target/demo*.jar demo.jar
ENV VERSION="v1.0"
CMD java -XX:+UnlockExperimentalVMOptions -Dcom.sun.management.jmxremote -noverify ${JAVA_OPTS} -jar demo.jar

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: demo-configmap
  labels:
    app: demo
    release: v1.0

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-deployment
  labels:
    app: demo
    release: v1.0
spec:
  selector:
    matchLabels:
      app: demo
      release: v1.0
  replicas: 1
  template:
    metadata:
      labels:
        app: demo
        release: v1.0
    spec:
      containers:
        - name: demo
          image: demo:v1.0
          imagePullPolicy: Always
          ports:
          - containerPort: 8080
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 30
            timeoutSeconds: 5
            failureThreshold: 6
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            timeoutSeconds: 3
            periodSeconds: 5

ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: demo-ingress
  labels:
    app: demo
    release: v1.0
  annotations:
    traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
spec:
  rules:
    - http:
        paths:
          - backend:
              serviceName: demo
              servicePort: 8080
            path: /demo

networkpolicy.yaml

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: demo-policy
  labels:
    app: demo
    release: v1.0
spec:
  podSelector:
    matchLabels:
      app: demo
      release: v1.0
  ingress:
    - ports:
        - port: 8080
          protocol: TCP

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: demo-service
  labels:
    app: demo
    release: v1.0
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 8080
      targetPort: 8080
  selector:
    app: demo
    release: v1.0

My question is to know what is the right configuration to make a micronaut work on kubernetes?

Is there any tutorial or an extended documentation about how to configure Micronaut for K8s?

-- 3logy
docker
kubernetes
micronaut

1 Answer

3/10/2020

With the Micronaut 1.2 everything seems to work.

-- 3logy
Source: StackOverflow