Configure ClusterIP Service by Assigning Endpoints
ClusterIP Service without a Selector and Manually Assigned Endpoints
Juniper® Cloud-Native Contrail Networking (CN2) supports the ClusterIP service to work with manually assigned endpoints without adding a selector in the service. ClusterIP is the default type of service, which is used to expose a service on an IP address internal to the cluster. Access is only permitted from within the cluster.
When creating the endpoint for the service, it's important to add the IP address and
targetRef in the endpoint. The targetRef
should include the pod details such as kind, name, and namespace. Without these
details, connectivity to the ClusterIP service will not work.
Pod details provided in the targetRef of the endpoint are used to
add the virtual machine interface (VMI) reference of the corresponding pod in the
service floating IP (FIP) object.
See the following example of pod details provided in targetRef:
apiVersion: v1
kind: Endpoints
metadata:
labels:
app: nginx
name: nginx
namespace: clusterip
subsets:
- addresses:
- ip: 10.128.0.151
targetRef:
kind: Pod
name: nginx-7d79f94b45-9tfjm
namespace: clusterip
- ip: 10.128.0.175
targetRef:
kind: Pod
name: nginx-7d79f94b45-kcb4s
namespace: clusterip
ports:
- name: http
port: 8080
protocol: TCP
Configure ClusterIP Service
Following is an example procedure to configure ClusterIP service by manually assigning endpoints and without adding a selector.