After deploying a spring microservice ,Load balancer in Kubernetes is not connecting to the mentioned port in Google Cloud Platform.
Is there any firewall settings we need to change to connect to the deployed service ?
https://serverfault.com/questions/912734/kubernetes-connection-refused-during-deployment
Most likely this is an issue with your Kubernetes Service and/or Deployment. GKE will automatically provision the firewall rules required for the ports mapped to the Service
resource.
Ensure that you have exposed port 80
on your Service
and also mapped it to a valid port on your Deployment
's Pods
Here is an example of using a Deployment
and Service
to expose an nginx pod:
deployment.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
service.yaml: apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: type: LoadBalancer selector: app: nginx ports: - name: http port: 80 targetPort: 80
To see what ip address (and ports) are being mapped you can run: kubectl get services
and kubectl describe pod <your pod name
>`
If you are still having problems please provide the outputs of the two kubectl
commands above.
Good luck!