Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for VPC clusterclass #1500

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ generate-templates: $(KUSTOMIZE)
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass.yaml

.PHONY: generate-e2e-templates
generate-e2e-templates: $(KUSTOMIZE)
Expand Down
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ resources:
- group: infrastructure
kind: IBMPowerVSClusterTemplate
version: v1beta2
- group: infrastructure
kind: IBMVPCClusterTemplate
version: v1beta2
version: "2"
62 changes: 62 additions & 0 deletions api/v1beta2/ibmvpcclustertemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// IBMVPCClusterTemplateSpec defines the desired state of IBMVPCClusterTemplate.
type IBMVPCClusterTemplateSpec struct {
Template IBMVPCClusterTemplateResource `json:"template,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=ibmvpcclustertemplates,scope=Namespaced,categories=cluster-api,shortName=ibmvpcct
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of IBMVPCClusterTemplate"

// IBMVPCClusterTemplate is the Schema for the ibmvpcclustertemplates API.
type IBMVPCClusterTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec IBMVPCClusterTemplateSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

// IBMVPCClusterTemplateList contains a list of IBMVPCClusterTemplate.
type IBMVPCClusterTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []IBMVPCClusterTemplate `json:"items"`
}

// IBMVPCClusterTemplateResource describes the data needed to create an IBMVPCCluster from a template.
type IBMVPCClusterTemplateResource struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta capiv1beta1.ObjectMeta `json:"metadata,omitempty"`
Spec IBMVPCClusterSpec `json:"spec"`
}

func init() {
SchemeBuilder.Register(&IBMVPCClusterTemplate{}, &IBMVPCClusterTemplateList{})
}
91 changes: 91 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: ibmvpcclustertemplates.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: IBMVPCClusterTemplate
listKind: IBMVPCClusterTemplateList
plural: ibmvpcclustertemplates
shortNames:
- ibmvpcct
singular: ibmvpcclustertemplate
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Time duration since creation of IBMVPCClusterTemplate
jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1beta2
schema:
openAPIV3Schema:
description: IBMVPCClusterTemplate is the Schema for the ibmvpcclustertemplates
API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: IBMVPCClusterTemplateSpec defines the desired state of IBMVPCClusterTemplate.
properties:
template:
description: IBMVPCClusterTemplateResource describes the data needed
to create an IBMVPCCluster from a template.
properties:
metadata:
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map
stored with a resource that may be set by external tools
to store and retrieve arbitrary metadata. They are not queryable
and should be preserved when modifying objects. More info:
http://kubernetes.io/docs/user-guide/annotations'
type: object
labels:
additionalProperties:
type: string
description: 'Map of string keys and values that can be used
to organize and categorize (scope and select) objects. May
match selectors of replication controllers and services.
More info: http://kubernetes.io/docs/user-guide/labels'
type: object
type: object
spec:
description: IBMVPCClusterSpec defines the desired state of IBMVPCCluster.
properties:
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint
used to communicate with the control plane.
properties:
host:
description: The hostname on which the API server is serving.
type: string
port:
description: The port on which the API server is serving.
format: int32
type: integer
required:
- host
- port
type: object
controlPlaneLoadBalancer:
description: ControlPlaneLoadBalancer is optional configuration
for customizing control plane behavior.
properties:
name:
description: Name sets the name of the VPC load balancer.
maxLength: 63
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
type: object
region:
description: The IBM Cloud Region the cluster lives in.
type: string
resourceGroup:
description: The VPC resources should be created under the
resource group.
type: string
vpc:
description: The Name of VPC.
type: string
zone:
description: The Name of availability zone.
type: string
required:
- region
- resourceGroup
type: object
required:
- spec
type: object
type: object
type: object
served: true
storage: true
subresources: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ resources:
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsmachinetemplates.yaml
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsimages.yaml
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsclustertemplates.yaml
- bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand All @@ -28,6 +29,7 @@ patchesStrategicMerge:
- patches/webhook_in_ibmvpcmachinetemplates.yaml
- patches/webhook_in_ibmpowervsimages.yaml
#- patches/webhook_in_ibmpowervsclustertemplates.yaml
#- patches/webhook_in_ibmvpcclustertemplates.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -40,6 +42,7 @@ patchesStrategicMerge:
- patches/cainjection_in_ibmvpcmachinetemplates.yaml
- patches/cainjection_in_ibmpowervsimages.yaml
#- patches/cainjection_in_ibmpowervsclustertemplates.yaml
#- patches/cainjection_in_ibmvpcclustertemplates.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_ibmvpcclustertemplates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: ibmvpcclustertemplates.infrastructure.cluster.x-k8s.io
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_ibmvpcclustertemplates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The following patch enables conversion webhook for CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: ibmvpcclustertemplates.infrastructure.cluster.x-k8s.io
spec:
conversion:
strategy: Webhook
webhookClientConfig:
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
caBundle: Cg==
service:
namespace: system
name: webhook-service
path: /convert
24 changes: 24 additions & 0 deletions config/rbac/ibmvpcclustertemplate_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# permissions for end users to edit ibmvpcclustertemplates.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ibmvpcclustertemplate-editor-role
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmvpcclustertemplates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmvpcclustertemplates/status
verbs:
- get
20 changes: 20 additions & 0 deletions config/rbac/ibmvpcclustertemplate_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# permissions for end users to view ibmvpcclustertemplates.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ibmvpcclustertemplate-viewer-role
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmvpcclustertemplates
verbs:
- get
- list
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmvpcclustertemplates/status
verbs:
- get
Loading