我已经在ACR中部署了Java API并推送到Kubernetes。使用代理时,我可以将数据发布到服务中。但同一服务无法使用公开的端点运行。 PFB对应的Kubernetes YAML文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: taxservice-deployment
labels:
app: taxserviceapi
spec:
replicas: 1
template:
metadata:
name: taxserviceapi
labels:
app: taxserviceapi
spec:
containers:
- name: taxserviceapi
image : 3poacr.azurecr.io/3potaxservice:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
restartPolicy: Always
imagePullSecrets:
- name: regcret5
selector:
matchLabels:
app: taxserviceapi
---
apiVersion: v1
kind: Service
metadata:
name: taxservice-service
spec:
type: NodePort
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
app: taxserviceapi
externalTrafficPolicy: Local
答案 0 :(得分:2)
在服务定义中,您需要将规范类型从NodePort
替换为LoadBalancer
。
在此处查看更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
答案 1 :(得分:0)
将服务类型更改为LoadBalancer。 然后,您可以通过描述服务来检查暴露的端口:
kubectl describe svc taxservice-service