Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create toggle for using headless service DNS name as CN #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
additionalDNSNames string
certDir string
clusterDomain string
headlessNameAsCN bool
hostname string
namespace string
podIP string
Expand All @@ -51,6 +52,7 @@ func main() {
flag.StringVar(&additionalDNSNames, "additional-dnsnames", "", "additional dns names; comma separated")
flag.StringVar(&certDir, "cert-dir", "/etc/tls", "The directory where the TLS certs should be written")
flag.StringVar(&clusterDomain, "cluster-domain", "cluster.local", "Kubernetes cluster domain")
flag.BoolVar(&headlessNameAsCN, "headless-name-as-cn", false, "If a headless domain name is provided, use it as CN")
flag.StringVar(&hostname, "hostname", "", "hostname as defined by pod.spec.hostname")
flag.StringVar(&namespace, "namespace", "default", "namespace as defined by pod.metadata.namespace")
flag.StringVar(&podName, "pod-name", "", "name as defined by pod.metadata.name")
Expand Down Expand Up @@ -214,7 +216,12 @@ func main() {
func defaultDNSNames(ip, hostname, subdomain, namespace, clusterDomain string) []string {
ns := []string{podDomainName(ip, namespace, clusterDomain)}
if hostname != "" && subdomain != "" {
ns = append(ns, podHeadlessDomainName(hostname, subdomain, namespace, clusterDomain))
headlessName := podHeadlessDomainName(hostname, subdomain, namespace, clusterDomain)
if headlessNameAsCN {
ns = append([]string{headlessName}, ns...)
} else {
ns = append(ns, headlessName)
}
}
return ns
}
Expand Down