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

[k8s_0.29] Update k8s.io API to version 0.29 #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 16 additions & 9 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ limitations under the License.
package main

import (
"context"
"flag"
"os"
"time"

"github.com/golang/glog"
"github.com/jboss-openshift/statefulset-scaledown-controller/pkg/controller"
"github.com/jboss-openshift/statefulset-scaledown-controller/pkg/signals"
"io/ioutil"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/leaderelection"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"os"

"statefulset-scaledown-controller/pkg/controller"
"statefulset-scaledown-controller/pkg/signals"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using local controller/signals packages instead of github.com/jboss-openshift

)

type ConfigOptions struct {
Expand Down Expand Up @@ -99,7 +101,7 @@ func main() {
var kubeInformerFactory kubeinformers.SharedInformerFactory
if config.localOnly {
if config.namespace == "" {
bytes, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
bytes, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ioutil.ReadFile was replaced with os.ReadFile

if err != nil {
glog.Fatalf("Using --localOnly without --namespace, but unable to determine namespace: %s", err.Error())
}
Expand Down Expand Up @@ -146,6 +148,7 @@ func main() {
config.LeaderElectionNamespace,
"statefulset-scaledown-controller",
leaderElectionClient.CoreV1(),
leaderElectionClient.CoordinationV1(),
resourcelock.ResourceLockConfig{
Identity: id + "-external-statefulset-scaledown-controller",
EventRecorder: c.Recorder,
Expand All @@ -155,13 +158,17 @@ func main() {
}

// Try and become the leader and start controller loop
leaderelection.RunOrDie(leaderelection.LeaderElectionConfig{
leaderelection.RunOrDie(context.TODO(), leaderelection.LeaderElectionConfig{
Lock: lock,
LeaseDuration: config.LeaderElection.LeaseDuration.Duration,
RenewDeadline: config.LeaderElection.RenewDeadline.Duration,
RetryPeriod: config.LeaderElection.RetryPeriod.Duration,
Callbacks: leaderelection.LeaderCallbacks{
OnStartedLeading: runController,
OnStartedLeading: func(ctx context.Context) {
glog.Infof("Running with leader election (HA mode)")
runController(stopCh)
panic("unreachable")
},
OnStoppedLeading: func() {
glog.Fatalf("Stopped being the leader. Exiting!")
},
Expand Down Expand Up @@ -194,9 +201,9 @@ func init() {
flag.DurationVar(&config.LeaderElection.RetryPeriod.Duration, "leader-elect-retry-period", DefaultRetryPeriod, ""+
"The duration the clients should wait between attempting acquisition and renewal "+
"of a leadership. This is only applicable if leader election is enabled.")
flag.StringVar(&config.LeaderElection.ResourceLock, "leader-elect-resource-lock", resourcelock.ConfigMapsResourceLock, ""+
flag.StringVar(&config.LeaderElection.ResourceLock, "leader-elect-resource-lock", resourcelock.LeasesResourceLock, ""+
"The type of resource object that is used for locking during "+
"leader election. Supported options are `configmaps` (default) and `endpoints`.")
"leader election. Supported option is `leases`.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfigMaps was replaced by Leases


flag.StringVar(&config.LeaderElectionNamespace, "leader-election-namespace", "", "Namespace to use for leader election lock (defaults to the controller's namespace)")
}
55 changes: 55 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module statefulset-scaledown-controller

go 1.21

toolchain go1.21.3

require (
github.com/golang/glog v1.2.0
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // 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.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.6 // 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/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/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // 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.3.0 // indirect
)
Loading