使用入口进行https,在GCP上配置负载均衡器

时间:2017-09-10 16:23:38

标签: kubernetes google-cloud-platform load-balancing google-kubernetes-engine

配置入口服务时遇到麻烦

这就是我配置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。但是它不会返回任何静态的声明 - .js,.css,.html。

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

试试这个:

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