Custom addressing

Another option to customize services is with the clusterIP element. In our examples so far, we've not specified an IP address, which means that it chooses the internal address of the service for us. However, we can add this element and choose the IP address in advance with something like clusterip: 10.0.125.105.

There may be times when you don't want to load balance and would rather have DNS with A records for each pod. For example, software that needs to replicate data evenly to all nodes may rely on A records to distribute data. In this case, we can use an example like the following one and set clusterip to None.

Kubernetes will not assign an IP address and instead only assign A records in DNS for each of the pods. If you are using DNS, the service should be available at node-js-none or node-js-none.default.cluster.local from within the cluster. For this, we  will use the following listing nodejs-headless-service.yaml:

apiVersion: v1 
kind: Service
metadata:
name: node-js-none
labels:
name: node-js-none
spec:
clusterIP: None
ports:
- port: 80
selector:
name: node-js

Test it out after you create this service with the trusty exec command:

$ kubectl exec node-js-pod -- curl node-js-none
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.78.179