Skip to content

Commit 1ebac57

Browse files
committed
implement gke bootstrap logic to satisfy clusterclass capi contract
Signed-off-by: Carlos Salas <[email protected]>
1 parent c430ad0 commit 1ebac57

14 files changed

+833
-6
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ generate-go: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate tar
329329
paths=./ \
330330
paths=./... \
331331
paths=./$(EXP_DIR)/api/... \
332+
paths=./$(EXP_DIR)/bootstrap/gke/api/... \
332333
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
333334
go generate ./...
334335

@@ -338,6 +339,7 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
338339
paths=./ \
339340
paths=./api/... \
340341
paths=./$(EXP_DIR)/api/... \
342+
paths=./$(EXP_DIR)/bootstrap/gke/api/... \
341343
crd:crdVersions=v1 \
342344
rbac:roleName=manager-role \
343345
output:crd:dir=$(CRD_ROOT) \
@@ -347,6 +349,7 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
347349
paths=./ \
348350
paths=./controllers/... \
349351
paths=./$(EXP_DIR)/controllers/... \
352+
paths=./$(EXP_DIR)/bootstrap/gke/controllers/... \
350353
output:rbac:dir=$(RBAC_ROOT) \
351354
rbac:roleName=manager-role
352355

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.17.3
7+
name: gkeconfigs.bootstrap.cluster.x-k8s.io
8+
spec:
9+
group: bootstrap.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: GKEConfig
14+
listKind: GKEConfigList
15+
plural: gkeconfigs
16+
shortNames:
17+
- gkec
18+
singular: gkeconfig
19+
scope: Namespaced
20+
versions:
21+
- additionalPrinterColumns:
22+
- description: Bootstrap configuration is ready
23+
jsonPath: .status.ready
24+
name: Ready
25+
type: string
26+
- description: Name of Secret containing bootstrap data
27+
jsonPath: .status.dataSecretName
28+
name: DataSecretName
29+
type: string
30+
name: v1beta1
31+
schema:
32+
openAPIV3Schema:
33+
description: |-
34+
GKEConfig is the schema for the GCP GKE Bootstrap Configuration.
35+
this is a placeholder used for compliance with the CAPI contract.
36+
properties:
37+
apiVersion:
38+
description: |-
39+
APIVersion defines the versioned schema of this representation of an object.
40+
Servers should convert recognized schemas to the latest internal value, and
41+
may reject unrecognized values.
42+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
43+
type: string
44+
kind:
45+
description: |-
46+
Kind is a string value representing the REST resource this object represents.
47+
Servers may infer this from the endpoint the client submits requests to.
48+
Cannot be updated.
49+
In CamelCase.
50+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
51+
type: string
52+
metadata:
53+
type: object
54+
spec:
55+
description: GKEConfigSpec defines the desired state of GCP GKE Bootstrap
56+
Configuration.
57+
type: object
58+
status:
59+
description: GKEConfigStatus defines the observed state of the GCP GKE
60+
Bootstrap Configuration.
61+
properties:
62+
conditions:
63+
description: Conditions defines current service state of the GKEConfig.
64+
items:
65+
description: Condition defines an observation of a Cluster API resource
66+
operational state.
67+
properties:
68+
lastTransitionTime:
69+
description: |-
70+
lastTransitionTime is the last time the condition transitioned from one status to another.
71+
This should be when the underlying condition changed. If that is not known, then using the time when
72+
the API field changed is acceptable.
73+
format: date-time
74+
type: string
75+
message:
76+
description: |-
77+
message is a human readable message indicating details about the transition.
78+
This field may be empty.
79+
maxLength: 10240
80+
minLength: 1
81+
type: string
82+
reason:
83+
description: |-
84+
reason is the reason for the condition's last transition in CamelCase.
85+
The specific API may choose whether or not this field is considered a guaranteed API.
86+
This field may be empty.
87+
maxLength: 256
88+
minLength: 1
89+
type: string
90+
severity:
91+
description: |-
92+
severity provides an explicit classification of Reason code, so the users or machines can immediately
93+
understand the current situation and act accordingly.
94+
The Severity field MUST be set only when Status=False.
95+
maxLength: 32
96+
type: string
97+
status:
98+
description: status of the condition, one of True, False, Unknown.
99+
type: string
100+
type:
101+
description: |-
102+
type of condition in CamelCase or in foo.example.com/CamelCase.
103+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
104+
can be useful (see .node.status.conditions), the ability to deconflict is important.
105+
maxLength: 256
106+
minLength: 1
107+
type: string
108+
required:
109+
- lastTransitionTime
110+
- status
111+
- type
112+
type: object
113+
type: array
114+
dataSecretName:
115+
description: DataSecretName is the name of the secret that stores
116+
the bootstrap data script.
117+
type: string
118+
failureMessage:
119+
description: FailureMessage will be set on non-retryable errors
120+
type: string
121+
failureReason:
122+
description: FailureReason will be set on non-retryable errors
123+
type: string
124+
observedGeneration:
125+
description: ObservedGeneration is the latest generation observed
126+
by the controller.
127+
format: int64
128+
type: integer
129+
ready:
130+
description: Ready indicates the BootstrapData secret is ready to
131+
be consumed
132+
type: boolean
133+
type: object
134+
type: object
135+
served: true
136+
storage: true
137+
subresources:
138+
status: {}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.17.3
7+
name: gkeconfigtemplates.bootstrap.cluster.x-k8s.io
8+
spec:
9+
group: bootstrap.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: GKEConfigTemplate
14+
listKind: GKEConfigTemplateList
15+
plural: gkeconfigtemplates
16+
shortNames:
17+
- gkect
18+
singular: gkeconfigtemplate
19+
scope: Namespaced
20+
versions:
21+
- name: v1beta1
22+
schema:
23+
openAPIV3Schema:
24+
description: GKEConfigTemplate is the GCP GKE Bootstrap Configuration Template
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: GKEConfigTemplateSpec defines the desired state of templated
46+
GKEConfig GCP GKE Bootstrap Configuration resources.
47+
properties:
48+
template:
49+
description: GKEConfigTemplateResource defines the Template structure.
50+
properties:
51+
spec:
52+
description: GKEConfigSpec defines the desired state of GCP GKE
53+
Bootstrap Configuration.
54+
type: object
55+
type: object
56+
required:
57+
- template
58+
type: object
59+
type: object
60+
served: true
61+
storage: true

config/crd/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ resources:
1515
- bases/infrastructure.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml
1616
- bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanetemplates.yaml
1717
- bases/infrastructure.cluster.x-k8s.io_gcpmanagedmachinepooltemplates.yaml
18+
- bases/bootstrap.cluster.x-k8s.io_gkeconfigs.yaml
19+
- bases/bootstrap.cluster.x-k8s.io_gkeconfigtemplates.yaml
1820

1921
# +kubebuilder:scaffold:crdkustomizeresource
2022

config/rbac/role.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,37 @@ rules:
3939
- subjectaccessreviews
4040
verbs:
4141
- create
42+
- apiGroups:
43+
- bootstrap.cluster.x-k8s.io
44+
resources:
45+
- gkeconfigs
46+
verbs:
47+
- get
48+
- list
49+
- patch
50+
- update
51+
- watch
52+
- apiGroups:
53+
- bootstrap.cluster.x-k8s.io
54+
resources:
55+
- gkeconfigs/status
56+
verbs:
57+
- get
58+
- patch
59+
- update
4260
- apiGroups:
4361
- cluster.x-k8s.io
4462
resources:
4563
- clusters
4664
- clusters/status
65+
verbs:
66+
- get
67+
- list
68+
- patch
69+
- watch
70+
- apiGroups:
71+
- cluster.x-k8s.io
72+
resources:
4773
- machinepools
4874
- machinepools/status
4975
- machines

exp/api/v1beta1/gcpmanagedmachinepool_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
ManagedMachinePoolFinalizer = "gcpmanagedmachinepool.infrastructure.cluster.x-k8s.io"
2828

2929
// GCPManagedMachinePoolMachineKind indicates the kind of an GCPManagedMachinePoolMachine.
30-
GCPManagedMachinePoolMachineKind = "GCPManagedMachinePoolMachine"
30+
GCPManagedMachinePoolMachineKind = "GCPManagedMachinePool"
3131
)
3232

3333
// DiskType is type of the disk attached to node.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
Copyright 2025 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+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
)
23+
24+
// GKEConfigSpec defines the desired state of GCP GKE Bootstrap Configuration.
25+
type GKEConfigSpec struct{}
26+
27+
// +kubebuilder:object:root=true
28+
// +kubebuilder:resource:path=gkeconfigs,scope=Namespaced,categories=cluster-api,shortName=gkec
29+
// +kubebuilder:storageversion
30+
// +kubebuilder:subresource:status
31+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Bootstrap configuration is ready"
32+
// +kubebuilder:printcolumn:name="DataSecretName",type="string",JSONPath=".status.dataSecretName",description="Name of Secret containing bootstrap data"
33+
34+
// GKEConfig is the schema for the GCP GKE Bootstrap Configuration.
35+
// this is a placeholder used for compliance with the CAPI contract.
36+
type GKEConfig struct {
37+
metav1.TypeMeta `json:",inline"`
38+
metav1.ObjectMeta `json:"metadata,omitempty"`
39+
40+
Spec GKEConfigSpec `json:"spec,omitempty"`
41+
Status GKEConfigStatus `json:"status,omitempty"`
42+
}
43+
44+
// GKEConfigStatus defines the observed state of the GCP GKE Bootstrap Configuration.
45+
type GKEConfigStatus struct {
46+
// Ready indicates the BootstrapData secret is ready to be consumed
47+
Ready bool `json:"ready,omitempty"`
48+
49+
// DataSecretName is the name of the secret that stores the bootstrap data script.
50+
// +optional
51+
DataSecretName *string `json:"dataSecretName,omitempty"`
52+
53+
// FailureReason will be set on non-retryable errors
54+
// +optional
55+
FailureReason string `json:"failureReason,omitempty"`
56+
57+
// FailureMessage will be set on non-retryable errors
58+
// +optional
59+
FailureMessage string `json:"failureMessage,omitempty"`
60+
61+
// ObservedGeneration is the latest generation observed by the controller.
62+
// +optional
63+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
64+
65+
// Conditions defines current service state of the GKEConfig.
66+
// +optional
67+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
68+
}
69+
70+
// +kubebuilder:object:root=true
71+
72+
// GKEConfigList contains a list of GCP GKE Bootstrap Configuration.
73+
type GKEConfigList struct {
74+
metav1.TypeMeta `json:",inline"`
75+
metav1.ListMeta `json:"metadata,omitempty"`
76+
Items []GKEConfig `json:"items"`
77+
}
78+
79+
func init() {
80+
SchemeBuilder.Register(&GKEConfig{}, &GKEConfigList{})
81+
}

0 commit comments

Comments
 (0)