Skip to content

Commit 73703a7

Browse files
wongniJoshua Reed
andauthored
Feature/implement machine health checker (#71)
* Can now build Isolated network with extra CRDs. * Such awesome, much wow * Saving progress and switching gears. * Abstractions gallore. * Further abstraction of the controller as an idea. Compiles and almost works. * More generalized than before. * More abstraction still. * Made things work. * Made things work. * Zones firing. * Machines work via new style now. * Slight cleanup. * Iso net with load balancer rules working now. * Set nginx to use default ports. * Isolated networks create and delete with load balancer and fill endpoint hosts now. * Builds a cluster. * Added Affinity group crd. * Added machine health checker. * Afinity groups are a go. * Update partially to main. * Some cleanup. More to come. * Fixup missing dispose iso net call. * Removed machine health checker crd. * Removed machine health checker crd. * Implement CloudStackMachineStateChecker * Change to lower cases * Passes webhook and controller tests. Passes lint. * Unit tests fixed up. * Mild cleanup. * Updated per PR comments. * Fixup tests. * Fixup again. * Readd non-root. * Fix isolated network deletion. * pr review comments addressed. * Fix tests. * Fixup finalizer. * Fix issues after merge the CRD breakout PR * Fix comments * Update comments Co-authored-by: Joshua Reed <[email protected]> Co-authored-by: Wonkun Kim <[email protected]>
1 parent 3247e55 commit 73703a7

18 files changed

+462
-7
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ resources:
6868
kind: CloudStackAffinityGroup
6969
path: github.com/aws/cluster-api-provider-cloudstack/api/v1beta1
7070
version: v1beta1
71+
- api:
72+
crdVersion: v1
73+
namespaced: true
74+
controller: true
75+
domain: cluster.x-k8s.io
76+
group: infrastructure
77+
kind: CloudStackMachineStateChecker
78+
path: github.com/aws/cluster-api-provider-cloudstack/api/v1beta1
79+
version: v1beta1
7180
version: "3"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
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 v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// CloudStackMachineStateCheckerSpec
24+
type CloudStackMachineStateCheckerSpec struct {
25+
// CloudStack machine instance ID
26+
InstanceID string `json:"instanceID,omitempty"`
27+
}
28+
29+
// CloudStackMachineStateCheckerStatus defines the observed state of CloudStackMachineStateChecker
30+
type CloudStackMachineStateCheckerStatus struct {
31+
// Reflects the readiness of the Machine State Checker.
32+
Ready bool `json:"ready"`
33+
}
34+
35+
//+kubebuilder:object:root=true
36+
//+kubebuilder:subresource:status
37+
38+
// CloudStackMachineStateChecker is the Schema for the cloudstackmachinestatecheckers API
39+
type CloudStackMachineStateChecker struct {
40+
metav1.TypeMeta `json:",inline"`
41+
metav1.ObjectMeta `json:"metadata,omitempty"`
42+
43+
Spec CloudStackMachineStateCheckerSpec `json:"spec,omitempty"`
44+
Status CloudStackMachineStateCheckerStatus `json:"status,omitempty"`
45+
}
46+
47+
//+kubebuilder:object:root=true
48+
49+
// CloudStackMachineStateCheckerList contains a list of CloudStackMachineStateChecker
50+
type CloudStackMachineStateCheckerList struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ListMeta `json:"metadata,omitempty"`
53+
Items []CloudStackMachineStateChecker `json:"items"`
54+
}
55+
56+
func init() {
57+
SchemeBuilder.Register(&CloudStackMachineStateChecker{}, &CloudStackMachineStateCheckerList{})
58+
}

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.4.1
8+
creationTimestamp: null
9+
name: cloudstackmachinestatecheckers.infrastructure.cluster.x-k8s.io
10+
spec:
11+
group: infrastructure.cluster.x-k8s.io
12+
names:
13+
kind: CloudStackMachineStateChecker
14+
listKind: CloudStackMachineStateCheckerList
15+
plural: cloudstackmachinestatecheckers
16+
singular: cloudstackmachinestatechecker
17+
scope: Namespaced
18+
versions:
19+
- name: v1beta1
20+
schema:
21+
openAPIV3Schema:
22+
description: CloudStackMachineStateChecker is the Schema for the cloudstackmachinestatecheckers
23+
API
24+
properties:
25+
apiVersion:
26+
description: 'APIVersion defines the versioned schema of this representation
27+
of an object. Servers should convert recognized schemas to the latest
28+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
29+
type: string
30+
kind:
31+
description: 'Kind is a string value representing the REST resource this
32+
object represents. Servers may infer this from the endpoint the client
33+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
34+
type: string
35+
metadata:
36+
type: object
37+
spec:
38+
description: CloudStackMachineStateCheckerSpec defines the desired state
39+
of CloudStackMachineStateChecker
40+
properties:
41+
instanceID:
42+
description: CloudStack machine instance ID
43+
type: string
44+
type: object
45+
status:
46+
description: CloudStackMachineStateCheckerStatus defines the observed
47+
state of CloudStackMachineStateChecker
48+
properties:
49+
ready:
50+
description: Reflects the readiness of the Machine State Checker.
51+
type: boolean
52+
required:
53+
- ready
54+
type: object
55+
type: object
56+
served: true
57+
storage: true
58+
subresources:
59+
status: {}
60+
status:
61+
acceptedNames:
62+
kind: ""
63+
plural: ""
64+
conditions: []
65+
storedVersions: []

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ resources:
1111
- bases/infrastructure.cluster.x-k8s.io_cloudstackisolatednetworks.yaml
1212
- bases/infrastructure.cluster.x-k8s.io_cloudstackzones.yaml
1313
- bases/infrastructure.cluster.x-k8s.io_cloudstackaffinitygroups.yaml
14+
- bases/infrastructure.cluster.x-k8s.io_cloudstackmachinestatecheckers.yaml
1415
#+kubebuilder:scaffold:crdkustomizeresource
1516

1617
patchesStrategicMerge:
@@ -21,6 +22,7 @@ patchesStrategicMerge:
2122
#- patches/webhook_in_cloudstackisolatednetworks.yaml
2223
#- patches/webhook_in_cloudstackzones.yaml
2324
#- patches/webhook_in_cloudstackaffinitygroups.yaml
25+
#- patches/webhook_in_cloudstackmachinestatecheckers.yaml
2426
#+kubebuilder:scaffold:crdkustomizewebhookpatch
2527

2628
# patches here are for enabling the CA injection for each CRD
@@ -30,6 +32,7 @@ patchesStrategicMerge:
3032
#- patches/cainjection_in_cloudstackisolatednetworks.yaml
3133
#- patches/cainjection_in_cloudstackzones.yaml
3234
#- patches/cainjection_in_cloudstackaffinitygroups.yaml
35+
#- patches/cainjection_in_cloudstackmachinestatecheckers.yaml
3336
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
3437

3538
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
name: cloudstackmachinestatecheckers.infrastructure.cluster.x-k8s.io
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables a conversion webhook for the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: cloudstackmachinestatecheckers.infrastructure.cluster.x-k8s.io
6+
spec:
7+
conversion:
8+
strategy: Webhook
9+
webhook:
10+
clientConfig:
11+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert
15+
conversionReviewVersions:
16+
- v1
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# permissions for end users to edit cloudstackmachinestatecheckers.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: cloudstackmachinestatechecker-editor-role
6+
rules:
7+
- apiGroups:
8+
- infrastructure.cluster.x-k8s.io
9+
resources:
10+
- cloudstackmachinestatecheckers
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
- apiGroups:
20+
- infrastructure.cluster.x-k8s.io
21+
resources:
22+
- cloudstackmachinestatecheckers/status
23+
verbs:
24+
- get
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# permissions for end users to view cloudstackmachinestatecheckers.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: cloudstackmachinestatechecker-viewer-role
6+
rules:
7+
- apiGroups:
8+
- infrastructure.cluster.x-k8s.io
9+
resources:
10+
- cloudstackmachinestatecheckers
11+
verbs:
12+
- get
13+
- list
14+
- watch
15+
- apiGroups:
16+
- infrastructure.cluster.x-k8s.io
17+
resources:
18+
- cloudstackmachinestatecheckers/status
19+
verbs:
20+
- get

config/rbac/role.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ rules:
3434
- get
3535
- list
3636
- watch
37+
- apiGroups:
38+
- cluster.x-k8s.io
39+
resources:
40+
- machines
41+
verbs:
42+
- delete
43+
- get
44+
- list
45+
- watch
3746
- apiGroups:
3847
- cluster.x-k8s.io
3948
resources:
@@ -164,6 +173,32 @@ rules:
164173
- get
165174
- patch
166175
- update
176+
- apiGroups:
177+
- infrastructure.cluster.x-k8s.io
178+
resources:
179+
- cloudstackmachinestatecheckers
180+
verbs:
181+
- create
182+
- delete
183+
- get
184+
- list
185+
- patch
186+
- update
187+
- watch
188+
- apiGroups:
189+
- infrastructure.cluster.x-k8s.io
190+
resources:
191+
- cloudstackmachinestatecheckers/finalizers
192+
verbs:
193+
- update
194+
- apiGroups:
195+
- infrastructure.cluster.x-k8s.io
196+
resources:
197+
- cloudstackmachinestatecheckers/status
198+
verbs:
199+
- get
200+
- patch
201+
- update
167202
- apiGroups:
168203
- infrastructure.cluster.x-k8s.io
169204
resources:

0 commit comments

Comments
 (0)