ori-edge / k8s_gateway

A CoreDNS plugin to resolve all types of external Kubernetes resources
Apache License 2.0
316 stars 65 forks source link

chart: Add nodeport and nodeSelector support #17

Closed morganchristiansson closed 3 years ago

morganchristiansson commented 3 years ago

Support deploying as NodePort service on specific node

At the time I didn't know k8s_gateway only resolves type: LoadBalancer services and that only type: LoadBalancer get service status.loadbalancer.ip field populated. After deploying k8s_gateway I ended up deploying metallb and will likely go back to using type: LoadBalancer. Also it turns out type: LoadBalancer was already working by default in k3s with https://github.com/k3s-io/klipper-lb.

But nonetheless this PR correctly adds support for nodePort that I'm currently using :+1:

networkop commented 3 years ago

thanks @morganchristiansson so what happens when you configure a nodePort service? does it even work?

morganchristiansson commented 3 years ago

This is my values.yaml. The service forwards to normal port 53 on pod.

service:
  type: NodePort
  nodePort: 30053

nodeSelector:
  kubernetes.io/hostname: morgan-server

In my openwrt dnsmasq.conf I have

server=/k8s.lan/192.168.1.190#30053
rebind-domain-ok=/k8s.lan/

It was a bit difficult to query dns on non-standard port, many tools don't seem to support specifying port when specifying dns server. But found some that do and it works.

The default nodeport range is not very big and it's not recommended to expand it to include lower ports like 53, tho it would probably work fine as long as you don't have too many NodePort services using random auto-allocated ports(?).

Btw I've copied from helm create k8s_gateway output to stay consistent with default helm chart style. And the conditional around nodePort was used in several charts in the deprecated stable chart repo.

morganchristiansson commented 3 years ago

I also added support for setting loadBalancerIP requested in #14 and added a README.

Chart version bumped. Thank you! :1st_place_medal:

helm diff shows no change when run locally as expected. loadBalancerIP is untested but I may switch to it later.

morganchristiansson commented 3 years ago

Also it seems like the failing github action docker that runs on PR is set to build and push the image from this branch as latest? It's just complaining about credentials as the branch is on a forked repo.

      - 
        name: Login to Container Registry
        uses: docker/login-action@v1
        with:
          registry: quay.io
          username: ${{ secrets.DOCKER_LOGIN }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - 
        name: Build and Push container images
        run: |
          make docker
networkop commented 3 years ago

amazing, thanks for your great work @morganchristiansson :tada:

morganchristiansson commented 3 years ago

Likewise :+1: