Skip to content

Commit

Permalink
chore: update from v2 to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Dec 3, 2024
1 parent b59050b commit f0ea701
Show file tree
Hide file tree
Showing 57 changed files with 169 additions and 76 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY apis/ apis/
COPY controllers/ controllers/
COPY internal/ internal/
COPY cmd/ cmd/
COPY api/ api/
COPY internal/controllers internal/controllers
COPY internal/harbor internal/harbor
COPY internal/helpers internal/helpers
COPY internal/messenger internal/messenger
COPY internal/metrics internal/metrics
COPY internal/utilities internal/utilities

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ test: manifests generate fmt vet envtest ## Run tests.
# Build manager binary
.PHONY: manager
manager: generate fmt vet
go build -o bin/manager main.go
go build -o bin/manager cmd/main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run
run: generate fmt vet manifests
go run ./main.go --controller-namespace=${CONTROLLER_NAMESPACE}
go run ./cmd/main.go --controller-namespace=${CONTROLLER_NAMESPACE}

# Install CRDs into a cluster
.PHONY: install
Expand Down Expand Up @@ -130,7 +130,7 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.2 ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.5 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand Down Expand Up @@ -292,6 +292,14 @@ kind/logs-remote-controller:
$$(kubectl -n remote-controller-system get pod -l control-plane=controller-manager -o jsonpath="{.items[0].metadata.name}") \
-c manager

.PHONY: kind/metrics-port-forward
kind/metrics-port-forward:
export KIND_CLUSTER=$(KIND_CLUSTER) && \
kind export kubeconfig --name=$(KIND_CLUSTER) && \
kubectl -n remote-controller-system port-forward \
$$(kubectl -n remote-controller-system get pod -l control-plane=controller-manager -o jsonpath="{.items[0].metadata.name}") \
8443:8443

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
# $2 - package url which can be installed
Expand Down
38 changes: 32 additions & 6 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
domain: lagoon.sh
multigroup: true
layout:
- go.kubebuilder.io/v3
projectName: remote-controller
repo: github.com/uselagoon/remote-controller
resources:
- group: crd
- api:
crdVersion: v1
namespaced: true
controller: true
domain: lagoon.sh
group: crd
kind: LagoonBuild
path: remote-controller/api/lagoon/v1beta2
version: v1beta2
- group: crd
- api:
crdVersion: v1
namespaced: true
controller: true
domain: lagoon.sh
group: crd
kind: LagoonTask
path: remote-controller/api/lagoon/v1beta2
version: v1beta2
- group: crd
- api:
crdVersion: v1
namespaced: true
controller: true
domain: lagoon.sh
group: crd
kind: LagoonBuild
path: remote-controller/api/lagoon/v1beta1
version: v1beta1
- group: crd
- api:
crdVersion: v1
namespaced: true
controller: true
domain: lagoon.sh
group: crd
kind: LagoonTask
path: remote-controller/api/lagoon/v1beta1
version: v1beta1
version: "2"
version: "3"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 16 additions & 13 deletions main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ import (

cron "gopkg.in/robfig/cron.v2"

"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/hashicorp/golang-lru/v2/expirable"
k8upv1 "github.com/k8up-io/k8up/v2/api/v1"
lagoonv1beta1 "github.com/uselagoon/remote-controller/apis/lagoon/v1beta1"
lagoonv1beta2 "github.com/uselagoon/remote-controller/apis/lagoon/v1beta2"
harborctrl "github.com/uselagoon/remote-controller/controllers/harbor"
lagoonv1beta1ctrl "github.com/uselagoon/remote-controller/controllers/v1beta1"
lagoonv1beta2ctrl "github.com/uselagoon/remote-controller/controllers/v1beta2"
lagoonv1beta1 "github.com/uselagoon/remote-controller/api/lagoon/v1beta1"
lagoonv1beta2 "github.com/uselagoon/remote-controller/api/lagoon/v1beta2"
harborctrl "github.com/uselagoon/remote-controller/internal/controllers/harbor"
lagoonv1beta1ctrl "github.com/uselagoon/remote-controller/internal/controllers/v1beta1"
lagoonv1beta2ctrl "github.com/uselagoon/remote-controller/internal/controllers/v1beta2"
"github.com/uselagoon/remote-controller/internal/messenger"
k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -184,7 +185,7 @@ func main() {

var unauthenticatedRegistry string

flag.StringVar(&metricsAddr, "metrics-addr", ":8080",
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080",
"The address the metric endpoint binds to.")
flag.BoolVar(&secureMetrics, "metrics-secure", false,
"If set the metrics endpoint is served securely")
Expand All @@ -210,7 +211,7 @@ func main() {
"The number of startup attempts before exiting.")
flag.IntVar(&startupConnectionInterval, "startup-connection-interval-seconds", 30,
"The duration between startup attempts.")
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&enableMQ, "enable-message-queue", true,
"Enable message queue to provide updates back to Lagoon.")
Expand Down Expand Up @@ -487,13 +488,15 @@ func main() {
if !enableHTTP2 {
tlsOpts = append(tlsOpts, disableHTTP2)
}
metricsServerOptions := metricsserver.Options{
BindAddress: metricsAddr,
SecureServing: secureMetrics,
TLSOpts: tlsOpts,
FilterProvider: filters.WithAuthenticationAndAuthorization,
}
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
SecureServing: secureMetrics,
TLSOpts: tlsOpts,
},
Scheme: scheme,
Metrics: metricsServerOptions,
LeaderElection: enableLeaderElection,
LeaderElectionID: leaderElectionID,
})
Expand Down
17 changes: 5 additions & 12 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@ spec:
template:
spec:
containers:
- name: kube-rbac-proxy
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.4.1
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=10"
ports:
- containerPort: 8443
name: https
- name: manager
args:
- "--metrics-addr=127.0.0.1:8080"
- "--enable-leader-election"
- "--metrics-bind-address=:8443"
- "--leader-elect"
- "--build-pod-cleanup-cron=*/1 * * * *"
- "--task-pod-cleanup-cron=*/1 * * * *"
- "--harbor-credential-cron=*/1 * * * *"
Expand All @@ -34,3 +24,6 @@ spec:
- "--enable-deprecated-apis"
- "--lagoon-feature-flag-support-k8upv2"
- "--skip-tls-verify"
ports:
- containerPort: 8443
name: https
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
- command:
- /manager
args:
- --enable-leader-election
- --leader-elect
image: controller:latest
name: manager
resources:
Expand Down
24 changes: 22 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,22 @@ require (
k8s.io/apiextensions-apiserver v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/controller-runtime v0.19.2
)

require (
github.com/NeowayLabs/wabbit v0.0.0-20210927194032-73ad61d1620e // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -58,18 +62,20 @@ require (
github.com/goharbor/harbor/src v0.0.0-20230220075213-6015b3efa7d0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/guregu/null v4.0.0+incompatible // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // 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/matryer/try v0.0.0-20161228173917-9ac251b645a2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.5.0 // 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
Expand All @@ -82,30 +88,44 @@ require (
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rabbitmq/amqp091-go v1.7.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.mongodb.org/mongo-driver v1.15.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.31.1 // indirect
k8s.io/component-base v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
Loading

0 comments on commit f0ea701

Please sign in to comment.