Skip to content

Commit c5e08e1

Browse files
committed
Add hypervisor crd setting, remove hypervisor crd creation, status TLS
1 parent 5fe9e7d commit c5e08e1

File tree

12 files changed

+220
-236
lines changed

12 files changed

+220
-236
lines changed

api/v1alpha1/hypervisor_types.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ import (
2727
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
2828
// Important: Run "make" to regenerate code after modifying this file
2929

30+
const (
31+
// ConditionTypeReady is the type of condition for ready status of a hypervisor
32+
ConditionTypeReady = "Ready"
33+
)
34+
3035
// HypervisorSpec defines the desired state of Hypervisor
3136
type HypervisorSpec struct {
3237
// +kubebuilder:validation:Optional
@@ -41,10 +46,30 @@ type HypervisorSpec struct {
4146
// EvacuateOnReboot request an evacuation of all instances before reboot.
4247
EvacuateOnReboot bool `json:"evacuateOnReboot"`
4348

49+
// +kubebuilder:default:=true
50+
// LifecycleEnabled enables the lifecycle management of the hypervisor via hypervisor-operator.
51+
LifecycleEnabled bool `json:"lifecycleEnabled"`
52+
53+
// +kubebuilder:default:=false
54+
// SkipTests skips the tests during the onboarding process.
55+
SkipTests bool `json:"skipTests"`
56+
57+
// +kubebuilder:default:={}
58+
// CustomTraits are used to apply custom traits to the hypervisor.
59+
CustomTraits []string `json:"customTraits"`
60+
61+
// +kubebuilder:default:=true
62+
// HighAvailability is used to enable the high availability handling of the hypervisor.
63+
HighAvailability bool `json:"highAvailability"`
64+
4465
// +kubebuilder:default:=false
4566
// Require to issue a certificate from cert-manager for the hypervisor, to be used for
4667
// secure communication with the libvirt API.
4768
CreateCertManagerCertificate bool `json:"createCertManagerCertificate"`
69+
70+
// +kubebuilder:default:=true
71+
// InstallCertificate is used to enable the installations of the certificates via kvm-node-agent.
72+
InstallCertificate bool `json:"installCertificate"`
4873
}
4974

5075
type Instance struct {
@@ -152,11 +177,13 @@ type HypervisorStatus struct {
152177
// +kubebuilder:object:root=true
153178
// +kubebuilder:subresource:status
154179
// +kubebuilder:resource:scope=Cluster,shortName=hv
155-
// +kubebuilder:printcolumn:JSONPath=".status.node",name="Node",type="string"
180+
// +kubebuilder:printcolumn:JSONPath=".status.conditions[?(@.type==\"Ready\")].reason",name="State",type="string"
181+
// +kubebuilder:printcolumn:JSONPath=".spec.lifecycleEnabled",name="Lifecycle",type="boolean"
182+
// +kubebuilder:printcolumn:JSONPath=".spec.highAvailability",name="High Availability",type="boolean"
156183
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.prettyVersion",name="Version",type="string"
157184
// +kubebuilder:printcolumn:JSONPath=".status.numInstances",name="Instances",type="integer"
158-
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.hardwareModel",name="Hardware",type="string"
159-
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.kernelRelease",name="Kernel",type="string"
185+
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.hardwareModel",name="Hardware",type="string",priority=2
186+
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.kernelRelease",name="Kernel",type="string",priority=2
160187
// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date"
161188

162189
// Hypervisor is the Schema for the hypervisors API

api/v1alpha1/zz_generated.deepcopy.go

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

charts/kvm-node-agent/crds/hypervisor-crd.yaml

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ spec:
1616
scope: Cluster
1717
versions:
1818
- additionalPrinterColumns:
19-
- jsonPath: .status.node
20-
name: Node
19+
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
20+
name: State
2121
type: string
22+
- jsonPath: .spec.lifecycleEnabled
23+
name: Lifecycle
24+
type: boolean
25+
- jsonPath: .spec.highAvailability
26+
name: High Availability
27+
type: boolean
2228
- jsonPath: .status.operatingSystem.prettyVersion
2329
name: Version
2430
type: string
@@ -27,9 +33,11 @@ spec:
2733
type: integer
2834
- jsonPath: .status.operatingSystem.hardwareModel
2935
name: Hardware
36+
priority: 2
3037
type: string
3138
- jsonPath: .status.operatingSystem.kernelRelease
3239
name: Kernel
40+
priority: 2
3341
type: string
3442
- jsonPath: .metadata.creationTimestamp
3543
name: Age
@@ -65,28 +73,82 @@ spec:
6573
Require to issue a certificate from cert-manager for the hypervisor, to be used for
6674
secure communication with the libvirt API.
6775
type: boolean
76+
customTraits:
77+
default: []
78+
description: CustomTraits are used to apply custom traits to the hypervisor.
79+
items:
80+
type: string
81+
type: array
6882
evacuateOnReboot:
6983
default: true
7084
description: EvacuateOnReboot request an evacuation of all instances
7185
before reboot.
7286
type: boolean
87+
highAvailability:
88+
default: true
89+
description: HighAvailability is used to enable the high availability
90+
handling of the hypervisor.
91+
type: boolean
92+
installCertificate:
93+
default: true
94+
description: InstallCertificate is used to enable the installations
95+
of the certificates via kvm-node-agent.
96+
type: boolean
97+
lifecycleEnabled:
98+
default: true
99+
description: LifecycleEnabled enables the lifecycle management of
100+
the hypervisor via hypervisor-operator.
101+
type: boolean
73102
reboot:
74103
default: false
75104
description: Reboot request an reboot after successful installation
76105
of an upgrade.
77106
type: boolean
107+
skipTests:
108+
default: false
109+
description: SkipTests skips the tests during the onboarding process.
110+
type: boolean
78111
version:
79112
description: OperatingSystemVersion represents the desired operating
80113
system version.
81114
type: string
82115
required:
83116
- createCertManagerCertificate
117+
- customTraits
84118
- evacuateOnReboot
119+
- highAvailability
120+
- installCertificate
121+
- lifecycleEnabled
85122
- reboot
123+
- skipTests
86124
type: object
87125
status:
88126
description: HypervisorStatus defines the observed state of Hypervisor
89127
properties:
128+
capabilities:
129+
description: The capabilities of the hypervisors as reported by libvirt.
130+
properties:
131+
cpuArch:
132+
default: unknown
133+
description: The hosts CPU architecture (not the guests).
134+
type: string
135+
cpus:
136+
anyOf:
137+
- type: integer
138+
- type: string
139+
description: Total host cpus available as a sum of cpus over all
140+
numa cells.
141+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
142+
x-kubernetes-int-or-string: true
143+
memory:
144+
anyOf:
145+
- type: integer
146+
- type: string
147+
description: Total host memory available as a sum of memory over
148+
all numa cells.
149+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
150+
x-kubernetes-int-or-string: true
151+
type: object
90152
conditions:
91153
description: Represents the Hypervisor node conditions.
92154
items:

charts/kvm-node-agent/templates/manager-rbac.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,11 @@ rules:
88
- apiGroups:
99
- ""
1010
resources:
11-
- nodes
1211
- secrets
1312
verbs:
1413
- get
1514
- list
1615
- watch
17-
- apiGroups:
18-
- ""
19-
resources:
20-
- nodes/status
21-
verbs:
22-
- get
2316
- apiGroups:
2417
- cert-manager.io
2518
resources:
@@ -43,7 +36,6 @@ rules:
4336
resources:
4437
- hypervisors
4538
verbs:
46-
- create
4739
- delete
4840
- get
4941
- list

cmd/main.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -201,29 +201,6 @@ func main() {
201201
os.Exit(1)
202202
}
203203

204-
reboot := true
205-
evacuateOnReboot := true
206-
createCertManagerCertificate := true
207-
if os.Getenv("DISABLE_REBOOT") != "" {
208-
reboot = false
209-
}
210-
if os.Getenv("DISABLE_EVACUATE_ON_REBOOT") != "" {
211-
evacuateOnReboot = false
212-
}
213-
if os.Getenv("DISABLE_CREATE_CERT_MANAGER_CERTIFICATE") != "" {
214-
createCertManagerCertificate = false
215-
}
216-
217-
if err = (&controller.NodeReconciler{
218-
Client: mgr.GetClient(),
219-
Scheme: mgr.GetScheme(),
220-
Reboot: reboot,
221-
EvacuateOnReboot: evacuateOnReboot,
222-
CreateCertManagerCertificate: createCertManagerCertificate,
223-
}).SetupWithManager(mgr); err != nil {
224-
setupLog.Error(err, "unable to create controller", "controller", "Node")
225-
os.Exit(1)
226-
}
227204
if err = (&controller.SecretReconciler{
228205
Client: mgr.GetClient(),
229206
Scheme: mgr.GetScheme(),

config/crd/bases/kvm.cloud.sap_hypervisors.yaml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ spec:
1717
scope: Cluster
1818
versions:
1919
- additionalPrinterColumns:
20-
- jsonPath: .status.node
21-
name: Node
20+
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
21+
name: State
2222
type: string
23+
- jsonPath: .spec.lifecycleEnabled
24+
name: Lifecycle
25+
type: boolean
26+
- jsonPath: .spec.highAvailability
27+
name: High Availability
28+
type: boolean
2329
- jsonPath: .status.operatingSystem.prettyVersion
2430
name: Version
2531
type: string
@@ -28,9 +34,11 @@ spec:
2834
type: integer
2935
- jsonPath: .status.operatingSystem.hardwareModel
3036
name: Hardware
37+
priority: 2
3138
type: string
3239
- jsonPath: .status.operatingSystem.kernelRelease
3340
name: Kernel
41+
priority: 2
3442
type: string
3543
- jsonPath: .metadata.creationTimestamp
3644
name: Age
@@ -66,24 +74,54 @@ spec:
6674
Require to issue a certificate from cert-manager for the hypervisor, to be used for
6775
secure communication with the libvirt API.
6876
type: boolean
77+
customTraits:
78+
default: []
79+
description: CustomTraits are used to apply custom traits to the hypervisor.
80+
items:
81+
type: string
82+
type: array
6983
evacuateOnReboot:
7084
default: true
7185
description: EvacuateOnReboot request an evacuation of all instances
7286
before reboot.
7387
type: boolean
88+
highAvailability:
89+
default: true
90+
description: HighAvailability is used to enable the high availability
91+
handling of the hypervisor.
92+
type: boolean
93+
installCertificate:
94+
default: true
95+
description: InstallCertificate is used to enable the installations
96+
of the certificates via kvm-node-agent.
97+
type: boolean
98+
lifecycleEnabled:
99+
default: true
100+
description: LifecycleEnabled enables the lifecycle management of
101+
the hypervisor via hypervisor-operator.
102+
type: boolean
74103
reboot:
75104
default: false
76105
description: Reboot request an reboot after successful installation
77106
of an upgrade.
78107
type: boolean
108+
skipTests:
109+
default: false
110+
description: SkipTests skips the tests during the onboarding process.
111+
type: boolean
79112
version:
80113
description: OperatingSystemVersion represents the desired operating
81114
system version.
82115
type: string
83116
required:
84117
- createCertManagerCertificate
118+
- customTraits
85119
- evacuateOnReboot
120+
- highAvailability
121+
- installCertificate
122+
- lifecycleEnabled
86123
- reboot
124+
- skipTests
87125
type: object
88126
status:
89127
description: HypervisorStatus defines the observed state of Hypervisor

config/rbac/role.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ rules:
77
- apiGroups:
88
- ""
99
resources:
10-
- nodes
1110
- secrets
1211
verbs:
1312
- get
1413
- list
1514
- watch
16-
- apiGroups:
17-
- ""
18-
resources:
19-
- nodes/status
20-
verbs:
21-
- get
2215
- apiGroups:
2316
- cert-manager.io
2417
resources:
@@ -42,7 +35,6 @@ rules:
4235
resources:
4336
- hypervisors
4437
verbs:
45-
- create
4638
- delete
4739
- get
4840
- list

0 commit comments

Comments
 (0)