-
Notifications
You must be signed in to change notification settings - Fork 13
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
rtkypoeluev
wants to merge
4
commits into
luksa:master
Choose a base branch
from
rtkypoeluev:k8s.io_0.29.0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
684983c
[k8s_0.29] Initialized go module
rtkypoeluev 6c9f2e9
[k8s_0.29] Removing vendor dir
rtkypoeluev b368394
[k8s_0.29] Updating controller code to use k8s.io API v0.29
rtkypoeluev 71cffb8
[k8s_0.29] renaming sts-scaledown-controller -> statefulset-scaledown…
rtkypoeluev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
) | ||
|
||
type ConfigOptions struct { | ||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if err != nil { | ||
glog.Fatalf("Using --localOnly without --namespace, but unable to determine namespace: %s", err.Error()) | ||
} | ||
|
@@ -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, | ||
|
@@ -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!") | ||
}, | ||
|
@@ -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`.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
flag.StringVar(&config.LeaderElectionNamespace, "leader-election-namespace", "", "Namespace to use for leader election lock (defaults to the controller's namespace)") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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