From 09ef566dc8f4b0223699cc8a6c8ac280661a0644 Mon Sep 17 00:00:00 2001 From: Patrick Koss Date: Wed, 18 Oct 2023 09:03:44 +0200 Subject: [PATCH] adjust readme --- README.md | 146 ++++++++++++++++++++++++++++++++++------ cmd/webhook/cmd/root.go | 12 ++-- 2 files changed, 132 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 945d118..401b2bf 100644 --- a/README.md +++ b/README.md @@ -11,28 +11,31 @@ [![GitHub stars](https://img.shields.io/github/stars/stackitcloud/external-dns-stackit-webhook.svg?style=social&label=Star&maxAge=2592000)](https://github.com/stackitcloud/external-dns-stackit-webhook/stargazers) [![GitHub forks](https://img.shields.io/github/forks/stackitcloud/external-dns-stackit-webhook.svg?style=social&label=Fork&maxAge=2592000)](https://github.com/stackitcloud/external-dns-stackit-webhook/network) -ExternalDNS serves as an add-on for Kubernetes designed to automate the management of Domain Name System (DNS) -records for Kubernetes services by utilizing various DNS providers. While Kubernetes traditionally manages DNS -records internally, ExternalDNS augments this functionality by transferring the responsibility of DNS records -management to an external DNS provider such as STACKIT. Consequently, the STACKIT webhook enables the management -of your STACKIT domains within your Kubernetes cluster using +ExternalDNS serves as an add-on for Kubernetes designed to automate the management of Domain Name System (DNS) +records for Kubernetes services by utilizing various DNS providers. While Kubernetes traditionally manages DNS +records internally, ExternalDNS augments this functionality by transferring the responsibility of DNS records +management to an external DNS provider such as STACKIT. Consequently, the STACKIT webhook enables the management +of your STACKIT domains within your Kubernetes cluster using [ExternalDNS](https://github.com/kubernetes-sigs/external-dns). -For utilizing ExternalDNS with STACKIT, it is mandatory to establish a STACKIT project, a service account -within the project, generate an authentication token for the service account, authorize the service account +For utilizing ExternalDNS with STACKIT, it is mandatory to establish a STACKIT project, a service account +within the project, generate an authentication token for the service account, authorize the service account to create and read dns zones, and finally, establish a STACKIT zone. ## Kubernetes Deployment -The STACKIT webhook is presented as a standard Open Container Initiative (OCI) image released in the -[GitHub container registry](https://github.com/stackitcloud/external-dns-stackit-webhook/pkgs/container/external-dns-stackit-webhook). -The deployment is compatible with all Kubernetes-supported methods. The subsequent example -demonstrates the deployment as a -[sidecar container](https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods) + +The STACKIT webhook is presented as a standard Open Container Initiative (OCI) image released in the +[GitHub container registry](https://github.com/stackitcloud/external-dns-stackit-webhook/pkgs/container/external-dns-stackit-webhook). +The deployment is compatible with all Kubernetes-supported methods. The subsequent example +demonstrates the deployment as a +[sidecar container](https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods) within the ExternalDNS pod. ```shell kubectl create secret generic external-dns-stackit-webhook --from-literal=auth-token='' +``` +```shell kubectl apply -f - <Why isn't it working? + +Answer: The External DNS will try to create a TXT record named `a-example.runs.onstackit.cloud`, which will fail +because you can't establish a record outside the zone. The solution is to use a name that's within the zone, such as +`nginx.example.runs.onstackit.cloud`. + +### 2. Issues with Creating Ingresses not in the Zone + +For a project containing the zone `example.runs.onstackit.cloud`, suppose you've created these two ingress: + + ```yaml + apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + annotations: + ingress.kubernetes.io/rewrite-target: / + kubernetes.io/ingress.class: nginx + name: example-ingress-external-dns + namespace: default + spec: + rules: + - host: test.example.runs.onstackit.cloud + http: + paths: + - backend: + service: + name: example + port: + number: 80 + path: / + pathType: Prefix + - host: test.example.stackit.rocks + http: + paths: + - backend: + service: + name: example + port: + number: 80 + path: / + pathType: Prefix + ``` + +Why isn't it working? + +Answer: External DNS will attempt to establish a record set for `test.example.stackit.rocks`. As the zone +`example.stackit.rocks` isn't within the project, it'll fail. There are two potential fixes: + +- Incorporate the zone `example.stackit.rocks` into the project. +- Adjust the domain filter to `example.runs.onstackit.cloud` by setting the domain filter + flag `--domain-filter="example.runs.onstackit.cloud"`. This will exclude `test.example.stackit.rocks` and only + generate + the record set for `test.example.runs.onstackit.cloud`. ## Development + Run the app: + ```bash export BASE_URL="https://dns.api.stackit.cloud" export PROJECT_ID="c158c736-0300-4044-95c4-b7d404279b35" @@ -233,11 +337,13 @@ make run ``` Lint the code: + ```bash make lint ``` Test the code: + ```bash make test ``` diff --git a/cmd/webhook/cmd/root.go b/cmd/webhook/cmd/root.go index bac0ed9..8ed1952 100644 --- a/cmd/webhook/cmd/root.go +++ b/cmd/webhook/cmd/root.go @@ -2,7 +2,6 @@ package cmd import ( "fmt" - "go.uber.org/zap/zapcore" "log" "net/http" "strings" @@ -15,6 +14,7 @@ import ( "github.com/stackitcloud/external-dns-stackit-webhook/pkg/api" "github.com/stackitcloud/external-dns-stackit-webhook/pkg/metrics" "go.uber.org/zap" + "go.uber.org/zap/zapcore" "sigs.k8s.io/external-dns/endpoint" ) @@ -89,13 +89,13 @@ func getLogger() *zap.Logger { func getZapLogLevel() zapcore.Level { switch logLevel { - case "DEBUG": + case "debug": return zapcore.DebugLevel - case "INFO": + case "info": return zapcore.InfoLevel - case "WARN": + case "warn": return zapcore.WarnLevel - case "ERROR": + case "error": return zapcore.ErrorLevel default: return zapcore.InfoLevel @@ -119,7 +119,7 @@ func init() { "excessively high to prevent receiving 429 rate limiting from the API.") rootCmd.PersistentFlags().StringArrayVar(&domainFilter, "domain-filter", []string{}, "Establishes a filter for DNS zone names") rootCmd.PersistentFlags().BoolVar(&dryRun, "dry-run", false, "Specifies whether to perform a dry run.") - rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "INFO", "Specifies the log level. Possible values are: DEBUG, INFO, WARN, ERROR") + rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Specifies the log level. Possible values are: debug, info, warn, error") } func initConfig() {