Skip to content

Commit

Permalink
Update dependencies to k8s 1.29 client libs (open-cluster-management-…
Browse files Browse the repository at this point in the history
…io#96)

Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Mar 5, 2024
1 parent e59b134 commit 8483cbe
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 459 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/managed-serviceaccount/managed-serviceaccount/go'
defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*.*.*'
env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/managed-serviceaccount/managed-serviceaccount/go'
GITHUB_REF: ${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-bullseye AS builder
FROM golang:1.21-bullseye AS builder
WORKDIR /go/src/github.com/open-cluster-management.io/managed-serviceaccount
COPY . .
RUN go env
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
IMG_REGISTRY ?= quay.io/open-cluster-management
IMAGE_TAG ?= latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_OPTIONS ?= "crd:crdVersions={v1},allowDangerousTypes=true,generateEmbeddedObjectMeta=true"
E2E_TEST_CLUSTER_NAME ?= loopback

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand Down Expand Up @@ -95,7 +95,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -125,7 +125,7 @@ test-e2e: build-e2e
./bin/e2e --test-cluster $(E2E_TEST_CLUSTER_NAME) $(GENKGO_ARGS)

client-gen:
go install k8s.io/code-generator/cmd/client-gen@v0.27.4
go install k8s.io/code-generator/cmd/client-gen@v0.29.2
client-gen --go-header-file hack/boilerplate.go.txt --clientset-name versioned \
--output-base ./_output/gen \
--output-package open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset \
Expand Down
1 change: 0 additions & 1 deletion apis/authentication/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apis/authentication/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/healthz"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

authv1beta1 "open-cluster-management.io/managed-serviceaccount/apis/authentication/v1beta1"
"open-cluster-management.io/managed-serviceaccount/pkg/addon/agent/controller"
Expand Down Expand Up @@ -97,15 +98,18 @@ func main() {
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
// Only watch resources in the managed cluster namespace on the hub cluster.
Namespace: clusterName,
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "managed-serviceaccount-addon-agent",
LeaderElectionConfig: spokeCfg,
Cache: cache.Options{
// Only watch resources in the managed cluster namespace on the hub cluster.
DefaultNamespaces: map[string]cache.Config{
clusterName: {},
},
},
})
if err != nil {
klog.Fatal("unable to start manager")
Expand Down Expand Up @@ -148,14 +152,17 @@ func main() {
spokeCache, err := cache.New(spokeCfg, cache.Options{
ByObject: map[client.Object]cache.ByObject{
&corev1.ServiceAccount{}: {
Label: labels.SelectorFromSet(
labels.Set{
common.LabelKeyIsManagedServiceAccount: "true",
Namespaces: map[string]cache.Config{
spokeNamespace: {
LabelSelector: labels.SelectorFromSet(
labels.Set{
common.LabelKeyIsManagedServiceAccount: "true",
},
),
},
),
},
},
},
Namespaces: []string{spokeNamespace},
})
if err != nil {
klog.Fatal("unable to instantiate a spoke serviceaccount cache")
Expand Down
12 changes: 6 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"open-cluster-management.io/managed-serviceaccount/pkg/features"
"open-cluster-management.io/managed-serviceaccount/pkg/util"
ctrl "sigs.k8s.io/controller-runtime"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -107,8 +108,7 @@ func main() {

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "managed-serviceaccount-addon-manager",
Expand Down Expand Up @@ -181,13 +181,13 @@ func main() {
WithGetValuesFuncs(
manager.GetDefaultValues(addonAgentImageName, imagePullSecret),
addonfactory.GetAgentImageValues(
addonfactory.NewAddOnDeploymentConfigGetter(addonClient),
utils.NewAddOnDeploymentConfigGetter(addonClient),
"Image",
addonAgentImageName,
),
addonfactory.GetAddOnDeloymentConfigValues(
addonfactory.NewAddOnDeploymentConfigGetter(addonClient),
addonfactory.ToAddOnDeloymentConfigValues,
addonfactory.GetAddOnDeploymentConfigValues(
utils.NewAddOnDeploymentConfigGetter(addonClient),
addonfactory.ToAddOnDeploymentConfigValues,
),
).
WithAgentRegistrationOption(manager.NewRegistrationOption(nativeClient)).
Expand Down
Loading

0 comments on commit 8483cbe

Please sign in to comment.