Skip to content

Commit

Permalink
fix(naming): rename "plugin" into "webhook" [DNS-861] (#18)
Browse files Browse the repository at this point in the history
This change is directly related to this [change in
external-dns](kubernetes-sigs/external-dns@dd170b9).
It affects all artifacts including the repository itself, which is
renamed after the merge of this PR.
  • Loading branch information
akrieg-ionos authored Jun 22, 2023
1 parent 66c6d97 commit 6f8e1cf
Show file tree
Hide file tree
Showing 22 changed files with 165 additions and 230 deletions.
12 changes: 6 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
project_name: external-dns-ionos-webhook

before:
hooks:
- scripts/release_precheck.sh

builds:
- main: ./cmd/plugin
- main: ./cmd/webhook
env:
- CGO_ENABLED=0
goos:
Expand All @@ -31,7 +31,7 @@ archives:
- goos: windows
format: zip
dockers:
- id: external-dns-ionos-plugin
- id: external-dns-ionos-webhook
use: buildx
image_templates:
- "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}"
Expand All @@ -41,7 +41,7 @@ dockers:
goarch: amd64
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description=ionos DNS plugin for external-dns
- --label=org.opencontainers.image.description=ionos DNS webhook for external-dns
- --label=org.opencontainers.image.url=https://{{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY}}
- --label=org.opencontainers.image.source=https://{{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY}}
- --label=org.opencontainers.image.version={{ .Version }}
Expand All @@ -67,7 +67,7 @@ docker_signs:
- --yes
artifacts: images
ids:
- external-dns-ionos-plugin
- external-dns-ionos-webhook
output: true

changelog:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM gcr.io/distroless/static-debian11:nonroot

USER 20000:20000
ADD --chmod=555 external-dns-ionos-plugin /opt/external-dns-ionos-plugin/app
ADD --chmod=555 external-dns-ionos-webhook /opt/external-dns-ionos-webhook/app

ENTRYPOINT ["/opt/external-dns-ionos-plugin/app"]
ENTRYPOINT ["/opt/external-dns-ionos-webhook/app"]
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifndef $(GOPATH)
export GOPATH
endif

ARTIFACT_NAME = external-dns-ionos-plugin
ARTIFACT_NAME = external-dns-ionos-webhook

# logging
LOG_LEVEL = debug
Expand All @@ -16,7 +16,7 @@ LOG_FORMAT = auto


REGISTRY ?= localhost:5001
IMAGE_NAME ?= external-dns-ionos-plugin
IMAGE_NAME ?= external-dns-ionos-webhook
IMAGE_TAG ?= latest
IMAGE = $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)

Expand Down Expand Up @@ -57,16 +57,17 @@ static-analysis: lint vet ## Run static analysis against code.

.PHONY: clean
clean: ## Clean the build directory
rm -rf ./dist
rm -rf ./build
rm -rf ./vendor

.PHONY: build
build: ## Build the binary
CGO_ENABLED=0 go build -o build/bin/$(ARTIFACT_NAME) ./cmd/plugin
CGO_ENABLED=0 go build -o build/bin/$(ARTIFACT_NAME) ./cmd/webhook

.PHONY: run
run:build ## Run the binary on local machine
LOG_LEVEL=$(LOG_LEVEL) LOG_ENVIRONMENT=$(LOG_ENVIRONMENT) LOG_FORMAT=$(LOG_FORMAT) build/bin/external-dns-ionos-plugin
LOG_LEVEL=$(LOG_LEVEL) LOG_ENVIRONMENT=$(LOG_ENVIRONMENT) LOG_FORMAT=$(LOG_FORMAT) build/bin/external-dns-ionos-webhook

##@ Docker

Expand All @@ -90,7 +91,7 @@ unit-test: ## Run unit tests

.PHONY: release-check
release-check: ## Check if the release will work
GITHUB_SERVER_URL=github.com GITHUB_REPOSITORY=ionos-cloud/external-dns-ionos-plugin REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) goreleaser release --snapshot --clean --skip-publish
GITHUB_SERVER_URL=github.com GITHUB_REPOSITORY=ionos-cloud/external-dns-ionos-webhook REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) goreleaser release --snapshot --clean --skip-publish

##@ License

Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# ExternalDNS - IONOS Plugin
# ExternalDNS - IONOS Webhook

**⚠️ NOTE**: This Plugin is based on a not yet released version of
**⚠️ NOTE**: This Webhook is based on a not yet released version of
[ExternalDNS](https://github.com/kubernetes-sigs/external-dns) -
especially the new integration approach by using plugins, discussed and implemented in
especially the new integration approach by using webhooks, discussed and implemented in
[PR-3063](https://github.com/kubernetes-sigs/external-dns/pull/3063).

ExternalDNS is a Kubernetes add-on for automatically managing
Domain Name System (DNS) records for Kubernetes services by using different DNS providers.
By default, Kubernetes manages DNS records internally,
but ExternalDNS takes this functionality a step further by delegating the management of DNS records to an external DNS
provider such as IONOS.
Therefore, the IONOS plugin allows to manage your
Therefore, the IONOS webhook allows to manage your
IONOS domains inside your kubernetes cluster with [ExternalDNS](https://github.com/kubernetes-sigs/external-dns).

To use ExternalDNS with IONOS, you need your IONOS API key or token of the account managing
your domains.
For detailed technical instructions on how the IONOS plugin is deployed using the Bitnami Helm charts for ExternalDNS,
For detailed technical instructions on how the IONOS webhook is deployed using the Bitnami Helm charts for ExternalDNS,
see[deployment instructions](#kubernetes-deployment).

## Kubernetes Deployment

The IONOS plugin is provided as a regular Open Container Initiative (OCI) image released in
the [GitHub container registry](https://github.com/ionos-cloud/external-dns-ionos-plugin/pkgs/container/external-dns-ionos-plugin).
The IONOS webhook is provided as a regular Open Container Initiative (OCI) image released in
the [GitHub container registry](https://github.com/ionos-cloud/external-dns-ionos-webhook/pkgs/container/external-dns-ionos-webhook).
The deployment can be performed in every way Kubernetes supports.
The following example shows the deployment as
a [sidecar container](https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods) in the
Expand All @@ -36,17 +36,17 @@ kubectl create secret generic ionos-credentials --from-literal=api-key='<EXAMPLE
cat <<EOF > external-dns-ionos-values.yaml
image:
registry: ghcr.io
repository: ionos-cloud/external-dns-plugin-provider
repository: ionos-cloud/external-dns-webhook-provider
tag: latest
provider: plugin
provider: webhook
extraArgs:
plugin-provider-url: http://localhost:8888
webhook-provider-url: http://localhost:8888
sidecars:
- name: ionos-plugin
image: ghcr.io/ionos-cloud/external-dns-ionos-plugin:$RELEASE_VERSION
- name: ionos-webhook
image: ghcr.io/ionos-cloud/external-dns-ionos-webhook:$RELEASE_VERSION
ports:
- containerPort: 8888
name: http
Expand Down Expand Up @@ -81,15 +81,15 @@ helm install external-dns-ionos bitnami/external-dns -f external-dns-ionos-value

## Verify the image resource integrity

All official plugins provided by IONOS are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/).
All official webhooks provided by IONOS are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/).
The Cosign public key can be found in the [cosign.pub](./cosign.pub) file.

Note: Due to the early development stage of the plugin, the image is not yet signed
Note: Due to the early development stage of the webhook, the image is not yet signed
by [sigstores transparency log](https://github.com/sigstore/rekor).

```shell
export RELEASE_VERSION=latest
cosign verify --insecure-ignore-tlog --key cosign.pub ghcr.io/ionos-cloud/external-dns-ionos-plugin:$RELEASE_VERSION
cosign verify --insecure-ignore-tlog --key cosign.pub ghcr.io/ionos-cloud/external-dns-ionos-webhook:$RELEASE_VERSION
```

## Development
Expand All @@ -98,7 +98,7 @@ The basic development tasks are provided by make. Run `make help` to see the ava

### Local deployment

The plugin can be deployed locally with a kind cluster. As a prerequisite, you need to install:
The webhook can be deployed locally with a kind cluster. As a prerequisite, you need to install:

- [Docker](https://docs.docker.com/get-docker/),
- [Helm](https://https://helm.sh/ ) with the repos:
Expand All @@ -113,10 +113,10 @@ The plugin can be deployed locally with a kind cluster. As a prerequisite, you n
- [kubectl](https://kubernetes.io/docs/tasks/tools/)

```shell
# setup the kind cluster and deploy external-dns with ionos plugin and a dns mockserver
# setup the kind cluster and deploy external-dns with ionos webhook and a dns mockserver
./scripts/deploy_on_kind.sh
# check if the plugin is running
# check if the webhook is running
kubectl get pods -l app.kubernetes.io/name=external-dns -o wide
# trigger a DNS change e.g. with annotating the ingress controller service
Expand All @@ -128,7 +128,7 @@ kubectl -n ingress-nginx annotate service ingress-nginx-controller "external-dn

### Local acceptance tests

The acceptance tests are run against a kind cluster with ExternalDNS and the plugin deployed.
The acceptance tests are run against a kind cluster with ExternalDNS and the webhook deployed.
The DNS mock server is used to verify the DNS changes. The following diagram shows the test setup:

```mermaid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (

"github.com/caarlos0/env/v8"

"github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration"
"github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionos"
"github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscloud"
"github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscore"
"github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint"
"github.com/ionos-cloud/external-dns-ionos-plugin/pkg/provider"
"github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration"
"github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionos"
"github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionoscore"
"github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint"
"github.com/ionos-cloud/external-dns-ionos-webhook/pkg/provider"
log "github.com/sirupsen/logrus"
)

Expand All @@ -40,7 +39,8 @@ var IonosCoreProviderFactory = func(domainFilter endpoint.DomainFilter, ionosCon

var IonosCloudProviderFactory = func(domainFilter endpoint.DomainFilter, ionosConfig *ionos.Configuration, dryRun bool) (provider.Provider, error) {
setDefaults("https://dns.de-fra.ionos.com", "Bearer", ionosConfig)
return ionoscloud.NewProvider(domainFilter, ionosConfig, dryRun)
// return ionoscloud.NewProvider(domainFilter, ionosConfig, dryRun)
return nil, fmt.Errorf("ionos cloud DNS is not supported in this version")
}

func Init(config configuration.Config) (provider.Provider, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package dnsprovider
import (
"testing"

"github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration"
"github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscloud"
"github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscore"
"github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration"
"github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionoscore"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
Expand All @@ -32,7 +31,8 @@ func TestInit(t *testing.T) {
env: map[string]string{
"IONOS_API_KEY": "algorithm.eyAiaXNzIiA6ICJpb25vc2Nsb3VkIiB9.signature",
},
providerType: "cloud",
providerType: "cloud",
expectedError: "failed to initialize IONOS provider: ionos cloud DNS is not supported in this version",
},
{
name: "without api key you are not able to create provider",
Expand All @@ -56,10 +56,11 @@ func TestInit(t *testing.T) {
if tc.providerType == "core" {
_, ok := dnsProvider.(*ionoscore.Provider)
assert.True(t, ok, "provider is not of type ionoscore.Provider")
} else if tc.providerType == "cloud" {
_, ok := dnsProvider.(*ionoscloud.Provider)
assert.True(t, ok, "provider is not of type ionoscloud.Provider")
}
//} else if tc.providerType == "cloud" {
// _, ok := dnsProvider.(*ionoscloud.Provider)
// assert.True(t, ok, "provider is not of type ionoscloud.Provider")
//}
})
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (

log "github.com/sirupsen/logrus"

"github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration"
"github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration"

"github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plugin"
"github.com/ionos-cloud/external-dns-ionos-webhook/pkg/webhook"
)

// Init server initialization function
func Init(config configuration.Config, p *plugin.Plugin) *http.Server {
func Init(config configuration.Config, p *webhook.Webhook) *http.Server {
r := chi.NewRouter()
r.Use(plugin.Health)
r.Use(webhook.Health)
r.Get("/records", p.Records)
r.Post("/records", p.ApplyChanges)
r.Post("/propertyvaluesequals", p.PropertyValuesEquals)
Expand Down
Loading

0 comments on commit 6f8e1cf

Please sign in to comment.