Skip to content

Commit 7cc9ec0

Browse files
committed
Deploy both v1alpha1 and v1alpha2 at the same time to support updates from old versions
1 parent 202c532 commit 7cc9ec0

7 files changed

Lines changed: 307 additions & 0 deletions

File tree

PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ resources:
1010
domain: elx.cloud
1111
group: k8s
1212
kind: NodeGroup
13+
path: github.com/elastx/elx-nodegroup-controller/api/v1alpha1
14+
version: v1alpha1
15+
- api:
16+
crdVersion: v2
17+
controller: true
18+
domain: elx.cloud
19+
group: k8s
20+
kind: NodeGroup
1321
path: github.com/elastx/elx-nodegroup-controller/api/v1alpha2
1422
version: v1alpha2
1523
version: "3"

api/v1alpha1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2022.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha1 contains API Schema definitions for the k8s v1alpha1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=k8s.elx.cloud
20+
package v1alpha1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "k8s.elx.cloud", Version: "v1alpha1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)

api/v1alpha1/nodegroup_types.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2022.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
type NodeGroupSpec struct {
25+
Members []string `json:"members,omitempty"`
26+
//+optional
27+
Labels map[string]string `json:"labels,omitEmpty"`
28+
//+optional
29+
Taints []corev1.Taint `json:"taints,omitEmpty"`
30+
}
31+
32+
type NodeGroupStatus struct {
33+
}
34+
35+
//+kubebuilder:object:root=true
36+
//+kubebuilder:subresource:status
37+
//+kubebuilder:resource:scope=Cluster
38+
39+
// NodeGroup is the Schema for the nodegroups API
40+
type NodeGroup struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec NodeGroupSpec `json:"spec,omitempty"`
45+
Status NodeGroupStatus `json:"status,omitempty"`
46+
}
47+
48+
//+kubebuilder:object:root=true
49+
50+
// NodeGroupList contains a list of NodeGroup
51+
type NodeGroupList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []NodeGroup `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&NodeGroup{}, &NodeGroupList{})
59+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha2/nodegroup_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type NodeGroupStatus struct {
3636
}
3737

3838
//+kubebuilder:object:root=true
39+
//+kubebuilder:storageversion
3940
//+kubebuilder:subresource:status
4041
//+kubebuilder:resource:scope=Cluster
4142

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,75 @@ spec:
1414
singular: nodegroup
1515
scope: Cluster
1616
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: NodeGroup is the Schema for the nodegroups API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
properties:
41+
labels:
42+
additionalProperties:
43+
type: string
44+
type: object
45+
members:
46+
items:
47+
type: string
48+
type: array
49+
taints:
50+
items:
51+
description: |-
52+
The node this Taint is attached to has the "effect" on
53+
any pod that does not tolerate the Taint.
54+
properties:
55+
effect:
56+
description: |-
57+
Required. The effect of the taint on pods
58+
that do not tolerate the taint.
59+
Valid effects are NoSchedule, PreferNoSchedule and NoExecute.
60+
type: string
61+
key:
62+
description: Required. The taint key to be applied to a node.
63+
type: string
64+
timeAdded:
65+
description: |-
66+
TimeAdded represents the time at which the taint was added.
67+
It is only written for NoExecute taints.
68+
format: date-time
69+
type: string
70+
value:
71+
description: The taint value corresponding to the taint key.
72+
type: string
73+
required:
74+
- effect
75+
- key
76+
type: object
77+
type: array
78+
type: object
79+
status:
80+
type: object
81+
type: object
82+
served: true
83+
storage: false
84+
subresources:
85+
status: {}
1786
- name: v1alpha2
1887
schema:
1988
openAPIV3Schema:
File renamed without changes.

0 commit comments

Comments
 (0)