我有一个简单的节点api服务,mongo服务和负载平衡器。
我正在尝试使用kubernetes部署我的应用程序,运行命令时出现以下错误。
- kubectl describe ing -n my-service
警告错误5秒(x2超过8秒)aws-alb-ingress-controller错误 实例化负载均衡器:my-service-api服务类型不正确 NodePort和目标类型是实例
kind: Namespace
apiVersion: v1
metadata:
name: my-service
labels:
name: my-service
---
#MongoDB
apiVersion: v1
kind: Service
metadata:
name: mongo
namespace: my-service
labels:
run: mongo
spec:
ports:
- port: 27017
targetPort: 27017
protocol: TCP
selector:
run: mongo
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mongo
namespace: my-service
spec:
template:
metadata:
labels:
run: mongo
spec:
containers:
- name: mongo
image: mongo
ports:
- containerPort: 27017
---
apiVersion: v1
kind: Service
metadata:
name: my-service-api
namespace: my-service
labels:
app: my-service-api
spec:
selector:
app: my-service-api
ports:
- port: 3002
protocol: TCP
nodePort: 30002
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: my-service-api-deployment
namespace: my-service
spec:
replicas: 1
template:
metadata:
labels:
app: my-service-api
spec:
containers:
- name: my-service-api
image: <removed>
imagePullPolicy: Always
env: <removed>
ports:
- containerPort: 3002
imagePullSecrets:
- name: regcred
---
#LoadBalancer
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-service-api
namespace: my-service
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: instance
alb.ingress.kubernetes.io/tags: Name=my-service-api,Owner=devops,Project=my-service,Stage=development
spec:
rules:
- host: <removed>
http:
paths:
- path: /
backend:
serviceName: my-service-api
servicePort: 3002
有人可以告诉我我在这里做错了吗,谢谢。
答案 0 :(得分:0)
您的my-service-api
服务类型似乎是“ LoadBalancer”,并且您需要使用“ NodePort” 才能将instance
用于alb.ingress.kubernetes.io/target-type:
< / p>
这个封闭的github issue可能对您有用