Answers: <p>Further reading the k8s documentation <a href="https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors" rel="nofollow noreferrer">Documentation</a></p>
  <p>Quoting from Documentation:</p>
  <blockquote>
  <p>When you create an EndpointSlice object for a Service, you can use any
  name for the EndpointSlice.</p>
  <p>Each EndpointSlice in a namespace must have a unique name. You link an
  EndpointSlice to a Service by setting the kubernetes.io/service-name
  label on that EndpointSlice.</p>
  </blockquote>
  
Answers: CC BY-SA 4.0
Answers: 2022-12-09T10:09:59.800Z
Answers: 2022-12-09T10:09:59.800Z
Answers: igiannak
Body: <p>We have deployed a PostgreSQL with crunchydata operator.
  We followed the link <code>https://access.crunchydata.com/documentation/postgres-operator/v5/quickstart/#connect-using-a-port-forward</code> and connected with port-forward successfully to pods. Further, our services works and connect to Databases through Service created.</p>
  <p>My question is:<br />
  Service that created is with name my-test-db-primary.
  This service has no pod selector, however the pods are connecting while port-forward not.
  How this works and how it knows the destination?</p>
  <pre><code>kind: Service
  apiVersion: v1
  metadata:
    name: my-test-db-primary
    namespace: test-databases
    labels:
      postgres-operator.crunchydata.com/cluster: my-test-db
      postgres-operator.crunchydata.com/role: primary
    ownerReferences:
      - apiVersion: postgres-operator.crunchydata.com/v1beta1
        kind: PostgresCluster
        name: my-test-db
        controller: true
        blockOwnerDeletion: true
  spec:
    ports:
      - name: postgres
        protocol: TCP
        port: 5432
        targetPort: postgres
    clusterIP: None
    clusterIPs:
      - None
    type: ClusterIP
    sessionAffinity: None
    ipFamilies:
      - IPv4
      - IPv6
    ipFamilyPolicy: RequireDualStack
    internalTrafficPolicy: Cluster
  status:
    loadBalancer: {}
  
  </code></pre>
  
Tags: <kubernetes><postgresql>
Title: How crunchydata Postgresql operator and Service works
UserDisplayName: igiannak
ThreadText: # How crunchydata Postgresql operator and Service works
  
  (Asked by: username_0 on 2022-12-09)
  
  We have deployed a PostgreSQL with crunchydata operator.
  We followed the link `https://access.crunchydata.com/documentation/postgres-operator/v5/quickstart/#connect-using-a-port-forward` and connected with port-forward successfully to pods. Further, our services works and connect to Databases through Service created.
  
  My question is:  
  Service that created is with name my-test-db-primary.
  This service has no pod selector, however the pods are connecting while port-forward not.
  How this works and how it knows the destination?
  
  ```
  kind: Service
  apiVersion: v1
  metadata:
    name: my-test-db-primary
    namespace: test-databases
    labels:
      postgres-operator.crunchydata.com/cluster: my-test-db
      postgres-operator.crunchydata.com/role: primary
    ownerReferences:
      - apiVersion: postgres-operator.crunchydata.com/v1beta1
        kind: PostgresCluster
        name: my-test-db
        controller: true
        blockOwnerDeletion: true
  spec:
    ports:
      - name: postgres
        protocol: TCP
        port: 5432
        targetPort: postgres
    clusterIP: None
    clusterIPs:
      - None
    type: ClusterIP
    sessionAffinity: None
    ipFamilies:
      - IPv4
      - IPv6
    ipFamilyPolicy: RequireDualStack
    internalTrafficPolicy: Cluster
  status:
    loadBalancer: {}
  
  ```
  
  **Tags:** kubernetes, postgresql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-12-09. Score: 0 | Accepted answer
  
  Further reading the k8s documentation [Documentation](https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors)
  
  Quoting from Documentation:
  
  > When you create an EndpointSlice object for a Service, you can use any
  > name for the EndpointSlice.
  >
  > Each EndpointSlice in a namespace must have a unique name. You link an
  > EndpointSlice to a Service by setting the kubernetes.io/service-name
  > label on that EndpointSlice.
  
  
  ---
  
  