generated from giantswarm/template-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Create karpenter custom resources in workload clusters #268
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
Open
fiunchinho
wants to merge
42
commits into
main
Choose a base branch
from
manage-karpenter-wc-crs
base: main
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 31 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
0cd84be
wip
fiunchinho ef2c8dc
wip2
fiunchinho ec6e643
wip3
fiunchinho d8163fe
Use envtest k8s client
fiunchinho 7599b88
Only use security groups and subnets if defined
fiunchinho ff48046
Use map for subnet and security group selectors
fiunchinho 810a7b3
Take types from karpenter project
fiunchinho e87d502
Add managed-by label to resources created by controller
fiunchinho bdc953f
Check if NodePool field is nil
fiunchinho 60cd70e
Avoid setting defaults
fiunchinho aa07033
Run goimports in api files (including generated files)
fiunchinho 3ae94b5
Refactor tests
fiunchinho 9fe6d2f
Fix user data s3 key
fiunchinho fc99872
Ignore 'no matches for kind' errors when deleting karpenter CRs
fiunchinho 0482904
Mimic upstream ec2nodeclass
fiunchinho cc1af99
Add CAPA additional tags to karpenter resources
fiunchinho 22a8cab
Refactor
fiunchinho 2d227a4
Use conditions properly
fiunchinho e866ede
Fix condition message formatting
fiunchinho fe3096b
Merge branch 'main' into manage-karpenter-wc-crs
fiunchinho 1f8fb8d
Go mod tidy
fiunchinho bd9def1
Use different copies for the different patch operations
fiunchinho 6527931
Use update instead of patch for conditions
fiunchinho 38c008c
Rename policy skew condition
fiunchinho 92d3ae4
Fix condition message formatting again
fiunchinho d06eece
Update conditions immediately
fiunchinho b8f2c7b
Use patchHelper
fiunchinho b40b8d2
Improve condition handling
fiunchinho 99941c1
Reconcile AWS metadata endpoint config
fiunchinho daf0289
Bring back status.ready field
fiunchinho 23ead49
Reconcile taints and startuptaints
fiunchinho 810440b
Extract version skew to its own package
fiunchinho da0c949
Requeue instead of returning error when version skew policy does not …
fiunchinho df1bd01
Add comment explaining goimports on generated files
fiunchinho 3ed9a49
Merge branch 'main' into manage-karpenter-wc-crs
fiunchinho 5447edb
linting fixes
paurosello 5250cb3
revert makegen
paurosello f5865e7
revert makegen
paurosello 31d711f
file origins
paurosello 004ed32
not needed
paurosello a2945e5
patch KMP
paurosello cb6e98a
Merge branch 'main' into manage-karpenter-wc-crs
paurosello 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"slices" | ||
"time" | ||
|
||
"github.com/samber/lo" | ||
) | ||
|
||
const Never = "Never" | ||
|
||
// NillableDuration is a wrapper around time.Duration which supports correct | ||
// marshaling to YAML and JSON. It uses the value "Never" to signify | ||
// that the duration is disabled and sets the inner duration as nil | ||
type NillableDuration struct { | ||
*time.Duration | ||
|
||
// Raw is used to ensure we remarshal the NillableDuration in the same format it was specified. | ||
// This ensures tools like Flux and ArgoCD don't mistakenly detect drift due to our conversion webhooks. | ||
Raw []byte `hash:"ignore"` | ||
} | ||
|
||
func MustParseNillableDuration(val string) NillableDuration { | ||
nd := NillableDuration{} | ||
// Use %q instead of %s to ensure that we unmarshal the value as a string and not an int | ||
lo.Must0(json.Unmarshal([]byte(fmt.Sprintf("%q", val)), &nd)) | ||
return nd | ||
} | ||
|
||
// UnmarshalJSON implements the json.Unmarshaller interface. | ||
func (d *NillableDuration) UnmarshalJSON(b []byte) error { | ||
var str string | ||
err := json.Unmarshal(b, &str) | ||
if err != nil { | ||
return err | ||
} | ||
if str == Never { | ||
return nil | ||
} | ||
pd, err := time.ParseDuration(str) | ||
if err != nil { | ||
return err | ||
} | ||
d.Raw = slices.Clone(b) | ||
d.Duration = &pd | ||
return nil | ||
} | ||
|
||
// MarshalJSON implements the json.Marshaler interface. | ||
func (d NillableDuration) MarshalJSON() ([]byte, error) { | ||
if d.Raw != nil { | ||
return d.Raw, nil | ||
} | ||
if d.Duration != nil { | ||
return json.Marshal(d.Duration.String()) | ||
} | ||
return json.Marshal(Never) | ||
} | ||
|
||
// ToUnstructured implements the value.UnstructuredConverter interface. | ||
func (d NillableDuration) ToUnstructured() interface{} { | ||
if d.Raw != nil { | ||
// Decode the JSON bytes to get the actual string value | ||
var str string | ||
if err := json.Unmarshal(d.Raw, &str); err == nil { | ||
return str | ||
} | ||
// Fallback to string conversion if unmarshal fails | ||
if d.Duration != nil { | ||
return d.Duration.String() | ||
} | ||
return Never | ||
} | ||
if d.Duration != nil { | ||
return d.Duration.String() | ||
} | ||
return Never | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.
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.