Skip to content

Commit 8978f64

Browse files
committed
Add support for VPC clusterclass
1 parent 0775f0d commit 8978f64

10 files changed

+766
-0
lines changed

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

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)