答案 0 :(得分:0)
这很可能是您的Kubernetes服务和/或部署存在的问题。 GKE将自动为映射到Service
资源的端口提供所需的防火墙规则。
确保已将port 80
上的Service
公开,并将其映射到Deployment
的{{1}}上的有效端口上
以下是使用Pods
和Deployment
来公开Nginx容器的示例:
deployment.yaml:
Service
service.yaml:
apiVersion: apps/v1 # API Version of this Object
kind: Deployment # This Object Type
metadata: # Allows you to specify custom metadata
name: nginx # Specifies the name of this object
spec: # The official specification matching object type schema
selector: # Label selector for pods
matchLabels: # Must match these label(s)
app: nginx # Custom label with value
template: # Template describes the pods that are created
metadata: # Standard objects metadata
labels: # Labels used to group/categorize objects
app: nginx # The name of this template
spec: # Specification of the desired behaviour of this pod
containers: # List of containers belonging to this pod (cannot be changed/updated)
- name: nginx # Name of this container
image: nginx # Docker image used for this container
ports: # Port mapping(s)
- containerPort: 80 # Number of port to expose on this pods ip
要查看正在映射的IP地址(和端口),可以运行:
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- name: http
port: 80
targetPort: 80
和kubectl get services
>`
如果仍然有问题,请提供上面两个kubectl describe pod <your pod name
命令的输出。
祝你好运!