Skip to content

jmcgrath207/par

Repository files navigation

Par - Label Based DNS Operator

License: MIT Actions Status

Par is a DNS operator that allows you to control deployment DNS queries by labels without cluster administrative changes (ex. Istio sidecar )

It accomplishes this by changing the DNS policy of a deployment to point to the Operator DNS IP address then associating a client ID to pod ip addresses. This allows you to control the scope DNS response to a deployment's label.

Records Custom Resource Example

Forward Type

Manager

This type will update a deployment's pod template DNS configuration to the Operator's IP address. From now all DNS queries will be forwarded to the Operator. Once a DNS request is received, it will check the Records Custom Resource if an entry exist. If no entry is found it will default to the cluster's DNS.

Only the Records Custom Resource is needed for this configuration.

Proxy

The same initial setup happens as the Manager forward type, expect for that any DNS A Record Query will always return the proxy IP address. This will then force pod traffic through the proxy and from there the proxy will preform a DNS lookup from the Operator. In theory, any forward proxy can be used with this method if your able to implement the steps below.

Setup

The proxy deployment will need this label

  par.dev/proxy: "true"

and for the proxy configmap this label.

  par.dev/proxy-config: "true"

Inside the configmap will you need to add a go template tag .dnsResolver with the backticks like below. This is so the Operator can render the Operator DNA address in the configmap and forward DNS queries to the Operator.

serverBlock: |-
  server {
      listen 8080;

      location / {
          resolver {{ `{{ .dnsResolver }}` }};
          proxy_pass http://$http_host$request_uri;
          proxy_ssl_server_name on;
      }
  }

example nginx configuration

Then deploy your Records custom resource. ## Helm Install

helm repo add par https://jmcgrath207.github.io/par/chart
helm install par par/par

Values

Key Type Default Description
image.repository string "ghcr.io/jmcgrath207/par"
image.tag string "v0.1.0"
kubernetesClusterDomain string "cluster.local"
metrics bool false
requests.cpu string "256m"
requests.memory string "128Mi"
resources.limits.cpu string "500m"
resources.limits.memory string "256Mi"

Contribute

Run locally

make deploy_local

Run locally with Delve Debug

make deploy_debug

Then connect to localhost:30002 with delve or your IDE.

Run e2e Test

make deploy_e2e

Debug e2e

make deploy_e2e_debug

Then run a debug against deployment_test.go

License

This project is licensed under the MIT License. See the LICENSE file for more details.