Skip to content

Commit

Permalink
Add clusterclass support for Power VS
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Nov 22, 2022
1 parent bd2090a commit 848d42b
Show file tree
Hide file tree
Showing 11 changed files with 882 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ resources:
- group: infrastructure
kind: IBMPowerVSImage
version: v1beta1
- group: infrastructure
kind: IBMPowerVSClusterTemplate
version: v1beta1
version: "2"
62 changes: 62 additions & 0 deletions api/v1beta1/ibmpowervsclustertemplate_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 v1beta1

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

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

// IBMPowerVSClusterTemplateSpec defines the desired state of IBMPowerVSClusterTemplate.
type IBMPowerVSClusterTemplateSpec struct {
Template IBMPowerVSClusterTemplateResource `json:"template"`
}

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

// IBMPowerVSClusterTemplate is the schema for IBM Power VS Kubernetes Cluster Templates.
type IBMPowerVSClusterTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

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

//+kubebuilder:object:root=true

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

// IBMPowerVSClusterTemplateResource describes the data needed to create an IBMPowerVSCluster from a template.
type IBMPowerVSClusterTemplateResource 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 IBMPowerVSClusterSpec `json:"spec"`
}

func init() {
SchemeBuilder.Register(&IBMPowerVSClusterTemplate{}, &IBMPowerVSClusterTemplateList{})
}
91 changes: 91 additions & 0 deletions api/v1beta1/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,130 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: ibmpowervsclustertemplates.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: IBMPowerVSClusterTemplate
listKind: IBMPowerVSClusterTemplateList
plural: ibmpowervsclustertemplates
shortNames:
- ibmpowervsct
singular: ibmpowervsclustertemplate
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Time duration since creation of IBMPowerVSClusterTemplate
jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1beta1
schema:
openAPIV3Schema:
description: IBMPowerVSClusterTemplate is the schema for IBM Power VS Kubernetes
Cluster Templates.
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: IBMPowerVSClusterTemplateSpec defines the desired state of
IBMPowerVSClusterTemplate.
properties:
template:
description: IBMPowerVSClusterTemplateResource describes the data
needed to create an IBMPowerVSCluster 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: IBMPowerVSClusterSpec defines the desired state of
IBMPowerVSCluster.
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
network:
description: Network is the reference to the Network to use
for this cluster.
properties:
id:
description: ID of resource
minLength: 1
type: string
name:
description: Name of resource
minLength: 1
type: string
regex:
description: Regular expression to match resource, In
case of multiple resources matches the provided regular
expression the first matched resource will be selected
minLength: 1
type: string
type: object
serviceInstanceID:
description: ServiceInstanceID is the id of the power cloud
instance where the vsi instance will get deployed.
minLength: 1
type: string
required:
- network
- serviceInstanceID
type: object
required:
- spec
type: object
required:
- template
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 @@ -16,6 +16,7 @@ resources:
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsmachines.yaml
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsmachinetemplates.yaml
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsimages.yaml
- bases/infrastructure.cluster.x-k8s.io_ibmpowervsclustertemplates.yaml
# +kubebuilder:scaffold:crdkustomizeresource

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

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

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
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: ibmpowervsclustertemplates.infrastructure.cluster.x-k8s.io
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_ibmpowervsclustertemplates.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: ibmpowervsclustertemplates.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/ibmpowervsclustertemplate_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# permissions for end users to edit ibmpowervsclustertemplates.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ibmpowervsclustertemplate-editor-role
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmpowervsclustertemplates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmpowervsclustertemplates/status
verbs:
- get
20 changes: 20 additions & 0 deletions config/rbac/ibmpowervsclustertemplate_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# permissions for end users to view ibmpowervsclustertemplates.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ibmpowervsclustertemplate-viewer-role
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmpowervsclustertemplates
verbs:
- get
- list
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- ibmpowervsclustertemplates/status
verbs:
- get
Loading

0 comments on commit 848d42b

Please sign in to comment.