Skip to content

Commit

Permalink
feat(coredns): etcd authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieugouel committed May 26, 2024
1 parent 1a6153a commit 2fced0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/tutorials/coredns.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ helm install --name my-coredns --values values.yaml stable/coredns
## Installing ExternalDNS
### Install external ExternalDNS
ETCD_URLS is configured to etcd client service address.
Optionnally, you can configure ETCD_USERNAME and ETCD_PASSWORD for authenticating to etcd.

#### Manifest (for clusters without RBAC enabled)

Expand Down
6 changes: 5 additions & 1 deletion provider/coredns/coredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ func getETCDConfig() (*etcdcv3.Config, error) {
}
etcdURLs := strings.Split(etcdURLsStr, ",")
firstURL := strings.ToLower(etcdURLs[0])
etcdUsername := os.Getenv("ETCD_USERNAME")
etcdPassword := os.Getenv("ETCD_PASSWORD")
if strings.HasPrefix(firstURL, "http://") {
return &etcdcv3.Config{Endpoints: etcdURLs}, nil
return &etcdcv3.Config{Endpoints: etcdURLs, Username: etcdUsername, Password: etcdPassword}, nil
} else if strings.HasPrefix(firstURL, "https://") {
caFile := os.Getenv("ETCD_CA_FILE")
certFile := os.Getenv("ETCD_CERT_FILE")
Expand All @@ -221,6 +223,8 @@ func getETCDConfig() (*etcdcv3.Config, error) {
return &etcdcv3.Config{
Endpoints: etcdURLs,
TLS: tlsConfig,
Username: etcdUsername,
Password: etcdPassword,
}, nil
} else {
return nil, errors.New("etcd URLs must start with either http:// or https://")
Expand Down

0 comments on commit 2fced0c

Please sign in to comment.