Skip to content

Commit 202c532

Browse files
committed
Make sure everything is working and are named v1alpha2
1 parent 829c78d commit 202c532

12 files changed

Lines changed: 38 additions & 26 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.16 as builder
2+
FROM golang:1.22 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ kustomize build config/default | kubectl apply -f -
1212
## Sample nodegroup manifest
1313

1414
```yml
15-
apiVersion: k8s.elx.cloud/v1alpha1
15+
apiVersion: k8s.elx.cloud/v1alpha2
1616
kind: NodeGroup
1717
metadata:
1818
name: nodegroup-sample
1919
spec:
20-
members:
20+
members:
2121
- node1 # Kubernetes node name
22+
nodeGroupNames:
23+
- node0 # Kubernetes nodegroup name, used for clusters with dynamic node naming
2224
labels:
2325
name: value
2426
taints:

api/v1alpha2/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1alpha1 contains API Schema definitions for the k8s v1alpha1 API group
17+
// Package v1alpha2 contains API Schema definitions for the k8s v1alpha1 API group
1818
// +kubebuilder:object:generate=true
1919
// +groupName=k8s.elx.cloud
20-
package v1alpha1
20+
package v1alpha2
2121

2222
import (
2323
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -26,7 +26,7 @@ import (
2626

2727
var (
2828
// GroupVersion is group version used to register these objects
29-
GroupVersion = schema.GroupVersion{Group: "k8s.elx.cloud", Version: "v1alpha1"}
29+
GroupVersion = schema.GroupVersion{Group: "k8s.elx.cloud", Version: "v1alpha2"}
3030

3131
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

api/v1alpha2/nodegroup_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package v1alpha1
17+
package v1alpha2
1818

1919
import (
2020
corev1 "k8s.io/api/core/v1"

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/k8s.elx.cloud_nodegroups.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ spec:
1414
singular: nodegroup
1515
scope: Cluster
1616
versions:
17-
- name: v1alpha1
17+
- name: v1alpha2
1818
schema:
1919
openAPIV3Schema:
2020
description: NodeGroup is the Schema for the nodegroups API

config/samples/k8s_v1alpha1_nodegroup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: k8s.elx.cloud/v1alpha1
1+
apiVersion: k8s.elx.cloud/v1alpha2
22
kind: NodeGroup
33
metadata:
44
name: nodegroup-sample

controllers/nodegroup_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"sigs.k8s.io/controller-runtime/pkg/log"
3333
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3434

35-
k8sv1alpha1 "github.com/elastx/elx-nodegroup-controller/api/v1alpha2"
35+
k8sv1alpha2 "github.com/elastx/elx-nodegroup-controller/api/v1alpha2"
3636
)
3737

3838
const (
@@ -139,7 +139,7 @@ func reconcileNodeTaints(node *corev1.Node, taints []corev1.Taint) bool {
139139

140140
func (r *NodeGroupReconciler) findNodeGroupsForMember(_ context.Context, node client.Object) []reconcile.Request {
141141
log := log.FromContext(context.Background())
142-
nodeGroups := &k8sv1alpha1.NodeGroupList{}
142+
nodeGroups := &k8sv1alpha2.NodeGroupList{}
143143
listOpts := &client.ListOptions{
144144
FieldSelector: fields.OneTermEqualSelector(membersField, node.GetName()),
145145
}
@@ -164,7 +164,7 @@ func (r *NodeGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
164164
log := log.FromContext(ctx)
165165

166166
log.V(1).Info("reconciling node group", "nodeGroup", req.NamespacedName)
167-
var nodeGroup k8sv1alpha1.NodeGroup
167+
var nodeGroup k8sv1alpha2.NodeGroup
168168
if err := r.Get(ctx, req.NamespacedName, &nodeGroup); err != nil {
169169
if apierrors.IsNotFound(err) {
170170
return ctrl.Result{}, nil
@@ -255,8 +255,8 @@ func (r *NodeGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
255255
}
256256

257257
func (r *NodeGroupReconciler) SetupWithManager(mgr ctrl.Manager) error {
258-
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &k8sv1alpha1.NodeGroup{}, membersField, func(rawObj client.Object) []string {
259-
nodeGroup := rawObj.(*k8sv1alpha1.NodeGroup)
258+
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &k8sv1alpha2.NodeGroup{}, membersField, func(rawObj client.Object) []string {
259+
nodeGroup := rawObj.(*k8sv1alpha2.NodeGroup)
260260
if nodeGroup.Spec.Members == nil {
261261
return nil
262262
}
@@ -265,7 +265,7 @@ func (r *NodeGroupReconciler) SetupWithManager(mgr ctrl.Manager) error {
265265
return err
266266
}
267267
return ctrl.NewControllerManagedBy(mgr).
268-
For(&k8sv1alpha1.NodeGroup{}).
268+
For(&k8sv1alpha2.NodeGroup{}).
269269
Watches(&corev1.Node{},
270270
handler.EnqueueRequestsFromMapFunc(r.findNodeGroupsForMember)).
271271
Complete(r)

controllers/nodegroup_controller_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ var _ = Describe("NodeGroup controller", func() {
5050
Value: "tainted",
5151
Effect: "NoSchedule",
5252
}
53-
nodeGroups = []v1alpha1.NodeGroup{
53+
nodeGroups = []v1alpha2.NodeGroup{
5454
{
5555
ObjectMeta: metav1.ObjectMeta{
5656
Name: "nodegroup1",
5757
},
58-
Spec: v1alpha1.NodeGroupSpec{
58+
Spec: v1alpha2.NodeGroupSpec{
5959
Members: []string{"node1"},
6060
Labels: map[string]string{
6161
"nodegroup1": "value1",
@@ -66,7 +66,7 @@ var _ = Describe("NodeGroup controller", func() {
6666
ObjectMeta: metav1.ObjectMeta{
6767
Name: "nodegroup2",
6868
},
69-
Spec: v1alpha1.NodeGroupSpec{
69+
Spec: v1alpha2.NodeGroupSpec{
7070
Members: []string{"node2"},
7171
Labels: map[string]string{
7272
"nodegroup2": "value2",
@@ -91,7 +91,7 @@ var _ = Describe("NodeGroup controller", func() {
9191
}
9292
for _, nodeGroup := range nodeGroups {
9393
Expect(k8sClient.Create(context.Background(), &nodeGroup)).Should(Succeed())
94-
ng := &v1alpha1.NodeGroup{}
94+
ng := &v1alpha2.NodeGroup{}
9595
Eventually(func() bool {
9696
err := k8sClient.Get(context.Background(), types.NamespacedName{Name: nodeGroup.Name}, ng)
9797
if err != nil {
@@ -113,7 +113,7 @@ var _ = Describe("NodeGroup controller", func() {
113113

114114
Context("NodeGroups", func() {
115115
It("should add a finalizer to NodeGroups", func() {
116-
ng := &v1alpha1.NodeGroup{}
116+
ng := &v1alpha2.NodeGroup{}
117117
for _, nodeGroup := range nodeGroups {
118118
Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: nodeGroup.Name}, ng)).Should(Succeed())
119119
Expect(ng.Finalizers).Should(HaveLen(1))
@@ -180,7 +180,7 @@ var _ = Describe("NodeGroup controller", func() {
180180
}
181181
return n.GetLabels()["nodegroup2"] == "value2"
182182
})
183-
ng := &v1alpha1.NodeGroup{}
183+
ng := &v1alpha2.NodeGroup{}
184184
Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: "nodegroup2"}, ng)).To(Succeed())
185185
Expect(k8sClient.Delete(context.Background(), ng)).To(Succeed())
186186
Eventually(func() bool {

controllers/suite_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"path/filepath"
2222
"testing"
23+
2324
//+kubebuilder:scaffold:imports
2425

2526
"k8s.io/client-go/kubernetes/scheme"
@@ -33,7 +34,7 @@ import (
3334
. "github.com/onsi/ginkgo/v2"
3435
. "github.com/onsi/gomega"
3536

36-
k8sv1alpha1 "github.com/elastx/elx-nodegroup-controller/api/v1alpha2"
37+
k8sv1alpha2 "github.com/elastx/elx-nodegroup-controller/api/v1alpha2"
3738
)
3839

3940
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
@@ -64,7 +65,7 @@ var _ = BeforeSuite(func() {
6465
Expect(err).NotTo(HaveOccurred())
6566
Expect(cfg).NotTo(BeNil())
6667

67-
err = k8sv1alpha1.AddToScheme(scheme.Scheme)
68+
err = k8sv1alpha2.AddToScheme(scheme.Scheme)
6869
Expect(err).NotTo(HaveOccurred())
6970

7071
//+kubebuilder:scaffold:scheme

0 commit comments

Comments
 (0)