This repository was archived by the owner on Jan 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Reduce min keepalive interval to 1s #121
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
16771ad
Reduce min keepalive interval to 1s
NickCao a93a197
Add annotations to routes
NickCao 6384927
Rollout deployment when configmap is changed
NickCao b97424d
Fixup values doc
NickCao ff72865
Fix lint
NickCao 4818109
Prioritize old config format
NickCao 17c2c33
fixup! Prioritize old config format
NickCao 40d178d
Add notes about backwards compatibility
NickCao e19208e
Merge branch 'main' into short-keepalive
mangelajo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,20 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/keepalive" | ||
| ) | ||
|
|
||
| func LoadGrpcConfiguration(config Grpc) (grpc.ServerOption, error) { | ||
| minTime, err := time.ParseDuration(config.Keepalive.MinTime) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ | ||
| MinTime: minTime, | ||
| PermitWithoutStream: config.Keepalive.PermitWithoutStream, | ||
| }), nil | ||
| } |
This file contains hidden or 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,87 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/jumpstarter-dev/jumpstarter-controller/internal/oidc" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apiserver/pkg/apis/apiserver" | ||
| apiserverv1beta1 "k8s.io/apiserver/pkg/apis/apiserver/v1beta1" | ||
| "k8s.io/apiserver/pkg/authentication/authenticator" | ||
| tokenunion "k8s.io/apiserver/pkg/authentication/token/union" | ||
| "k8s.io/apiserver/pkg/server/dynamiccertificates" | ||
| koidc "k8s.io/apiserver/plugin/pkg/authenticator/token/oidc" | ||
| ) | ||
|
|
||
| func LoadAuthenticationConfiguration( | ||
| ctx context.Context, | ||
| scheme *runtime.Scheme, | ||
| config Authentication, | ||
| signer *oidc.Signer, | ||
| certificateAuthority string, | ||
| ) (authenticator.Token, string, error) { | ||
| if config.Internal.Prefix == "" { | ||
| config.Internal.Prefix = "internal:" | ||
| } | ||
|
|
||
| config.JWT = append(config.JWT, apiserverv1beta1.JWTAuthenticator{ | ||
| Issuer: apiserverv1beta1.Issuer{ | ||
| URL: signer.Issuer(), | ||
| CertificateAuthority: certificateAuthority, | ||
| Audiences: []string{signer.Audience()}, | ||
| }, | ||
| ClaimMappings: apiserverv1beta1.ClaimMappings{ | ||
| Username: apiserverv1beta1.PrefixedClaimOrExpression{ | ||
| Claim: "sub", | ||
| Prefix: &config.Internal.Prefix, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| authn, err := newJWTAuthenticator( | ||
| ctx, | ||
| scheme, | ||
| config, | ||
| ) | ||
| if err != nil { | ||
| return nil, "", err | ||
| } | ||
|
|
||
| return authn, config.Internal.Prefix, nil | ||
| } | ||
|
|
||
| // Reference: https://github.com/kubernetes/kubernetes/blob/v1.32.1/pkg/kubeapiserver/authenticator/config.go#L244 | ||
| func newJWTAuthenticator( | ||
| ctx context.Context, | ||
| scheme *runtime.Scheme, | ||
| config Authentication, | ||
| ) (authenticator.Token, error) { | ||
| var jwtAuthenticators []authenticator.Token | ||
| for _, jwtAuthenticator := range config.JWT { | ||
| var oidcCAContent koidc.CAContentProvider | ||
| if len(jwtAuthenticator.Issuer.CertificateAuthority) > 0 { | ||
| var oidcCAError error | ||
| oidcCAContent, oidcCAError = dynamiccertificates.NewStaticCAContent( | ||
| "oidc-authenticator", | ||
| []byte(jwtAuthenticator.Issuer.CertificateAuthority), | ||
| ) | ||
| if oidcCAError != nil { | ||
| return nil, oidcCAError | ||
| } | ||
| } | ||
| var jwtAuthenticatorUnversioned apiserver.JWTAuthenticator | ||
| if err := scheme.Convert(&jwtAuthenticator, &jwtAuthenticatorUnversioned, nil); err != nil { | ||
| return nil, err | ||
| } | ||
| oidcAuth, err := koidc.New(ctx, koidc.Options{ | ||
| JWTAuthenticator: jwtAuthenticatorUnversioned, | ||
| CAContentProvider: oidcCAContent, | ||
| SupportedSigningAlgs: koidc.AllValidSigningAlgorithms(), | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| jwtAuthenticators = append(jwtAuthenticators, oidcAuth) | ||
| } | ||
| return tokenunion.NewFailOnError(jwtAuthenticators...), nil | ||
| } |
This file contains hidden or 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,28 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| apiserverv1beta1 "k8s.io/apiserver/pkg/apis/apiserver/v1beta1" | ||
| ) | ||
|
|
||
| type Config struct { | ||
| Authentication Authentication `json:"authentication"` | ||
| Grpc Grpc `json:"grpc"` | ||
| } | ||
|
|
||
| type Authentication struct { | ||
| Internal Internal `json:"internal"` | ||
| JWT []apiserverv1beta1.JWTAuthenticator `json:"jwt"` | ||
| } | ||
|
|
||
| type Internal struct { | ||
| Prefix string `json:"prefix"` | ||
| } | ||
|
|
||
| type Grpc struct { | ||
| Keepalive Keepalive `json:"keepalive"` | ||
| } | ||
|
|
||
| type Keepalive struct { | ||
| MinTime string `json:"minTime"` | ||
| PermitWithoutStream bool `json:"permitWithoutStream"` | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.