我正在做一个项目,我已经部署了alb-ingress-controller,并且EKS中部署了服务
添加入口 alb 后创建,但我的服务未正确呈现。
这是入口资源、服务和端口,当我将这些服务作为映像运行时,它们运行良好。
知道出了什么问题吗,我已经用 helm 部署了 alb-ingress-controller
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: applications-ingress
namespace: applications
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}]'
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /mocktest
pathType: Prefix
backend:
service:
name: mocktest-frontend
port:
number: 4000
- path: /library-app
pathType: Prefix
backend:
service:
name: library-app
port:
number: 3000
用于基础设施部署的通量
这个 helm 发布文件,任何人都知道这里出了什么问题
示例错误:http://k8s-applicat-applicat-3e293401b4-218248430.ap-south-1.elb.amazonaws.com/library-app
无法加载资源:服务器响应状态为 404(未找到)
spec:
releaseName: aws-load-balancer-controller
chart:
spec:
chart: aws-load-balancer-controller
version: 1.8.2
sourceRef:
kind: HelmRepository
name: eks-charts
interval: 1h
values:
clusterName: eks-project
serviceAccount:
create: false
name: aws-load-balancer-controller
interval: 1h
这两个服务都有相同的错误,一个是 nextapp ,一个是 React app ,无法获取文件
在此输入图片描述
并再次部署 nginx 服务:
nginx:latest
这也给了400
根据您的评论,如果我做对了,您应该修改 Nginx 配置(假设您从 Nginx 提供静态文件):
server {
listen 4000;
server_name _;
# Serve the main app files
location /mocktest-app/ {
alias /var/www/build/mocktest-app/;
try_files $uri $uri/ /mocktest-app/index.html;
}
# Serve static files
location /mocktest-app/static/ {
alias /var/www/build/mocktest-app/static/;
expires max;
access_log off;
log_not_found off;
}
}
假设您已将构建应用程序复制到
mocktest-app
目录
COPY ./mocktest-frontend/build/ /var/www/build/mocktest-app/
WORKDIR /var/www/build
入口应该有一个路径
/mocktest-app
,将请求转发到 k8s 服务模拟测试前端
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /mocktest-app
pathType: Prefix
backend:
service:
name: mocktest-frontend
port:
number: 4000