Closed Hisdad closed 3 years ago
And if you do pre-create the service, it still tries to create it anyway. get events
6m56s Warning ServiceDeploymentErr kubegres/postgres-nextcloud Unable to deploy Primary Service. 'Service name': postgres-nextcloud - services "postgres-nextcloud" already exists
Thank you for your message.
In Kubernetes, when we create a Service and we do not define the field 'spec.type', then it is by default of a type ClusterIP.
However, Kubegres creates "headless services" by setting the field 'clusterIP: None' and Kubernetes configures automatically DNS since Kubegres has defined selectors in the service's YAML
That means if a client app is running inside its own Pod and wants to access to a cluster of Postgres Pods inside the same namespace, it can do so by using the hostname matching the name of the Postgres cluster name created with Kubegres (e.g. "mypostgres").
Could you please provide more details about your use-case?
What type of service are you trying to create (ClusterIP, NodePort, LoadBalancer), etc...?
Thanks that clarifies things. I was seeing
kubectl get svc
postgres-nextcloud ClusterIP None
Which implied there was no ip. Particularly since the php-fpm image I was using failed with "cannot resolve host postgresql-nextcloud" yep, spot the obvious error!
Dns lookup does work.
k exec dnsutils -it -- nslookup postgres-nextcloud Server: 10.96.0.10 Address: 10.96.0.10#53
Name: postgres-nextcloud.default.svc.cluster.local Address: 10.244.2.121
Perhaps you could explain in the quick start guide that not having a clusterIp on the svc is correct?
Thanks for your time in replying! --John
Good point. I will update the documentation as you suggested.
I updated the Getting-started page, as follows:
" Note that because Kubegres creates Headless services and configure them with selectors, then no cluster IP addresses are created and the DNS resolves directly to the IPs of the Postgres Pods. "
on the getting started page it says:
In this example, Kubegres created 2 Kubernetes clusterIP services using the name defined in YAML (e.g. "mypostgres"):
Consequently, a client app running inside a Kubernetes cluster, would use the hostname "mypostgres" to connect to the Primary PostgreSql for read and write requests, and optionally it can also use the hostname "mypostgres-replica" to connect to any of the available Replica PostgreSql for read requests.
Which is incorrect. The Services created are unusable, apparently by design. They have no Cluster IP address. See issue #1. The documentation needs to cover manually creating the services.