gpt4 book ai didi

kubernetes - 在GCP上使用https的入口配置负载均衡器

转载 作者:行者123 更新时间:2023-12-02 12:22:16 25 4
gpt4 key购买 nike

我在配置入口服务时遇到了麻烦

这是我配置kubernetes的方式:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: web-spa-development-deployment
spec:
template:
metadata:
labels:
app: web-spa-development-291
spec:
containers:
- name: web-spa-development-291
image: web-spa-development:292
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: web-spa-development-service
spec:
type: NodePort
selector:
app: web-spa-development-291
ports:
- port: 80
targetPort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: development-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: staging
spec:
tls:
- hosts:
- dev-app.example.com
secretName: wildcard-cert
rules:
- host: dev-app.example.com
http:
paths:
- backend:
serviceName: web-spa-development-service
servicePort: 80
path: /*
- backend:
serviceName: web-spa-development-service
servicePort: 80
path: /
---

在镜像本身中-一个nodejs服务器,在端口80上服务。

当入口启动并运行时-使用http / https访问Web应用返回响应中的index.html。但是,它不会返回任何静态 Assets -.js,.css,.html。

可能是什么问题?

最佳答案

试试这个:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: development-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: staging
spec:
tls:
- hosts:
- dev-app.example.com
secretName: wildcard-cert
rules:
- host: dev-app.example.com
http:
paths:
- backend:
serviceName: web-spa-development-service
servicePort: 80

参见 https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting

关于kubernetes - 在GCP上使用https的入口配置负载均衡器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46142886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com