我建立了一个简单的micronaut项目,该项目像本tutorial中的展示一样获取Bintray。
当我这样访问容器时:
kubectl exec -it -n namespace demo sh
然后我可以像这样执行卷曲
curl -x proxy:port https://bintray.com/path
而且有效。 不幸的是,我的应用程序内调用相同URL的客户端无法成功。
MyController.java
...
@Client("https://bintray.com/path/")
@Inject
RxHttpClient myclient;
...
application-k8s.yml
micronaut:
http:
client:
proxy-address: proxy:port
proxy-type: HTTP
在本地计算机上运行测试和测试时,一切正常。
但是在Kubernetes上我有错误:
io.micronaut.http.server.netty.RoutingInBoundHandler
io.micronaut.http.server.netty.RoutingInBoundHandler:
Unexpected error occurred: Connect Error: bintray.com : System error
编辑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
我的问题是要知道什么是使micronaut在kubernetes上正常工作的正确配置?
是否有关于如何为K8配置Micronaut的教程或扩展文档?
答案 0 :(得分:0)
使用Micronaut 1.2似乎一切正常。