Skip to content

Commit 7e21582

Browse files
committed
Add machine template and RBAC for machines.
1 parent 18b2181 commit 7e21582

File tree

4 files changed

+245
-1
lines changed

4 files changed

+245
-1
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2024.
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+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// MetalStackMachineTemplateSpec defines the desired state of MetalStackMachineTemplateSpec.
27+
type MetalStackMachineTemplateSpec struct {
28+
Template MetalStackMachine `json:"template"`
29+
}
30+
31+
// +kubebuilder:object:root=true
32+
// +kubebuilder:resource:path=inframachinetemplates,scope=Namespaced,categories=cluster-api,shortName=imt
33+
// +kubebuilder:storageversion
34+
35+
// MetalStackMachineTemplate is the Schema for the inframachinetemplates API.
36+
type MetalStackMachineTemplate struct {
37+
metav1.TypeMeta `json:",inline"`
38+
metav1.ObjectMeta `json:"metadata,omitempty"`
39+
40+
Spec MetalStackMachineTemplateSpec `json:"spec,omitempty"`
41+
}
42+
43+
// +kubebuilder:object:root=true
44+
45+
// MetalStackMachineTemplateList contains a list of MetalStackMachineTemplate.
46+
type MetalStackMachineTemplateList struct {
47+
metav1.TypeMeta `json:",inline"`
48+
metav1.ListMeta `json:"metadata,omitempty"`
49+
Items []MetalStackMachineTemplate `json:"items"`
50+
}
51+
52+
func init() {
53+
SchemeBuilder.Register(&MetalStackMachineTemplate{}, &MetalStackMachineTemplateList{})
54+
}
55+
56+
// MetalStackMachineTemplateResource describes the data needed to create a metal-stack machine from a template.
57+
type MetalStackMachineTemplateResource struct {
58+
Spec MetalStackMachineSpec `json:"spec"`
59+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.4
7+
name: inframachinetemplates.infrastructure.cluster.x-k8s.io
8+
spec:
9+
group: infrastructure.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: MetalStackMachineTemplate
14+
listKind: MetalStackMachineTemplateList
15+
plural: inframachinetemplates
16+
shortNames:
17+
- imt
18+
singular: metalstackmachinetemplate
19+
scope: Namespaced
20+
versions:
21+
- name: v1alpha1
22+
schema:
23+
openAPIV3Schema:
24+
description: MetalStackMachineTemplate is the Schema for the inframachinetemplates
25+
API.
26+
properties:
27+
apiVersion:
28+
description: |-
29+
APIVersion defines the versioned schema of this representation of an object.
30+
Servers should convert recognized schemas to the latest internal value, and
31+
may reject unrecognized values.
32+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
33+
type: string
34+
kind:
35+
description: |-
36+
Kind is a string value representing the REST resource this object represents.
37+
Servers may infer this from the endpoint the client submits requests to.
38+
Cannot be updated.
39+
In CamelCase.
40+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
41+
type: string
42+
metadata:
43+
type: object
44+
spec:
45+
description: MetalStackMachineTemplateSpec defines the desired state of
46+
MetalStackMachineTemplateSpec.
47+
properties:
48+
template:
49+
description: MetalStackMachine is the Schema for the metalstackmachines
50+
API.
51+
properties:
52+
apiVersion:
53+
description: |-
54+
APIVersion defines the versioned schema of this representation of an object.
55+
Servers should convert recognized schemas to the latest internal value, and
56+
may reject unrecognized values.
57+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
58+
type: string
59+
kind:
60+
description: |-
61+
Kind is a string value representing the REST resource this object represents.
62+
Servers may infer this from the endpoint the client submits requests to.
63+
Cannot be updated.
64+
In CamelCase.
65+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
66+
type: string
67+
metadata:
68+
type: object
69+
spec:
70+
description: MetalStackMachineSpec defines the desired state of
71+
MetalStackMachine.
72+
properties:
73+
image:
74+
description: Image is the operating system to deploy on the
75+
machine
76+
type: string
77+
size:
78+
description: Size is the size of the machine
79+
type: string
80+
required:
81+
- image
82+
- size
83+
type: object
84+
status:
85+
description: MetalStackMachineStatus defines the observed state
86+
of MetalStackMachine.
87+
type: object
88+
type: object
89+
required:
90+
- template
91+
type: object
92+
type: object
93+
served: true
94+
storage: true

config/rbac/capi.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
name: capi-metal-stack-clusters
5+
name: capi-metal-stack
66
labels:
77
cluster.x-k8s.io/aggregate-to-manager: "true"
88
rules:
99
- apiGroups:
1010
- infrastructure.cluster.x-k8s.io
1111
resources:
1212
- metalstackclusters
13+
- metalstackmachines
1314
verbs:
1415
- create
1516
- delete

0 commit comments

Comments
 (0)