Skip to content

Commit 9589dad

Browse files
authored
Add support for VPC clusterclass (#1500)
* Add support for VPC clusterclass * Add templates to generate vpc-clusterclass template * Add documentation for VPC clusterclass
1 parent ea7ec75 commit 9589dad

18 files changed

+969
-4
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ generate-templates: $(KUSTOMIZE)
188188
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs.yaml
189189
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider.yaml
190190
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass.yaml
191+
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass.yaml
191192

192193
.PHONY: generate-e2e-templates
193194
generate-e2e-templates: $(KUSTOMIZE)

PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@ resources:
4949
- group: infrastructure
5050
kind: IBMPowerVSClusterTemplate
5151
version: v1beta2
52+
- group: infrastructure
53+
kind: IBMVPCClusterTemplate
54+
version: v1beta2
5255
version: "2"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 v1beta2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
23+
)
24+
25+
// IBMVPCClusterTemplateSpec defines the desired state of IBMVPCClusterTemplate.
26+
type IBMVPCClusterTemplateSpec struct {
27+
Template IBMVPCClusterTemplateResource `json:"template,omitempty"`
28+
}
29+
30+
// +kubebuilder:object:root=true
31+
// +kubebuilder:resource:path=ibmvpcclustertemplates,scope=Namespaced,categories=cluster-api,shortName=ibmvpcct
32+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of IBMVPCClusterTemplate"
33+
34+
// IBMVPCClusterTemplate is the Schema for the ibmvpcclustertemplates API.
35+
type IBMVPCClusterTemplate struct {
36+
metav1.TypeMeta `json:",inline"`
37+
metav1.ObjectMeta `json:"metadata,omitempty"`
38+
39+
Spec IBMVPCClusterTemplateSpec `json:"spec,omitempty"`
40+
}
41+
42+
//+kubebuilder:object:root=true
43+
44+
// IBMVPCClusterTemplateList contains a list of IBMVPCClusterTemplate.
45+
type IBMVPCClusterTemplateList struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ListMeta `json:"metadata,omitempty"`
48+
Items []IBMVPCClusterTemplate `json:"items"`
49+
}
50+
51+
// IBMVPCClusterTemplateResource describes the data needed to create an IBMVPCCluster from a template.
52+
type IBMVPCClusterTemplateResource struct {
53+
// Standard object's metadata.
54+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
55+
// +optional
56+
ObjectMeta capiv1beta1.ObjectMeta `json:"metadata,omitempty"`
57+
Spec IBMVPCClusterSpec `json:"spec"`
58+
}
59+
60+
func init() {
61+
SchemeBuilder.Register(&IBMVPCClusterTemplate{}, &IBMVPCClusterTemplateList{})
62+
}

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.13.0
7+
name: ibmvpcclustertemplates.infrastructure.cluster.x-k8s.io
8+
spec:
9+
group: infrastructure.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: IBMVPCClusterTemplate
14+
listKind: IBMVPCClusterTemplateList
15+
plural: ibmvpcclustertemplates
16+
shortNames:
17+
- ibmvpcct
18+
singular: ibmvpcclustertemplate
19+
scope: Namespaced
20+
versions:
21+
- additionalPrinterColumns:
22+
- description: Time duration since creation of IBMVPCClusterTemplate
23+
jsonPath: .metadata.creationTimestamp
24+
name: Age
25+
type: date
26+
name: v1beta2
27+
schema:
28+
openAPIV3Schema:
29+
description: IBMVPCClusterTemplate is the Schema for the ibmvpcclustertemplates
30+
API.
31+
properties:
32+
apiVersion:
33+
description: 'APIVersion defines the versioned schema of this representation
34+
of an object. Servers should convert recognized schemas to the latest
35+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
36+
type: string
37+
kind:
38+
description: 'Kind is a string value representing the REST resource this
39+
object represents. Servers may infer this from the endpoint the client
40+
submits requests to. Cannot be updated. In CamelCase. 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: IBMVPCClusterTemplateSpec defines the desired state of IBMVPCClusterTemplate.
46+
properties:
47+
template:
48+
description: IBMVPCClusterTemplateResource describes the data needed
49+
to create an IBMVPCCluster from a template.
50+
properties:
51+
metadata:
52+
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
53+
properties:
54+
annotations:
55+
additionalProperties:
56+
type: string
57+
description: 'Annotations is an unstructured key value map
58+
stored with a resource that may be set by external tools
59+
to store and retrieve arbitrary metadata. They are not queryable
60+
and should be preserved when modifying objects. More info:
61+
http://kubernetes.io/docs/user-guide/annotations'
62+
type: object
63+
labels:
64+
additionalProperties:
65+
type: string
66+
description: 'Map of string keys and values that can be used
67+
to organize and categorize (scope and select) objects. May
68+
match selectors of replication controllers and services.
69+
More info: http://kubernetes.io/docs/user-guide/labels'
70+
type: object
71+
type: object
72+
spec:
73+
description: IBMVPCClusterSpec defines the desired state of IBMVPCCluster.
74+
properties:
75+
controlPlaneEndpoint:
76+
description: ControlPlaneEndpoint represents the endpoint
77+
used to communicate with the control plane.
78+
properties:
79+
host:
80+
description: The hostname on which the API server is serving.
81+
type: string
82+
port:
83+
description: The port on which the API server is serving.
84+
format: int32
85+
type: integer
86+
required:
87+
- host
88+
- port
89+
type: object
90+
controlPlaneLoadBalancer:
91+
description: ControlPlaneLoadBalancer is optional configuration
92+
for customizing control plane behavior.
93+
properties:
94+
name:
95+
description: Name sets the name of the VPC load balancer.
96+
maxLength: 63
97+
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
98+
type: string
99+
type: object
100+
region:
101+
description: The IBM Cloud Region the cluster lives in.
102+
type: string
103+
resourceGroup:
104+
description: The VPC resources should be created under the
105+
resource group.
106+
type: string
107+
vpc:
108+
description: The Name of VPC.
109+
type: string
110+
zone:
111+
description: The Name of availability zone.
112+
type: string
113+
required:
114+
- region
115+
- resourceGroup
116+
type: object
117+
required:
118+
- spec
119+
type: object
120+
type: object
121+
type: object
122+
served: true
123+
storage: true
124+
subresources: {}

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resources:
1515
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsmachinetemplates.yaml
1616
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsimages.yaml
1717
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsclustertemplates.yaml
18+
- bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml
1819
# +kubebuilder:scaffold:crdkustomizeresource
1920

2021
patchesStrategicMerge:
@@ -28,6 +29,7 @@ patchesStrategicMerge:
2829
- patches/webhook_in_ibmvpcmachinetemplates.yaml
2930
- patches/webhook_in_ibmpowervsimages.yaml
3031
#- patches/webhook_in_ibmpowervsclustertemplates.yaml
32+
#- patches/webhook_in_ibmvpcclustertemplates.yaml
3133
# +kubebuilder:scaffold:crdkustomizewebhookpatch
3234

3335
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
@@ -40,6 +42,7 @@ patchesStrategicMerge:
4042
- patches/cainjection_in_ibmvpcmachinetemplates.yaml
4143
- patches/cainjection_in_ibmpowervsimages.yaml
4244
#- patches/cainjection_in_ibmpowervsclustertemplates.yaml
45+
#- patches/cainjection_in_ibmvpcclustertemplates.yaml
4346
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
4447

4548
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
8+
name: ibmvpcclustertemplates.infrastructure.cluster.x-k8s.io
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The following patch enables conversion webhook for CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
name: ibmvpcclustertemplates.infrastructure.cluster.x-k8s.io
7+
spec:
8+
conversion:
9+
strategy: Webhook
10+
webhookClientConfig:
11+
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
12+
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
13+
caBundle: Cg==
14+
service:
15+
namespace: system
16+
name: webhook-service
17+
path: /convert
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 ibmvpcclustertemplates.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: ibmvpcclustertemplate-editor-role
6+
rules:
7+
- apiGroups:
8+
- infrastructure.cluster.x-k8s.io
9+
resources:
10+
- ibmvpcclustertemplates
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+
- ibmvpcclustertemplates/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 ibmvpcclustertemplates.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: ibmvpcclustertemplate-viewer-role
6+
rules:
7+
- apiGroups:
8+
- infrastructure.cluster.x-k8s.io
9+
resources:
10+
- ibmvpcclustertemplates
11+
verbs:
12+
- get
13+
- list
14+
- watch
15+
- apiGroups:
16+
- infrastructure.cluster.x-k8s.io
17+
resources:
18+
- ibmvpcclustertemplates/status
19+
verbs:
20+
- get

0 commit comments

Comments
 (0)