-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright 2021 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 v1alpha4 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// GCPClusterTemplateSpec defines the desired state of GCPClusterTemplate. | ||
type GCPClusterTemplateSpec struct { | ||
Template GCPClusterTemplateResource `json:"template"` | ||
} | ||
|
||
// GCPClusterTemplateResource contains spec for GCPClusterSpec. | ||
type GCPClusterTemplateResource struct { | ||
Spec GCPClusterSpec `json:"spec"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:resource:path=gcpclustertemplates,scope=Namespaced,categories=cluster-api,shortName=gcpct | ||
//+kubebuilder:storageversion | ||
|
||
// GCPClusterTemplate is the Schema for the gcpclustertemplates API. | ||
type GCPClusterTemplate struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec GCPClusterTemplateSpec `json:"spec,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// GCPClusterTemplateList contains a list of GCPClusterTemplate. | ||
type GCPClusterTemplateList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []GCPClusterTemplate `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&GCPClusterTemplate{}, &GCPClusterTemplateList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
Copyright 2021 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 v1alpha4 | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
|
||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
"sigs.k8s.io/controller-runtime/pkg/webhook" | ||
) | ||
|
||
// log is for logging in this package. | ||
var gcpclustertemplatelog = logf.Log.WithName("gcpclustertemplate-resource") | ||
|
||
func (r *GCPClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewWebhookManagedBy(mgr). | ||
For(r). | ||
Complete() | ||
} | ||
|
||
//+kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1alpha4-gcpclustertemplate,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=gcpclustertemplates,versions=v1alpha4,name=default.gcpclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1 | ||
|
||
var _ webhook.Defaulter = &GCPClusterTemplate{} | ||
|
||
// Default implements webhook.Defaulter so a webhook will be registered for the type. | ||
func (r *GCPClusterTemplate) Default() { | ||
gcpclustertemplatelog.Info("default", "name", r.Name) | ||
} | ||
|
||
//+kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha4-gcpclustertemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=gcpclustertemplates,versions=v1alpha4,name=validation.gcpclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1 | ||
|
||
var _ webhook.Validator = &GCPClusterTemplate{} | ||
|
||
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. | ||
func (r *GCPClusterTemplate) ValidateCreate() error { | ||
gcpclustertemplatelog.Info("validate create", "name", r.Name) | ||
|
||
return nil | ||
} | ||
|
||
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. | ||
func (r *GCPClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error { | ||
old, ok := oldRaw.(*GCPClusterTemplate) | ||
if !ok { | ||
return apierrors.NewBadRequest(fmt.Sprintf("expected an GCPClusterTemplate but got a %T", oldRaw)) | ||
} | ||
|
||
if !reflect.DeepEqual(r.Spec, old.Spec) { | ||
return apierrors.NewBadRequest("GCPClusterTemplate.Spec is immutable") | ||
} | ||
return nil | ||
} | ||
|
||
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. | ||
func (r *GCPClusterTemplate) ValidateDelete() error { | ||
gcpclustertemplatelog.Info("validate delete", "name", r.Name) | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
137 changes: 137 additions & 0 deletions
137
config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.5.0 | ||
creationTimestamp: null | ||
name: gcpclustertemplates.infrastructure.cluster.x-k8s.io | ||
spec: | ||
group: infrastructure.cluster.x-k8s.io | ||
names: | ||
categories: | ||
- cluster-api | ||
kind: GCPClusterTemplate | ||
listKind: GCPClusterTemplateList | ||
plural: gcpclustertemplates | ||
shortNames: | ||
- gcpct | ||
singular: gcpclustertemplate | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha4 | ||
schema: | ||
openAPIV3Schema: | ||
description: GCPClusterTemplate is the Schema for the gcpclustertemplates 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: GCPClusterTemplateSpec defines the desired state of GCPClusterTemplate. | ||
properties: | ||
template: | ||
description: GCPClusterTemplateResource contains spec for GCPClusterSpec. | ||
properties: | ||
spec: | ||
description: GCPClusterSpec defines the desired state of GCPCluster. | ||
properties: | ||
additionalLabels: | ||
additionalProperties: | ||
type: string | ||
description: AdditionalLabels is an optional set of tags to add to GCP resources managed by the GCP provider, in addition to the ones added by default. | ||
type: object | ||
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 | ||
failureDomains: | ||
description: FailureDomains is an optional field which is used to assign selected availability zones to a cluster FailureDomains if empty, defaults to all the zones in the selected region and if specified would override the default zones. | ||
items: | ||
type: string | ||
type: array | ||
network: | ||
description: NetworkSpec encapsulates all things related to GCP network. | ||
properties: | ||
autoCreateSubnetworks: | ||
description: "AutoCreateSubnetworks: When set to true, the VPC network is created in \"auto\" mode. When set to false, the VPC network is created in \"custom\" mode. \n An auto mode VPC network starts with one subnet per region. Each subnet has a predetermined range as described in Auto mode VPC network IP ranges. \n Defaults to true." | ||
type: boolean | ||
loadBalancerBackendPort: | ||
description: Allow for configuration of load balancer backend (useful for changing apiserver port) | ||
format: int32 | ||
type: integer | ||
name: | ||
description: Name is the name of the network to be used. | ||
type: string | ||
subnets: | ||
description: Subnets configuration. | ||
items: | ||
description: SubnetSpec configures an GCP Subnet. | ||
properties: | ||
cidrBlock: | ||
description: CidrBlock is the range of internal addresses that are owned by this subnetwork. Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only IPv4 is supported. This field can be set only at resource creation time. | ||
type: string | ||
description: | ||
description: Description is an optional description associated with the resource. | ||
type: string | ||
name: | ||
description: Name defines a unique identifier to reference this resource. | ||
type: string | ||
privateGoogleAccess: | ||
description: PrivateGoogleAccess defines whether VMs in this subnet can access Google services without assigning external IP addresses | ||
type: boolean | ||
region: | ||
description: Region is the name of the region where the Subnetwork resides. | ||
type: string | ||
routeTableId: | ||
description: 'EnableFlowLogs: Whether to enable flow logging for this subnetwork. If this field is not explicitly set, it will not appear in get listings. If not set the default behavior is to disable flow logging.' | ||
type: boolean | ||
secondaryCidrBlocks: | ||
additionalProperties: | ||
type: string | ||
description: SecondaryCidrBlocks defines secondary CIDR ranges, from which secondary IP ranges of a VM may be allocated | ||
type: object | ||
type: object | ||
type: array | ||
type: object | ||
project: | ||
description: Project is the name of the project to deploy the cluster to. | ||
type: string | ||
region: | ||
description: The GCP Region the cluster lives in. | ||
type: string | ||
required: | ||
- project | ||
- region | ||
type: object | ||
required: | ||
- spec | ||
type: object | ||
required: | ||
- template | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
Oops, something went wrong.