I'm going to turn crazy. I try to expose my service in kubernetes on Google Cloud. My pods are launch, without errors, my service is created. But when I go on, or curl, I get :
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
and replication :
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
The output of kubectl get svc is :
k8s-symfony-nginx 10.3.. 104.199.. 80:30274/TCP
4m
The output of kubectl describe on my service is :
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
I had the same issue and i changed
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
to
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
type should be changed to app in selector