Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update controller runtime to v0.8.3 and k8s to v1.20.6 #296

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions artifacts/deploy/webhook-configuration.yaml
Expand Up @@ -17,7 +17,7 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
- name: clusterpropagationpolicy.karmada.io
rules:
Expand All @@ -31,7 +31,7 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
- name: overridepolicy.karmada.io
rules:
Expand All @@ -45,7 +45,7 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
- name: work.karmada.io
rules:
Expand All @@ -59,7 +59,7 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
---
apiVersion: admissionregistration.k8s.io/v1
Expand All @@ -81,7 +81,7 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
- name: propagationpolicy.karmada.io
rules:
Expand All @@ -95,7 +95,7 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
- name: clusterpropagationpolicy.karmada.io
rules:
Expand All @@ -109,5 +109,5 @@ webhooks:
caBundle: {{caBundle}}
failurePolicy: Fail
sideEffects: None
admissionReviewVersions: ["v1beta1"]
admissionReviewVersions: ["v1"]
timeoutSeconds: 3
17 changes: 9 additions & 8 deletions cmd/agent/app/agent.go
@@ -1,6 +1,7 @@
package app

import (
"context"
"flag"
"fmt"
"os"
Expand All @@ -27,14 +28,14 @@ import (
)

// NewAgentCommand creates a *cobra.Command object with default parameters
func NewAgentCommand(stopChan <-chan struct{}) *cobra.Command {
func NewAgentCommand(ctx context.Context) *cobra.Command {
opts := options.NewOptions()

cmd := &cobra.Command{
Use: "karmada-agent",
Long: `The karmada agent runs the cluster registration agent`,
Run: func(cmd *cobra.Command, args []string) {
if err := run(opts, stopChan); err != nil {
if err := run(ctx, opts); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
Expand All @@ -46,7 +47,7 @@ func NewAgentCommand(stopChan <-chan struct{}) *cobra.Command {
return cmd
}

func run(opts *options.Options, stopChan <-chan struct{}) error {
func run(ctx context.Context, opts *options.Options) error {
controlPlaneRestConfig, err := clientcmd.BuildConfigFromFlags("", opts.KarmadaKubeConfig)
if err != nil {
return fmt.Errorf("error building kubeconfig of karmada control plane: %s", err.Error())
Expand Down Expand Up @@ -74,10 +75,10 @@ func run(opts *options.Options, stopChan <-chan struct{}) error {
return err
}

setupControllers(controllerManager, opts, stopChan)
setupControllers(controllerManager, opts, ctx.Done())

// blocks until the stop channel is closed.
if err := controllerManager.Start(stopChan); err != nil {
if err := controllerManager.Start(ctx); err != nil {
klog.Errorf("controller manager exits unexpectedly: %v", err)
return err
}
Expand All @@ -88,13 +89,13 @@ func run(opts *options.Options, stopChan <-chan struct{}) error {
func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stopChan <-chan struct{}) {
predicateFun := predicate.Funcs{
CreateFunc: func(createEvent event.CreateEvent) bool {
return createEvent.Meta.GetName() == opts.ClusterName
return createEvent.Object.GetName() == opts.ClusterName
},
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
return updateEvent.MetaOld.GetName() == opts.ClusterName
return updateEvent.ObjectOld.GetName() == opts.ClusterName
},
DeleteFunc: func(deleteEvent event.DeleteEvent) bool {
return deleteEvent.Meta.GetName() == opts.ClusterName
return deleteEvent.Object.GetName() == opts.ClusterName
},
GenericFunc: func(genericEvent event.GenericEvent) bool {
return false
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/main.go
Expand Up @@ -12,9 +12,9 @@ func main() {
logs.InitLogs()
defer logs.FlushLogs()

stopChan := apiserver.SetupSignalHandler()
ctx := apiserver.SetupSignalContext()

if err := app.NewAgentCommand(stopChan).Execute(); err != nil {
if err := app.NewAgentCommand(ctx).Execute(); err != nil {
klog.Fatal(err.Error())
}
}
11 changes: 6 additions & 5 deletions cmd/controller-manager/app/controllermanager.go
@@ -1,6 +1,7 @@
package app

import (
"context"
"flag"
"fmt"
"os"
Expand Down Expand Up @@ -36,15 +37,15 @@ import (
)

// NewControllerManagerCommand creates a *cobra.Command object with default parameters
func NewControllerManagerCommand(stopChan <-chan struct{}) *cobra.Command {
func NewControllerManagerCommand(ctx context.Context) *cobra.Command {
opts := options.NewOptions()

cmd := &cobra.Command{
Use: "controller-manager",
Long: `The controller manager runs a bunch of controllers`,
Run: func(cmd *cobra.Command, args []string) {
opts.Complete()
if err := Run(opts, stopChan); err != nil {
if err := Run(ctx, opts); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
Expand All @@ -57,7 +58,7 @@ func NewControllerManagerCommand(stopChan <-chan struct{}) *cobra.Command {
}

// Run runs the controller-manager with options. This should never exit.
func Run(opts *options.Options, stopChan <-chan struct{}) error {
func Run(ctx context.Context, opts *options.Options) error {
logs.InitLogs()
defer logs.FlushLogs()

Expand All @@ -82,10 +83,10 @@ func Run(opts *options.Options, stopChan <-chan struct{}) error {
return err
}

setupControllers(controllerManager, opts, stopChan)
setupControllers(controllerManager, opts, ctx.Done())

// blocks until the stop channel is closed.
if err := controllerManager.Start(stopChan); err != nil {
if err := controllerManager.Start(ctx); err != nil {
klog.Errorf("controller manager exits unexpectedly: %v", err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/controller-manager/controller-manager.go
Expand Up @@ -15,9 +15,9 @@ func main() {
logs.InitLogs()
defer logs.FlushLogs()

stopChan := apiserver.SetupSignalHandler()
ctx := apiserver.SetupSignalContext()

if err := app.NewControllerManagerCommand(stopChan).Execute(); err != nil {
if err := app.NewControllerManagerCommand(ctx).Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/webhook/app/webhook.go
@@ -1,6 +1,7 @@
package app

import (
"context"
"flag"
"fmt"
"net/http"
Expand All @@ -23,15 +24,15 @@ import (
)

// NewWebhookCommand creates a *cobra.Command object with default parameters
func NewWebhookCommand(stopChan <-chan struct{}) *cobra.Command {
func NewWebhookCommand(ctx context.Context) *cobra.Command {
opts := options.NewOptions()

cmd := &cobra.Command{
Use: "webhook",
Long: `Start a webhook server`,
Run: func(cmd *cobra.Command, args []string) {
opts.Complete()
if err := Run(opts, stopChan); err != nil {
if err := Run(ctx, opts); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
Expand All @@ -45,7 +46,7 @@ func NewWebhookCommand(stopChan <-chan struct{}) *cobra.Command {
}

// Run runs the webhook server with options. This should never exit.
func Run(opts *options.Options, stopChan <-chan struct{}) error {
func Run(ctx context.Context, opts *options.Options) error {
logs.InitLogs()
defer logs.FlushLogs()

Expand Down Expand Up @@ -78,7 +79,7 @@ func Run(opts *options.Options, stopChan <-chan struct{}) error {
hookServer.WebhookMux.Handle("/readyz/", http.StripPrefix("/readyz/", &healthz.Handler{}))

// blocks until the stop channel is closed.
if err := hookManager.Start(stopChan); err != nil {
if err := hookManager.Start(ctx); err != nil {
klog.Errorf("webhook server exits unexpectedly: %v", err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/webhook/main.go
Expand Up @@ -14,9 +14,9 @@ func main() {
logs.InitLogs()
defer logs.FlushLogs()

stopChan := apiserver.SetupSignalHandler()
ctx := apiserver.SetupSignalContext()

if err := app.NewWebhookCommand(stopChan).Execute(); err != nil {
if err := app.NewWebhookCommand(ctx).Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
Expand Down
31 changes: 17 additions & 14 deletions go.mod
Expand Up @@ -4,21 +4,24 @@ go 1.14

require (
github.com/evanphx/json-patch/v5 v5.1.0
github.com/go-logr/logr v0.3.0 // indirect
github.com/google/uuid v1.1.1
github.com/onsi/ginkgo v1.12.1
github.com/onsi/gomega v1.10.1
github.com/google/uuid v1.1.2
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.2
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
k8s.io/api v0.19.3
k8s.io/apiextensions-apiserver v0.19.3
k8s.io/apimachinery v0.19.3
k8s.io/apiserver v0.19.3
k8s.io/client-go v0.19.3
k8s.io/code-generator v0.19.3
k8s.io/component-base v0.19.3
k8s.io/klog/v2 v2.2.0
k8s.io/utils v0.0.0-20200729134348-d5654de09c73
sigs.k8s.io/controller-runtime v0.6.4
k8s.io/api v0.20.6
k8s.io/apiextensions-apiserver v0.20.6
k8s.io/apimachinery v0.20.6
k8s.io/apiserver v0.20.6
k8s.io/client-go v0.20.6
k8s.io/code-generator v0.20.6
k8s.io/component-base v0.20.6
k8s.io/klog/v2 v2.4.0
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009
sigs.k8s.io/controller-runtime v0.8.3
sigs.k8s.io/kind v0.10.0
)

// controller-runtime@v0.8.3 uses gnostic@v0.5.1 which not compatible with kubernetes@v1.20.2.
// kubernetes@v1.20.2 using gnostic@v0.4.1.
replace github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.1