mirror of
https://github.com/cert-manager/webhook-example.git
synced 2025-07-01 22:35:49 +02:00
upgarde cert-manager to v1.11
This commit is contained in:
parent
341a15da80
commit
bd0fe24b86
8 changed files with 587 additions and 630 deletions
13
Dockerfile
13
Dockerfile
|
@ -1,24 +1,23 @@
|
|||
FROM golang:1.16-alpine AS build_deps
|
||||
FROM golang:1.19-alpine3.17 AS builder
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
COPY go.mod go.mod
|
||||
COPY go.sum go.sum
|
||||
|
||||
RUN go mod download
|
||||
|
||||
FROM build_deps AS build
|
||||
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN CGO_ENABLED=0 go build -o webhook -ldflags '-w -extldflags "-static"' .
|
||||
|
||||
FROM alpine:3.9
|
||||
FROM alpine:3.17
|
||||
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
COPY --from=build /workspace/webhook /usr/local/bin/webhook
|
||||
COPY --from=builder /workspace/webhook /usr/local/bin/webhook
|
||||
|
||||
ENTRYPOINT ["webhook"]
|
||||
|
|
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ ARCH ?= $(shell go env GOARCH)
|
|||
|
||||
GCP_PROJECT ?= pluralsh
|
||||
IMAGE_NAME := "plural-certmanager-webhook"
|
||||
IMAGE_TAG := "0.1.0"
|
||||
IMAGE_TAG := "0.1.3"
|
||||
DKR_HOST ?= dkr.plural.sh
|
||||
|
||||
OUT := $(shell pwd)/_out
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/acme/webhook"
|
||||
acme "github.com/jetstack/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
|
||||
"github.com/cert-manager/cert-manager/pkg/acme/webhook"
|
||||
acme "github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
|
||||
"github.com/miekg/dns"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"math/big"
|
||||
"testing"
|
||||
|
||||
acme "github.com/jetstack/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
|
||||
acme "github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
121
go.mod
121
go.mod
|
@ -1,13 +1,118 @@
|
|||
module github.com/pluralsh/plural-certmanager-webhook
|
||||
|
||||
go 1.13
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/cert-manager/webhook-example v0.0.0-20210224141901-9440683e53e1
|
||||
github.com/jetstack/cert-manager v1.2.0
|
||||
github.com/miekg/dns v1.1.31
|
||||
github.com/pluralsh/gqlclient v1.1.6
|
||||
github.com/stretchr/testify v1.8.0
|
||||
k8s.io/apiextensions-apiserver v0.19.0
|
||||
k8s.io/client-go v0.19.0
|
||||
github.com/cert-manager/cert-manager v1.11.0
|
||||
github.com/cert-manager/webhook-example v0.0.0-20230119163313-9ea71aef37e6
|
||||
github.com/miekg/dns v1.1.51
|
||||
github.com/pluralsh/gqlclient v1.3.9
|
||||
github.com/stretchr/testify v1.8.2
|
||||
k8s.io/apiextensions-apiserver v0.26.2
|
||||
k8s.io/client-go v0.26.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/NYTimes/gziphandler v1.1.1 // indirect
|
||||
github.com/Yamashou/gqlgenc v0.11.0 // indirect
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
||||
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/cel-go v0.12.6 // indirect
|
||||
github.com/google/gnostic v0.6.9 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.14.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/schollz/progressbar/v3 v3.8.6 // indirect
|
||||
github.com/spf13/cobra v1.6.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/stoewer/go-strcase v1.2.0 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.5 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 // indirect
|
||||
go.opentelemetry.io/otel v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.31.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.10.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/mod v0.7.0 // indirect
|
||||
golang.org/x/net v0.7.0 // indirect
|
||||
golang.org/x/oauth2 v0.4.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/term v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.4.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
|
||||
google.golang.org/grpc v1.51.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.26.2 // indirect
|
||||
k8s.io/apimachinery v0.26.2 // indirect
|
||||
k8s.io/apiserver v0.26.2 // indirect
|
||||
k8s.io/component-base v0.26.2 // indirect
|
||||
k8s.io/klog/v2 v2.80.1 // indirect
|
||||
k8s.io/kms v0.26.2 // indirect
|
||||
k8s.io/kube-aggregator v0.26.0 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20230109183929-3758b55a6596 // indirect
|
||||
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 // indirect
|
||||
sigs.k8s.io/controller-runtime v0.14.1 // indirect
|
||||
sigs.k8s.io/gateway-api v0.6.0 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
|
19
main.go
19
main.go
|
@ -5,12 +5,11 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||
//"k8s.io/client-go/kubernetes"
|
||||
extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/acme/webhook/cmd"
|
||||
"github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
|
||||
"github.com/cert-manager/cert-manager/pkg/acme/webhook/cmd"
|
||||
"github.com/pluralsh/plural-certmanager-webhook/plural"
|
||||
)
|
||||
|
||||
|
@ -28,19 +27,19 @@ func main() {
|
|||
// the different implementations.
|
||||
cmd.RunWebhookServer(GroupName,
|
||||
&pluralDnsProviderSolver{
|
||||
Token: os.Getenv("PLURAL_ACCESS_TOKEN"),
|
||||
Token: os.Getenv("PLURAL_ACCESS_TOKEN"),
|
||||
Endpoint: os.Getenv("PlURAL_ENDPOINT"),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
type pluralDnsProviderSolver struct {
|
||||
Token string
|
||||
Token string
|
||||
Endpoint string
|
||||
}
|
||||
|
||||
type pluralDNSProviderConfig struct {
|
||||
Cluster string `json:"cluster"`
|
||||
Cluster string `json:"cluster"`
|
||||
Provider string `json:"provider"`
|
||||
}
|
||||
|
||||
|
@ -63,9 +62,9 @@ func (c *pluralDnsProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
|
|||
client := plural.NewClient(conf)
|
||||
|
||||
_, err = client.CreateRecord(&plural.DnsRecord{
|
||||
Type: "TXT",
|
||||
Name: ch.ResolvedFQDN,
|
||||
Records: []string{ ch.Key },
|
||||
Type: "TXT",
|
||||
Name: ch.ResolvedFQDN,
|
||||
Records: []string{ch.Key},
|
||||
})
|
||||
fmt.Printf("attempted to create record for %s", ch.ResolvedFQDN)
|
||||
|
||||
|
|
11
main_test.go
11
main_test.go
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jetstack/cert-manager/test/acme/dns"
|
||||
"github.com/cert-manager/cert-manager/test/acme/dns"
|
||||
|
||||
"github.com/cert-manager/webhook-example/example"
|
||||
)
|
||||
|
@ -26,15 +26,16 @@ func TestRunsSuite(t *testing.T) {
|
|||
// dns.SetManifestPath("testdata/my-custom-solver"),
|
||||
// dns.SetBinariesPath("_test/kubebuilder/bin"),
|
||||
//)
|
||||
|
||||
solver := example.New("59351")
|
||||
fixture := dns.NewFixture(solver,
|
||||
fixture := dns.NewFixture(solver.Name(),
|
||||
dns.SetResolvedZone("example.com."),
|
||||
dns.SetManifestPath("testdata/my-custom-solver"),
|
||||
dns.SetBinariesPath("_test/kubebuilder/bin"),
|
||||
dns.SetDNSServer("127.0.0.1:59351"),
|
||||
dns.SetUseAuthoritative(false),
|
||||
)
|
||||
//need to uncomment and RunConformance delete runBasic and runExtended once https://github.com/cert-manager/cert-manager/pull/4835 is merged
|
||||
//fixture.RunConformance(t)
|
||||
fixture.RunBasic(t)
|
||||
fixture.RunExtended(t)
|
||||
|
||||
fixture.RunConformance(t)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue