我看到了与此相关的其他文章,但是在尝试将ConfigMap放入入口时出现错误。为了获得HTTP-> HTTPS。
---
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "3600"
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*'
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: <ARN>
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
labels:
app: nginx-ingress
chart: nginx-ingress-0.16.1
component: controller
release: prod-hola
name: nginx-ingress-hola
namespace: nginx-ingress
spec:
externalTrafficPolicy: Cluster
ports:
- name: https
port: 443
protocol: TCP
targetPort: 80
- name: http
port: 80
protocol: TCP
targetPort: 8000
selector:
app: nginx-ingress
component: controller
release: prod-hola
sessionAffinity: None
type: LoadBalancer
---
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: nginx-ingress-config
name: nginx-ingress-config
namespace: nginx-ingress
data:
ssl-redirect: "false"
hsts: "true"
server-tokens: "false"
http-snippet: |
server {
listen 8000 proxy_protocol;
server_tokens off;
return 301 https://$host$request_uri;
}
---
它给了我resource name may not be empty
。那么,我是否在正确的位置放置了此ConfigMap,以使HTTP到https:// flask(我在8000上有)上工作?
答案 0 :(得分:0)
由于缩进打cup,您似乎缺少ConfigMap的实际名称:
代替此:
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: nginx-ingress-config
name: nginx-ingress-config
namespace: nginx-ingress
data:
ssl-redirect: "false"
hsts: "true"
server-tokens: "false"
http-snippet: |
server {
listen 8000 proxy_protocol;
server_tokens off;
return 301 https://$host$request_uri;
}
应该是这样:
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: nginx-ingress-config
name: nginx-ingress-config
namespace: nginx-ingress
data:
ssl-redirect: "false"
hsts: "true"
server-tokens: "false"
http-snippet: |
server {
listen 8000 proxy_protocol;
server_tokens off;
return 301 https://$host$request_uri;
}