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

Add etcd basic auth support for CoreDNS provider #4258

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions docs/tutorials/coredns.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ helm install --name my-coredns --values values.yaml stable/coredns
### Install external ExternalDNS
ETCD_URLS is configured to etcd client service address.

If the etcd client being used has basic auth enabled, for example when using the [bitnami/etcd](https://artifacthub.io/packages/helm/bitnami/etcd) chart, the `ETCD_USERNAME` and `ETCD_PASSWORD` environment variables can be used to provide the credentials.
ch4nn0n marked this conversation as resolved.
Show resolved Hide resolved

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

```yaml
Expand Down
10 changes: 9 additions & 1 deletion provider/coredns/coredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,14 @@ 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 +227,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
Loading