gpt4 book ai didi

amazon-web-services - 如何使我的AWS EKS Kubernetes集群公开可见?

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

我已按照Udacity Full-Stack Nanodegree类(class)中的步骤进行操作,以使Kubernetes集群在AWS EKS上运行。

服务正在运行。运行命令kubectl get services simple-jwt-api -o wide返回:

NAME             TYPE           CLUSTER-IP      EXTERNAL-IP                                                              PORT(S)        AGE   SELECTOR
simple-jwt-api LoadBalancer 10.100.217.57 a32d4ab0969b149bd9fb47d2065aee80-335944770.us-west-2.elb.amazonaws.com 80:31644/TCP 51m app=simple-jwt-api

节点似乎正在运行:
NAME                                          STATUS   ROLES    AGE   VERSION               INTERNAL-IP     EXTERNAL-IP     OS-IMAGE         KERNEL-VERSION                  CONTAINER-RUNTIME
ip-192-168-3-213.us-west-2.compute.internal Ready <none> 80m v1.15.10-eks-bac369 192.168.3.213 54.70.213.28 Amazon Linux 2 4.14.173-137.229.amzn2.x86_64 docker://18.9.9
ip-192-168-46-0.us-west-2.compute.internal Ready <none> 80m v1.15.10-eks-bac369 192.168.46.0 34.220.32.208 Amazon Linux 2 4.14.173-137.229.amzn2.x86_64 docker://18.9.9

Pane 似乎正在运行
NAME                              READY   STATUS    RESTARTS   AGE   IP               NODE                                          NOMINATED NODE   READINESS GATES
simple-jwt-api-5dd5b9cf98-46ngm 1/1 Running 0 37m 192.168.22.121 ip-192-168-3-213.us-west-2.compute.internal <none> <none>
simple-jwt-api-5dd5b9cf98-kfgxf 1/1 Running 0 37m 192.168.20.148 ip-192-168-3-213.us-west-2.compute.internal <none> <none>
simple-jwt-api-5dd5b9cf98-xs6rp 1/1 Running 0 37m 192.168.60.136 ip-192-168-46-0.us-west-2.compute.internal <none> <none>

Docker文件是:
FROM python:stretch

COPY . /app
WORKDIR /app

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

EXPOSE 8080

ENTRYPOINT ["gunicorn", "-b", ":8080", "main:APP"]

部署文件为:
apiVersion: v1
kind: Service
metadata:
name: simple-jwt-api
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: simple-jwt-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-jwt-api
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 2
maxSurge: 2
selector:
matchLabels:
app: simple-jwt-api
template:
metadata:
labels:
app: simple-jwt-api
spec:
containers:
- name: simple-jwt-api
image: CONTAINER_IMAGE
securityContext:
privileged: false
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
ports:
- containerPort: 8080

为什么我不能通过a32d4ab0969b149bd9fb47d2065aee80-335944770.us-west-2.elb.amazonaws.com访问该应用程序?

最佳答案

看起来服务targetPort: 80中的targetPort与POD的容器端口即containerPort: 8080不匹配。请将使用中的targetPort更改为8080,然后重试。

apiVersion: v1
kind: Service
metadata:
name: simple-jwt-api
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: simple-jwt-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-jwt-api
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 2
maxSurge: 2
selector:
matchLabels:
app: simple-jwt-api
template:
metadata:
labels:
app: simple-jwt-api
spec:
containers:
- name: simple-jwt-api
image: CONTAINER_IMAGE
securityContext:
privileged: false
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
ports:
- containerPort: 8080

关于amazon-web-services - 如何使我的AWS EKS Kubernetes集群公开可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61228081/

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