2023-05-22 23:39:31 +03:00
|
|
|
# DNS in Kubernetes
|
2023-04-24 23:52:17 +03:00
|
|
|
|
2023-05-22 23:39:31 +03:00
|
|
|
Again, it is very interesting to access the service by ip but we know that we can access it by service name
|
|
|
|
Lets try,
|
2023-04-24 23:52:17 +03:00
|
|
|
|
|
|
|
```bash
|
2023-05-22 23:39:31 +03:00
|
|
|
kubectl exec busy-box -- wget -O - nginx-service
|
2023-04-24 23:52:17 +03:00
|
|
|
```
|
|
|
|
|
2023-05-22 23:39:31 +03:00
|
|
|
and nothing happen
|
2023-04-24 23:52:17 +03:00
|
|
|
|
2023-05-22 23:39:31 +03:00
|
|
|
the reason is DNS server which we still not configured
|
|
|
|
|
|
|
|
but dns server we can install from kubernetes directly
|
2023-04-24 23:52:17 +03:00
|
|
|
|
|
|
|
```bash
|
|
|
|
kubectl apply -f https://storage.googleapis.com/kubernetes-the-hard-way/coredns-1.8.yaml
|
|
|
|
```
|
|
|
|
|
2023-05-22 23:39:31 +03:00
|
|
|
and try to erpeat
|
|
|
|
|
2023-04-24 23:52:17 +03:00
|
|
|
```bash
|
2023-05-22 23:39:31 +03:00
|
|
|
kubectl exec busy-box -- wget -O - nginx-service
|
2023-04-24 23:52:17 +03:00
|
|
|
```
|
|
|
|
|
2023-05-22 23:39:31 +03:00
|
|
|
|
|
|
|
Output:
|
|
|
|
```
|
|
|
|
Hello from pod: nginx-deployment-68b9c94586-zh9vn
|
|
|
|
Connecting to nginx-service (10.32.0.230:80)
|
|
|
|
writing to stdout
|
|
|
|
- 100% |********************************| 50 0:00:00 ETA
|
|
|
|
written to stdout
|
|
|
|
```
|
|
|
|
|
|
|
|
great, everything works as expected
|