Skip to content

Commit 93da421

Browse files
Bump sigs.k8s.io/controller-runtime from 0.14.2 to 0.14.4 (#72)
* Bump sigs.k8s.io/controller-runtime from 0.14.2 to 0.14.4 Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.14.2 to 0.14.4. - [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/master/RELEASE.md) - [Commits](kubernetes-sigs/controller-runtime@v0.14.2...v0.14.4) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-runtime dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Implement changes * Remove useless make generate --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Oliver Borchert <[email protected]>
1 parent 74f8058 commit 93da421

File tree

7 files changed

+53
-226
lines changed

7 files changed

+53
-226
lines changed

Makefile

+2-31
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ help: ## Display this help.
2020
#--------------------------------------------------------------------------------------------------
2121
##@ Development
2222

23-
.PHONY: generate
24-
generate: controller-gen ## Generate code for custom resources
25-
$(CONTROLLER_GEN) object paths="./..."
26-
2723
.PHONY: docs
2824
docs: ## Generate helm docs in chart/README.md
2925
cd $(CURDIR)/chart
@@ -48,11 +44,11 @@ e2e-tests: create-cluster ## Run end-to-end tests
4844
##@ Build
4945

5046
.PHONY: build
51-
build: generate ## Build manager binary.
47+
build: ## Build manager binary.
5248
go build -o bin/manager cmd/main.go
5349

5450
.PHONY: run
55-
run: generate ## Run a controller from your host.
51+
run: ## Run a controller from your host.
5652
go run cmd/main.go --config dev/config.yaml
5753

5854
#--------------------------------------------------------------------------------------------------
@@ -79,28 +75,3 @@ setup-cluster: create-cluster ## Set up the currently connected Kubernetes clust
7975
.PHONY: teardown-cluster
8076
teardown-cluster: ## Tear down a locally running Kubernetes cluster
8177
kind delete cluster --name ${KIND_CLUSTER_NAME} || :
82-
83-
#--------------------------------------------------------------------------------------------------
84-
##@ Tool Installation
85-
86-
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
87-
.PHONY: controller-gen
88-
controller-gen: ## Download controller-gen locally if necessary.
89-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
90-
91-
#--------------------------------------------------------------------------------------------------
92-
# HELPERS
93-
#--------------------------------------------------------------------------------------------------
94-
# go-get-tool will 'go get' any package $2 and install it to $1.
95-
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
96-
define go-get-tool
97-
@[ -f $(1) ] || { \
98-
set -e ;\
99-
TMP_DIR=$$(mktemp -d) ;\
100-
cd $$TMP_DIR ;\
101-
go mod init tmp ;\
102-
echo "Downloading $(2)" ;\
103-
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
104-
rm -rf $$TMP_DIR ;\
105-
}
106-
endef

cmd/main.go

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package main
33
import (
44
"context"
55
"flag"
6+
"os"
67

78
configv1 "github.com/borchero/switchboard/internal/config/v1"
89
"github.com/borchero/switchboard/internal/controllers"
910
"github.com/borchero/zeus/pkg/zeus"
1011
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
1112
traefik "github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd/traefik/v1alpha1"
1213
"go.uber.org/zap"
14+
"gopkg.in/yaml.v3"
1315
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1416
"k8s.io/apimachinery/pkg/runtime"
1517
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -31,16 +33,26 @@ func main() {
3133
logger := zeus.Logger(ctx)
3234
defer zeus.Sync()
3335

34-
// Load the options and initialize the schema
35-
var err error
36-
options := ctrl.Options{Scheme: runtime.NewScheme()}
36+
// Load the config file if available
3737
var config configv1.Config
3838
if cfgFile != "" {
39-
// Load the config file if present
40-
options, err = options.AndFrom(ctrl.ConfigFile().AtPath(cfgFile).OfKind(&config))
39+
file, err := os.Open(cfgFile)
4140
if err != nil {
42-
logger.Fatal("failed to load config file", zap.Error(err))
41+
logger.Fatal("failed to open config file", zap.Error(err))
4342
}
43+
if err := yaml.NewDecoder(file).Decode(config); err != nil {
44+
logger.Fatal("failed to parse config file", zap.Error(err))
45+
}
46+
}
47+
48+
// Initialize the options and the schema
49+
options := ctrl.Options{
50+
Scheme: runtime.NewScheme(),
51+
LeaderElection: config.LeaderElection.LeaderElect,
52+
LeaderElectionID: config.LeaderElection.ResourceName,
53+
LeaderElectionNamespace: config.LeaderElection.ResourceNamespace,
54+
MetricsBindAddress: config.Metrics.BindAddress,
55+
HealthProbeBindAddress: config.Health.HealthProbeBindAddress,
4456
}
4557
initScheme(config, options.Scheme)
4658

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ require (
1111
github.com/stretchr/testify v1.8.1
1212
github.com/traefik/traefik/v2 v2.9.8
1313
go.uber.org/zap v1.24.0
14+
gopkg.in/yaml.v3 v3.0.1
1415
k8s.io/api v0.26.1
1516
k8s.io/apimachinery v0.26.1
1617
k8s.io/client-go v0.26.1
17-
sigs.k8s.io/controller-runtime v0.14.2
18+
sigs.k8s.io/controller-runtime v0.14.4
1819
sigs.k8s.io/external-dns v0.13.2
1920
)
2021

@@ -81,7 +82,6 @@ require (
8182
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
8283
gopkg.in/inf.v0 v0.9.1 // indirect
8384
gopkg.in/yaml.v2 v2.4.0 // indirect
84-
gopkg.in/yaml.v3 v3.0.1 // indirect
8585
k8s.io/apiextensions-apiserver v0.26.1 // indirect
8686
k8s.io/component-base v0.26.1 // indirect
8787
k8s.io/klog/v2 v2.80.1 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt
697697
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
698698
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
699699
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
700-
sigs.k8s.io/controller-runtime v0.14.2 h1:P6IwDhbsRWsBClt/8/h8Zy36bCuGuW5Op7MHpFrN/60=
701-
sigs.k8s.io/controller-runtime v0.14.2/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0=
700+
sigs.k8s.io/controller-runtime v0.14.4 h1:Kd/Qgx5pd2XUL08eOV2vwIq3L9GhIbJ5Nxengbd4/0M=
701+
sigs.k8s.io/controller-runtime v0.14.4/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0=
702702
sigs.k8s.io/external-dns v0.13.2 h1:TGxbjrKSB7ogJQSIOggOayel5zn+d3+fj7x6Ct/o2r0=
703703
sigs.k8s.io/external-dns v0.13.2/go.mod h1:On+311+3G04hcnKZBSAw0giggmUvRaqmXX1OAxAPYV0=
704704
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=

internal/config/v1/config_types.go internal/config/v1/config.go

+29-11
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,43 @@ package v1
22

33
import (
44
v1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
5-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6-
cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
75
)
86

9-
func init() {
10-
SchemeBuilder.Register(&Config{})
7+
// Config is the Schema for the configs API
8+
type Config struct {
9+
ControllerConfig `json:",inline"`
10+
Selector IngressSelector `json:"selector"`
11+
Integrations IntegrationConfigs `json:"integrations"`
1112
}
1213

13-
//+kubebuilder:object:root=true
14+
//-------------------------------------------------------------------------------------------------
1415

15-
// Config is the Schema for the configs API
16-
type Config struct {
17-
metav1.TypeMeta `json:",inline"`
18-
cfg.ControllerManagerConfigurationSpec `json:",inline"`
16+
// ControllerConfig provides configuration for the controller.
17+
type ControllerConfig struct {
18+
Health HealthConfig `json:"health,omitempty"`
19+
LeaderElection LeaderElectionConfig `json:"leaderElection,omitempty"`
20+
Metrics MetricsConfig `json:"metrics,omitempty"`
21+
}
1922

20-
Selector IngressSelector `json:"selector"`
21-
Integrations IntegrationConfigs `json:"integrations"`
23+
// HealthConfig provides configuration for the controller health checks.
24+
type HealthConfig struct {
25+
HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"`
2226
}
2327

28+
// LeaderElectionConfig provides configuration for the leader election.
29+
type LeaderElectionConfig struct {
30+
LeaderElect bool `json:"leaderElect,omitempty"`
31+
ResourceName string `json:"resourceName,omitempty"`
32+
ResourceNamespace string `json:"resourceNamespace,omitempty"`
33+
}
34+
35+
// MetricsConfig provides configuration for the controller metrics.
36+
type MetricsConfig struct {
37+
BindAddress string `json:"bindAddress,omitempty"`
38+
}
39+
40+
//-------------------------------------------------------------------------------------------------
41+
2442
// IngressSelector can be used to limit operations to ingresses with a specific class.
2543
type IngressSelector struct {
2644
IngressClass *string `json:"ingressClass,omitempty"`

internal/config/v1/groupversion_info.go

-21
This file was deleted.

internal/config/v1/zz_generated.deepcopy.go

-153
This file was deleted.

0 commit comments

Comments
 (0)