我有以下部署yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: rest-deployment
labels:
app: rest-deployment
spec:
selector:
matchLabels:
app: rest-deployment
replicas: 1
template:
metadata:
labels:
app: rest-deployment
spec:
containers:
- name: rest-deployment
image: public.ecr.aws/apryse/fluent-restful:24.2.1.4
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: restful-service
spec:
selector:
app: rest-deployment
ports:
- port: 80
targetPort: 8080
type: LoadBalancer
我的目标是在这个集群中运行多个 pod,所有这些 pod 都由负载均衡器管理,但我希望首先让它与一个 pod 一起工作。
我的问题是启动部署后无法访问 tomcat web 应用程序。 当我运行时我可以看到我的 pod 正在运行
kubectl get deployments
当我运行
kubectl describe svc restful-service
时,我可以看到负载均衡器正在运行。如果有帮助,这就是返回的内容:
Name: restful-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=rest-deployment
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: obfuscatedIP_1
IPs: obfuscatedIP_1
Port: <unset> 80/TCP
TargetPort: 8080/TCP
NodePort: <unset> 30416/TCP
Endpoints: obfuscatedIP_2:8080
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
容器上的 Tomcat 配置为侦听端口 8080:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
/>
但我似乎无法访问网络应用程序,我尝试过:
这些都不起作用。根据我在文档和在线中看到的内容,此设置应该可以工作,因此任何关于为什么它不起作用的见解都将不胜感激!
让它与以下服务而不是负载均衡器一起工作:
apiVersion: v1
kind: Service
metadata:
name: rest-service
spec:
type: NodePort
selector:
app: rest-deployment
ports:
- port: 8080
# By default and for convenience, the `targetPort` is set to
# the same value as the `port` field.
targetPort: 8080
# Optional field
# By default and for convenience, the Kubernetes control plane
# will allocate a port from a range (default: 30000-32767)
nodePort: 30007