gpt4 book ai didi

service - 有没有办法将 EKS 服务配置为使用 HTTPS?

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

这是我们当前 EKS 服务的配置:

apiVersion: v1
kind: Service
metadata:
labels:
app: main-api
name: main-api-svc
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
spec:
externalTrafficPolicy: Cluster
ports:
- name: http-port
port: 80
protocol: TCP
targetPort: 80
selector:
app: main-api
sessionAffinity: None
type: LoadBalancer

有没有办法将其配置为使用 HTTPS 而不是 HTTP?

最佳答案

要终止 Amazon Elastic Kubernetes Service 上的 HTTPS 流量并将其传递到后端:
1.     Request a public ACM certificate为您的自定义域。
2.    识别ARN of the certificate您想与负载平衡器的 HTTPS 监听器一起使用的。
3.    在您的文本编辑器中,创建一个 服务.yaml list 文件基于以下示例。然后,编辑注释以提供步骤 2 中的 ACM ARN。

apiVersion: v1
kind: Service
metadata:
name: echo-service
annotations:
# Note that the backend talks over HTTP.
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
# TODO: Fill in with the ARN of your certificate.
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:{region}:{user id}:certificate/{id}
# Only run SSL on the port named "https" below.
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"

spec:
type: LoadBalancer
selector:
app: echo-pod
ports:
- name: http
port: 80
targetPort: 8080
- name: https
port: 443
targetPort: 8080
4.    创建 服务 对象,运行以下命令:
$ kubectl create -f service.yaml
5.    返回 类型服务的 DNS URL负载均衡器 ,运行以下命令:
$ kubectl get service
注:如果您的集群中有许多事件服务正在运行,请确保获取类型为 的正确服务的 URL负载均衡器 从命令输出。
6.    打开 Amazon EC2 console ,然后选择 负载均衡器 .
7.    选择您的负载均衡器,然后选择 听众 .
8.    对于 听众 ID ,确认您的负载均衡器端口设置为 443 .
9.    对于 SSL证书 ,确认您在 YAML 文件中定义的 SSL 证书已附加到您的负载均衡器。
10.     Associate your custom domain name with your load balancer name .
11.    最后,在网络浏览器中,使用以下 HTTPS 协议(protocol)测试您的自定义域:
https://yourdomain.com

关于service - 有没有办法将 EKS 服务配置为使用 HTTPS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56534589/

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