Skip to content

Commit 2bdb5f0

Browse files
committed
extend readme
Signed-off-by: Maskym Vavilov <[email protected]>
1 parent 9e9b0c8 commit 2bdb5f0

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

docs/coredns/README.md

+38-26
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,6 @@ Configure CoreDNS
2828
(cd ../.. && make install-coredns-multi)
2929
```
3030

31-
Set up the provider and dns records and handle via dns operator
32-
33-
```
34-
k get services -A
35-
# get the external IPs from the c1 and c2 services
36-
37-
kubectl create secret generic core-dns --namespace=kuadrant-coredns-1 --type=kuadrant.io/coredns --from-literal=NAMESERVERS="10.89.0.18:53,10.89.0.16:53" --from-literal=ZONES="k.example.com"
38-
kubectl create secret generic core-dns --namespace=kuadrant-coredns-2 --type=kuadrant.io/coredns --from-literal=NAMESERVERS="10.89.0.18:53,10.89.0.16:53" --from-literal=ZONES="k.example.com"
39-
40-
kubectl apply -f coredns/examples/dnsrecord-c1.yaml
41-
kubectl apply -f coredns/examples/dnsrecord-c2.yaml
42-
43-
make run
44-
45-
dig @10.89.0.18 k.example.com
46-
dig @10.89.0.16 k.example.com
47-
48-
49-
Clean up
50-
51-
kubectl delete -f coredns/examples/dnsrecord-c1.yaml
52-
kubectl delete -f coredns/examples/dnsrecord-c2.yaml
53-
54-
```
55-
5631

5732
View Corefile configmap data
5833
```shell
@@ -91,18 +66,55 @@ kubectl create secret generic core-dns --namespace=kuadrant-coredns-1 --type=kua
9166
kubectl create secret generic core-dns --namespace=kuadrant-coredns-2 --type=kuadrant.io/coredns --from-literal=NAMESERVERS="$KNS" --from-literal=ZONES="k.example.com"
9267
```
9368

69+
Run dns-operator instance
70+
```shell
71+
make run
72+
```
73+
9474
Apply example dnsrecords:
9575
```shell
9676
(cd ../.. && kubectl apply -f coredns/examples/dnsrecord-c1.yaml)
9777
(cd ../.. && kubectl apply -f coredns/examples/dnsrecord-c2.yaml)
9878
```
79+
Dig nameservers
80+
```shell
81+
NS1=`kubectl get service -n kuadrant-coredns-1 -l app.kubernetes.io/name=coredns,app.kubernetes.io/component!=metrics -o yaml | yq '.items[0].status.loadBalancer.ingress[0].ip'`
82+
NS2=`kubectl get service -n kuadrant-coredns-2 -l app.kubernetes.io/name=coredns,app.kubernetes.io/component!=metrics -o yaml | yq '.items[0].status.loadBalancer.ingress[0].ip'`
83+
84+
echo $NS1
85+
echo $NS2
86+
87+
dig @${NS1} k.example.com
88+
dig @${NS2} k.example.com
89+
```
90+
9991

10092
Delete example dnsrecords:
10193
```shell
10294
(cd ../.. && kubectl delete -f coredns/examples/dnsrecord-c1.yaml)
10395
(cd ../.. && kubectl delete -f coredns/examples/dnsrecord-c2.yaml)
10496
```
10597

98+
### GEO corner
99+
The geo functionality is provided by the `geoip` plugin from CoreDNS. It relies on the geo database.
100+
In this demo we are using the mock database that is generated using `coredns/examples/db-generator.go`.
101+
The mock database contains sets of "local" subnets that are typical for kind deployments on mac and linux that are pointing at IE and US locales:
102+
103+
| Subnet | Continent | Country |
104+
|------------------|--------------------|--------------------|
105+
| 127.0.100.0/24 | Europe / EU | Ireland / IE |
106+
| 27.0.200.0/24 | North America / NA | United States / US |
107+
| 10.89.100.0/24 | Europe / EU | Ireland / IE |
108+
| 10.89.200.0/24 | North America / NA | United States / US |
109+
110+
You can use `-b` option with dig to use any available to host machine IP addresses as a "source". E.G `dig @[nameserver] [hostname] -p [exposed-port] -b 127.0.100.1` will be associated with IE locale and `-b 127.0.200.1` with US
111+
112+
> **_NOTE:_** the demo DB contains only localhost addresses. I.E. will work only with CoreDNS instance running with `make coredns-run` (not in kind cluster) unless you specify desired subnet in dig with `+subnet=[subnet]`
113+
114+
To add more subnets, it is the best to generate a new DB file. Add your desired CIDR range to the constants and at the end of the file associate it with the desired record (IE or US).
115+
116+
For a deployment using a real-world database you could refer to the [maxmind](https://dev.maxmind.com/geoip/) for their free db. Once obtained it must be mounted and referenced in the Corefile instead of the demo-db.
117+
106118
### Misc Commands
107119

108120
Get all CoreDNS Deployments:
@@ -117,7 +129,7 @@ kubectl get service -A -l app.kubernetes.io/name=coredns,app.kubernetes.io/compo
117129

118130
Get all CoreDNS service external IPs for multi deployment:
119131
```shell
120-
kubectl get service -A -l app.kubernetes.io/name=coredns,app.kubernetes.io/component!=metrics,app.kubernetes.io/part-of=coredns-multi -o json | jq -r .items[].status.loadBalancer.ingress[].ip
132+
kubectl get service -A -l app.kubernetes.io/name=coredns,app.kubernetes.io/component!=metrics,app.kubernetes.io/part-of=coredns-multi -o json | jq -r '.items[].status.loadBalancer.ingress[].ip'
121133
```
122134

123135
Get Name servers string:

0 commit comments

Comments
 (0)