Skip to content

Instantly share code, notes, and snippets.

@krsna1729
Created October 8, 2018 16:17
Show Gist options
  • Save krsna1729/a11df6344d357eae16f0dc6a3c5358cc to your computer and use it in GitHub Desktop.
Save krsna1729/a11df6344d357eae16f0dc6a3c5358cc to your computer and use it in GitHub Desktop.

Apply the below yaml file to create sgw-s11 service with static endpoint IPs

kubectl apply -f custom-dns.yaml

Verify DNS resolution

dig @10.96.0.10 sgw-s11.default.svc.cluster.local +short

This should return the two IPs specified in the Endpoints section of the yaml

1.2.3.4
5.6.7.8

Since we are using named ports and specified the protocol in our Service and Endpoint spec, SRV records are automatically populated to discover the port too. E.g.,

dig @10.96.0.10 _s11._udp.sgw-s11.default.svc.cluster.local SRV

Notice the port 2123 under ANSWER SECTION

;; QUESTION SECTION:
;_s11._udp.sgw-s11.default.svc.cluster.local. IN        SRV

;; ANSWER SECTION:
_s11._udp.sgw-s11.default.svc.cluster.local. 30 IN SRV 10 50 2123 cp-0.sgw-s11.default.svc.cluster.local.
_s11._udp.sgw-s11.default.svc.cluster.local. 30 IN SRV 10 50 2123 cp-1.sgw-s11.default.svc.cluster.local.

;; ADDITIONAL SECTION:
cp-0.sgw-s11.default.svc.cluster.local. 30 IN A 1.2.3.4
cp-1.sgw-s11.default.svc.cluster.local. 30 IN A 5.6.7.8
kind: Service
apiVersion: v1
metadata:
name: sgw-s11
spec:
clusterIP: None
ports:
- name: s11
port: 2123
protocol: UDP
---
kind: Endpoints
apiVersion: v1
metadata:
name: sgw-s11
subsets:
- addresses:
- ip: 1.2.3.4
hostname: cp-0
- ip: 5.6.7.8
hostname: cp-1
ports:
- name: s11
port: 2123
protocol: UDP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment