Skip to content

Commit

Permalink
Add DNS server override for cert-manager
Browse files Browse the repository at this point in the history
With Linode/Hetzner - you can run into issues where their own
DNS servers refuse to resolve valid domains or to update their
records.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Nov 5, 2024
1 parent 3595b71 commit 01dcc17
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/apps/certmanager_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package apps

import (
"fmt"
"strings"

"github.com/alexellis/arkade/pkg/config"

"github.com/alexellis/arkade/pkg"
Expand All @@ -27,6 +29,7 @@ func MakeInstallCertManager() *cobra.Command {
certManager.Flags().StringP("version", "v", "v1.5.4", "The version of cert-manager to install, has to be >= v1.0.0")
certManager.Flags().Bool("update-repo", true, "Update the helm repo")
certManager.Flags().StringArray("set", []string{}, "Use custom flags or override existing flags \n(example --set key=value)")
certManager.Flags().StringArray("dns-server", []string{}, "Use custom flags or override existing flags \n(example --dns-servers key=value)")

certManager.RunE = func(command *cobra.Command, args []string) error {
kubeConfigPath, _ := command.Flags().GetString("kubeconfig")
Expand All @@ -45,10 +48,35 @@ func MakeInstallCertManager() *cobra.Command {
overrides := map[string]string{}
overrides["installCRDs"] = "true"

dnsServers, err := command.Flags().GetStringArray("dns-server")
if err != nil {
return err
}

if len(dnsServers) > 0 {

for _, v := range dnsServers {
if !strings.Contains(v, ":") {
return fmt.Errorf("dns-server need a a specific port i.e. 8.8.8.8:53")
}
}

st := ""
if len(dnsServers) > 1 {
st = `"` + strings.Join(dnsServers, ",") + `"`
} else {
st = dnsServers[0]
}

overrides["dns01RecursiveNameservers"] = st
overrides["dns01RecursiveNameserversOnly"] = "true"
}

customFlags, err := command.Flags().GetStringArray("set")
if err != nil {
return err
}

if err := config.MergeFlags(overrides, customFlags); err != nil {
return err
}
Expand Down

0 comments on commit 01dcc17

Please sign in to comment.