forked from kubernetes-sigs/cluster-api-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 1
🌱 feat: adds new nodeadm bootstrap type #1
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c38276b
ci: adds unit tests
faiq 641b157
Merge pull request #2 from nutanix-cloud-native/faiq/unit-tests-on-pr
faiq 97049ce
feat: starts bootstrapping new type with kubebuilder
faiq 7e42d77
feat: adds fields to nodeadm config
faiq 7e108ee
refactor: use a common file resolver so nodeadmconfig can use it
faiq af310a2
feat: implements nodeadm config controller
faiq 3961c8b
fix: api type issues from copy paste mistakes
faiq 955a172
test: adds reconciler tests for nodeadm
faiq c51c989
fix: runs golangci-lint
faiq 2f2e34d
fix: boundries in userdata
faiq 66a5d18
fix: kubelet logic
faiq 59fbdbc
fix: adds nodeadmconfigtemplate crd
faiq 4e1fa66
fix: nodeadm kubelet config
faiq a961548
fix: handle runtime.Rawextension properly
faiq 3b4537a
e2e: adds test for nodeadm
faiq 4f4db0c
chore: fixes up tests to no longer require TEST_ENV variable
faiq f6d79e2
fix: we don't need to set eks specific labels
faiq 3537aa5
fix: removes local store options which isn't supported by capa
faiq c434fec
fix: use prenodeadm commands name
faiq 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: PR run unit and integration tests | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - edited | ||
| - labeled | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| jobs: | ||
| approve: | ||
| name: runs unit and integration tests | ||
| if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # tag=v4.2.2 | ||
| - name: Calculate go version | ||
| id: vars | ||
| run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT | ||
| - name: Set up Go | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # tag=v6.0.0 | ||
| with: | ||
| go-version: ${{ steps.vars.outputs.go_version }} | ||
| - name: Run runs-test | ||
| run: make test |
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 |
|---|---|---|
|
|
@@ -15,4 +15,4 @@ resources: | |
| - group: bootstrap | ||
| kind: EKSConfigTemplate | ||
| version: v1beta2 | ||
| version: "2" | ||
| version: "3" | ||
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,48 @@ | ||
| package v1beta2 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
| // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
|
||
| // NodeadmConfigSpec defines the desired state of NodeadmConfig. | ||
| type NodeadmConfigSpec struct { | ||
| // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
| // Important: Run "make" to regenerate code after modifying this file | ||
|
|
||
| // Foo is an example field of NodeadmConfig. Edit nodeadmconfig_types.go to remove/update | ||
| Foo string `json:"foo,omitempty"` | ||
| } | ||
|
|
||
| // NodeadmConfigStatus defines the observed state of NodeadmConfig. | ||
| type NodeadmConfigStatus struct { | ||
| // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
| // Important: Run "make" to regenerate code after modifying this file | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // NodeadmConfig is the Schema for the nodeadmconfigs API. | ||
| type NodeadmConfig struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec NodeadmConfigSpec `json:"spec,omitempty"` | ||
| Status NodeadmConfigStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // NodeadmConfigList contains a list of NodeadmConfig. | ||
| type NodeadmConfigList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []NodeadmConfig `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&NodeadmConfig{}, &NodeadmConfigList{}) | ||
| } | ||
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,56 @@ | ||
| /* | ||
| Copyright 2022 The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1beta2 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // NodeadmConfigTemplateSpec defines the desired state of templated NodeadmConfig Amazon EKS Configuration resources. | ||
| type NodeadmConfigTemplateSpec struct { | ||
| Template NodeadmConfigTemplateResource `json:"template"` | ||
| } | ||
|
|
||
| // NodeadmConfigTemplateResource defines the Template structure. | ||
| type NodeadmConfigTemplateResource struct { | ||
| Spec NodeadmConfigSpec `json:"spec,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:resource:path=nodeadmconfigtemplates,scope=Namespaced,categories=cluster-api,shortName=eksct | ||
| // +kubebuilder:storageversion | ||
|
|
||
| // NodeadmConfigTemplate is the Amazon EKS Bootstrap Configuration Template API. | ||
| type NodeadmConfigTemplate struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec NodeadmConfigTemplateSpec `json:"spec,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // NodeadmConfigTemplateList contains a list of Amazon EKS Bootstrap Configuration Templates. | ||
| type NodeadmConfigTemplateList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []NodeadmConfigTemplate `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&NodeadmConfigTemplate{}, &NodeadmConfigTemplateList{}) | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package controllers | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "k8s.io/apimachinery/pkg/runtime" | ||
| ctrl "sigs.k8s.io/controller-runtime" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
|
|
||
| eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta2" | ||
| ) | ||
|
|
||
| // NodeadmConfigReconciler reconciles a NodeadmConfig object | ||
| type NodeadmConfigReconciler struct { | ||
| client.Client | ||
| Scheme *runtime.Scheme | ||
| } | ||
|
|
||
| // +kubebuilder:rbac:groups=bootstrap.cluster.x-k8s.io,resources=nodeadmconfigs,verbs=get;list;watch;create;update;patch;delete | ||
| // +kubebuilder:rbac:groups=bootstrap.cluster.x-k8s.io,resources=nodeadmconfigs/status,verbs=get;update;patch | ||
| // +kubebuilder:rbac:groups=bootstrap.cluster.x-k8s.io,resources=nodeadmconfigs/finalizers,verbs=update | ||
|
|
||
| // Reconcile is part of the main kubernetes reconciliation loop which aims to | ||
| // move the current state of the cluster closer to the desired state. | ||
| // TODO(user): Modify the Reconcile function to compare the state specified by | ||
| // the NodeadmConfig object against the actual cluster state, and then | ||
| // perform operations to make the cluster state reflect the state specified by | ||
| // the user. | ||
| // | ||
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *NodeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| _ = logf.FromContext(ctx) | ||
|
|
||
| // TODO(user): your logic here | ||
|
|
||
| return ctrl.Result{}, nil | ||
| } | ||
|
|
||
| // SetupWithManager sets up the controller with the Manager. | ||
| func (r *NodeadmConfigReconciler) SetupWithManager(mgr ctrl.Manager) error { | ||
| return ctrl.NewControllerManagedBy(mgr). | ||
| For(&eksbootstrapv1.NodeadmConfig{}). | ||
| Named("nodeadmconfig"). | ||
| Complete(r) | ||
| } |
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.