gpt4 book ai didi

kubernetes 服务返回被拒绝

转载 作者:行者123 更新时间:2023-12-03 10:04:11 25 4
gpt4 key购买 nike

我要疯了。我尝试在 Google Cloud 上的 kubernetes 中公开我的服务。我的 pod 已启动,没有错误,我的服务已创建。但是当我继续或 curl 时,我得到:

Failed to connect to 130...*** port 80: Connection refused

apiVersion: v1
kind: Service
metadata:
name: k8s-symfony-nginx
labels:
name: k8s-symfony-nginx
spec:
type: LoadBalancer #expose
ports:
- port: 80
selector:
type: my-app

和复制:

apiVersion: v1
kind: ReplicationController
metadata:
name: k8s-symfony-nginx
labels:
name: k8s-symfony-nginx
spec:
replicas: 1
selector:
name: k8s-symfony-nginx
type: my-app
template:
metadata:
labels:
name: k8s-symfony-nginx
type: my-app
spec:
containers:
- name: nginx
image: phpdockerio/nginx:latest
ports:
- name: web
containerPort: 80
- name: php
image: gcr.io/myproject-138623/newcom4u/k8s-symfony-php:latest
ports:
- name: php
containerPort: 9000

kubectl get svc 的输出是:

k8s-symfony-nginx 10.3.. 104.199.. 80:30274/TCP
4m

kubectl describe 在我的服务上的输出是:

Name:           k8s-symfony-nginx
Namespace: default
Labels: name=k8s-symfony-nginx
Selector: name=k8s-symfony-nginx,type=my-app
Type: LoadBalancer
IP: 10.******
LoadBalancer Ingress: 104.*****
Port: <unset> 80/TCP
NodePort: <unset> 30274/TCP
Endpoints: 10.0.0.9:80
Session Affinity: None
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
12m 12m 1 {service-controller } Normal CreatingLoadBalancer Creating load balancer
11m 11m 1 {service-controller } Normal CreatedLoadBalancer Created load balancer

最佳答案

我有同样的问题,我改变了

apiVersion: v1
kind: Service
metadata:
name: k8s-symfony-nginx
labels:
name: k8s-symfony-nginx
spec:
type: LoadBalancer #expose
ports:
- port: 80
selector:
type: my-app

apiVersion: v1
kind: Service
metadata:
name: k8s-symfony-nginx
labels:
name: k8s-symfony-nginx
spec:
type: LoadBalancer #expose
ports:
- port: 80
selector:
app: my-app

选择器中的类型应更改为应用

关于kubernetes 服务返回被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41694554/

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