Configure Local Domain

Configure Local Domain

By configuring the local domain, you can access functions from within a Kubernetes cluster through the function’s external address.

Configure CoreDNS based on Gateway.spec.domain

Assume you have a Gateway that defines this domain: *.ofn.io, you need to update CoreDNS configuration via following commands:

  1. Edit the coredns configmap:
  1. kubectl -n kube-system edit cm coredns -o yaml
  1. Add rewrite stop name regex .*\.ofn\.io gateway.openfunction.svc.cluster.local to the configuration file in the .:53 section, e.g:
  1. apiVersion: v1
  2. data:
  3. Corefile: |
  4. .:53 {
  5. errors
  6. health {
  7. lameduck 5s
  8. }
  9. ready
  10. kubernetes cluster.local in-addr.arpa ip6.arpa {
  11. pods insecure
  12. fallthrough in-addr.arpa ip6.arpa
  13. ttl 30
  14. }
  15. rewrite stop name regex .*\.ofn\.io gateway.openfunction.svc.cluster.local
  16. prometheus :9153
  17. forward . /etc/resolv.conf {
  18. max_concurrent 1000
  19. }
  20. cache 30
  21. loop
  22. reload
  23. loadbalance
  24. }
  25. ...

Configure nodelocaldns based on Gateway.spec.domain

If you are also using nodelocaldns like Kubesphere, you need to update nodelocaldns configuration by the following commands:

  1. Edit the nodelocaldns configmap:
  1. kubectl -n kube-system edit cm nodelocaldns -o yaml
  1. Add ofn.io:53 section to the configuration file, e.g:
  1. apiVersion: v1
  2. data:
  3. Corefile: |
  4. ofn.io:53 {
  5. errors
  6. cache {
  7. success 9984 30
  8. denial 9984 5
  9. }
  10. reload
  11. loop
  12. bind 169.254.25.10
  13. forward . 10.233.0.3 {
  14. force_tcp
  15. }
  16. prometheus :9253
  17. }
  18. cluster.local:53 {
  19. errors
  20. cache {
  21. success 9984 30
  22. denial 9984 5
  23. }
  24. reload
  25. loop
  26. bind 169.254.25.10
  27. forward . 10.233.0.3 {
  28. force_tcp
  29. }
  30. prometheus :9253
  31. health 169.254.25.10:9254
  32. }
  33. .:53 {
  34. errors
  35. cache 30
  36. reload
  37. loop
  38. bind 169.254.25.10
  39. forward . /etc/resolv.conf
  40. prometheus :9253
  41. }
  42. ...