Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

wip add gke types #1

Draft
wants to merge 9 commits into
base: improbable
Choose a base branch
from
Draft
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
69 changes: 69 additions & 0 deletions api/v1alpha3/gcpmanagedcluster_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2019 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 v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
)

const (
// ManagedClusterFinalizer allows ReconcileGCPManagedCluster to clean up GCP resources associated with GCPManagedCluster before
// removing it from the apiserver.
ManagedClusterFinalizer = "gcpmanagedcluster.infrastructure.cluster.x-k8s.io"
)

// GCPManagedClusterSpec defines the desired state of GCPManagedCluster
type GCPManagedClusterSpec struct {
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
}

// GCPManagedClusterStatus defines the observed state of GCPManagedCluster
type GCPManagedClusterStatus struct {
Ready bool `json:"ready"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=gcpmanagedclusters,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this GCPManagedCluster belongs"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Cluster infrastructure is ready"

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

Spec GCPManagedClusterSpec `json:"spec,omitempty"`
Status GCPManagedClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&GCPManagedCluster{}, &GCPManagedClusterList{})
}
93 changes: 93 additions & 0 deletions api/v1alpha3/gcpmanagedcontrolplane_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2019 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 v1alpha3

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
)

// GCPManagedControlPlaneSpec defines the desired state of GCPManagedControlPlane
type GCPManagedControlPlaneSpec struct {
// Version defines the desired Kubernetes version.
// +kubebuilder:validation:MinLength:=2
// +kubebuilder:validation:Pattern:=^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-0-9a-zA-Z_\.+]*)?$
Version string `json:"version"`

// Project is the name of the GCP project to start the GKE cluster in.
Project string `json:"project"`

// Region is a string matching one of the canonical GCP region names. Examples: "us-central1", "europe-west1".
Region string `json:"region"`

// Network encapsulates all things related to GCP network.
// +optional
Network *ManagedNetworkSpec `json:"network,omitempty"`

// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`

// AdditionalLabels is an optional set of labels to add to GCP resources managed by the GCP provider, in addition to the
// ones added by default.
// +optional
AdditionalLabels map[string]string `json:"additionalLabels,omitempty"`

// DefaultPoolRef is the specification for the default pool, without which an GKE cluster cannot be created.
DefaultPoolRef corev1.LocalObjectReference `json:"defaultPoolRef"`
}

// GCPManagedControlPlaneStatus defines the observed state of GCPManagedControlPlane
type GCPManagedControlPlaneStatus struct {
// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready,omitempty"`

// Initialized is true when the the control plane is available for initial contact.
// This may occur before the control plane is fully ready.
// In the GCPManagedControlPlane implementation, these are identical.
// +optional
Initialized bool `json:"initialized,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=gcpmanagedcontrolplanes,scope=Namespaced,categories=cluster-api,shortName=gmcp
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

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

Spec GCPManagedControlPlaneSpec `json:"spec,omitempty"`
Status GCPManagedControlPlaneStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&GCPManagedControlPlane{}, &GCPManagedControlPlaneList{})
}
99 changes: 99 additions & 0 deletions api/v1alpha3/gcpmanagedmachinepool_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Copyright 2019 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 v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
capierrors "sigs.k8s.io/cluster-api/errors"
)

const (
// ManagedMachinePoolFinalizer allows ReconcileGCPManagedMachinePool to clean up GCP resources associated with #
// GCPManagedMachinePool before removing it from the apiserver.
ManagedMachinePoolFinalizer = "gcpmanagedmachinepool.infrastructure.cluster.x-k8s.io"
)

// GCPManagedMachinePoolSpec defines the desired state of GCPManagedMachinePool
type GCPManagedMachinePoolSpec struct {
// InstanceType is the type of the VMs in the node pool.
InstanceType string `json:"instanceType"`

// BootDiskSizeGB is the disk size for every machine in this pool.
// If you specify 0, it will apply the default size.
// +optional
BootDiskSizeGB *int32 `json:"bootDiskSizeGB,omitempty"`

// DiskType is the type of boot disk for machines in this pool.
// Possible values include: 'pd-standard', 'pd-ssd'. Defaults to 'pd-standard'.
// +kubebuilder:validation:Enum=pd-standard;pd-ssd
// +optional
DiskType string `json:"diskType,omitempty"`

// Preemptible determines if the nodes are preemptible. Defaults to false.
// +optional
Preemptible bool `json:"preemptible,omitempty"`
}

// GCPManagedMachinePoolStatus defines the observed state of GCPManagedMachinePool
type GCPManagedMachinePoolStatus struct {
// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`

// Replicas is the most recently observed number of replicas.
// +optional
Replicas int32 `json:"replicas"`

// Any transient errors that occur during the reconciliation of Machines
// can be added as events to the Machine object and/or logged in the
// controller's output.
// +optional
ErrorReason *capierrors.MachineStatusError `json:"errorReason,omitempty"`

// Any transient errors that occur during the reconciliation of Machines
// can be added as events to the Machine object and/or logged in the
// controller's output.
// +optional
ErrorMessage *string `json:"errorMessage,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=gcpmanagedmachinepools,scope=Namespaced,categories=cluster-api,shortName=gmmp
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

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

Spec GCPManagedMachinePoolSpec `json:"spec,omitempty"`
Status GCPManagedMachinePoolStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&GCPManagedMachinePool{}, &GCPManagedMachinePoolList{})
}
12 changes: 12 additions & 0 deletions api/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ type NetworkSpec struct {
LoadBalancerBackendPort *int32 `json:"loadBalancerBackendPort,omitempty"`
}

type ManagedNetworkSpec struct {
// Name is the name of the network to be used.
// If empty, defaults to the default network.
// +optional
Name *string `json:"name,omitempty"`

// Subnetwork is the name of the subnetwork to be used.
// If empty, an automatic name will be used.
// +optional
Subnetwork *string `json:"subnetwork,omitempty"`
}

// SubnetSpec configures an GCP Subnet.
type SubnetSpec struct {
// Name defines a unique identifier to reference this resource.
Expand Down
Loading