Skip to content

Commit

Permalink
initial: scaffolding of the GKE api/controllers
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Case <[email protected]>

Update API and proposal

go mod tidy

fix tests

fix goimports

make generate
  • Loading branch information
richardcase authored and richardchen331 committed Jan 6, 2023
1 parent 0386260 commit 71a343e
Show file tree
Hide file tree
Showing 30 changed files with 2,414 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
BIN_DIR := $(abspath $(ROOT_DIR)/bin)
EXP_DIR := exp
GO_INSTALL = ./scripts/go_install.sh
E2E_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/gcp-ci.yaml
E2E_CONF_FILE_ENVSUBST := $(ROOT_DIR)/test/e2e/config/gcp-ci-envsubst.yaml
Expand Down Expand Up @@ -320,6 +321,7 @@ generate: ## Generate code
generate-go: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate targets
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./$(EXP_DIR)/api/... \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha3 \
Expand All @@ -339,13 +341,15 @@ generate-go: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate tar
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./$(EXP_DIR)/api/... \
crd:crdVersions=v1 \
rbac:roleName=manager-role \
output:crd:dir=$(CRD_ROOT) \
output:webhook:dir=$(WEBHOOK_ROOT) \
webhook
$(CONTROLLER_GEN) \
paths=./controllers/... \
paths=./$(EXP_DIR)/controllers/... \
output:rbac:dir=$(RBAC_ROOT) \
rbac:roleName=manager-role

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: gcpmanagedclusters.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: GCPManagedCluster
listKind: GCPManagedClusterList
plural: gcpmanagedclusters
shortNames:
- gcpmc
singular: gcpmanagedcluster
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Cluster to which this GCPCluster belongs
jsonPath: .metadata.labels.cluster\.x-k8s\.io/cluster-name
name: Cluster
type: string
- description: Cluster infrastructure is ready for GCE instances
jsonPath: .status.ready
name: Ready
type: string
- description: GCP network the cluster is using
jsonPath: .spec.network.name
name: Network
type: string
- description: API Endpoint
jsonPath: .status.apiEndpoints[0]
name: Endpoint
priority: 1
type: string
name: v1beta1
schema:
openAPIV3Schema:
description: GCPManagedCluster is the Schema for the gcpmanagedclusters 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: GCPManagedClusterSpec defines the desired state of GCPManagedCluster.
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
network:
description: NetworkSpec encapsulates all things related to the 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
enableFlowLogs:
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
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
purpose:
default: PRIVATE_RFC_1918
description: "Purpose: The purpose of the resource. If unspecified,
the purpose defaults to PRIVATE_RFC_1918. The enableFlowLogs
field isn't supported with the purpose field set to INTERNAL_HTTPS_LOAD_BALANCER.
\n Possible values: \"INTERNAL_HTTPS_LOAD_BALANCER\" -
Subnet reserved for Internal HTTP(S) Load Balancing. \"PRIVATE\"
- Regular user created or automatically created subnet.
\"PRIVATE_RFC_1918\" - Regular user created or automatically
created subnet. \"PRIVATE_SERVICE_CONNECT\" - Subnetworks
created for Private Service Connect in the producer network.
\"REGIONAL_MANAGED_PROXY\" - Subnetwork used for Regional
Internal/External HTTP(S) Load Balancing."
enum:
- INTERNAL_HTTPS_LOAD_BALANCER
- PRIVATE_RFC_1918
- PRIVATE
- PRIVATE_SERVICE_CONNECT
- REGIONAL_MANAGED_PROXY
type: string
region:
description: Region is the name of the region where the
Subnetwork resides.
type: string
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
status:
description: GCPManagedClusterStatus defines the observed state of GCPManagedCluster.
properties:
conditions:
description: Conditions specifies the conditions for the managed control
plane
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
failureDomains:
additionalProperties:
description: FailureDomainSpec is the Schema for Cluster API failure
domains. It allows controllers to understand how many failure
domains a cluster can optionally span across.
properties:
attributes:
additionalProperties:
type: string
description: Attributes is a free form map of attributes an
infrastructure provider might use or require.
type: object
controlPlane:
description: ControlPlane determines if this failure domain
is suitable for use by control plane machines.
type: boolean
type: object
description: FailureDomains is a slice of FailureDomains.
type: object
network:
description: Network encapsulates GCP networking resources.
properties:
apiServerBackendService:
description: APIServerBackendService is the full reference to
the backend service created for the API Server.
type: string
apiServerForwardingRule:
description: APIServerForwardingRule is the full reference to
the forwarding rule created for the API Server.
type: string
apiServerHealthCheck:
description: APIServerHealthCheck is the full reference to the
health check created for the API Server.
type: string
apiServerInstanceGroups:
additionalProperties:
type: string
description: APIServerInstanceGroups is a map from zone to the
full reference to the instance groups created for the control
plane nodes created in the same zone.
type: object
apiServerIpAddress:
description: APIServerAddress is the IPV4 global address assigned
to the load balancer created for the API Server.
type: string
apiServerTargetProxy:
description: APIServerTargetProxy is the full reference to the
target proxy created for the API Server.
type: string
firewallRules:
additionalProperties:
type: string
description: FirewallRules is a map from the name of the rule
to its full reference.
type: object
router:
description: Router is the full reference to the router created
within the network it'll contain the cloud nat gateway
type: string
selfLink:
description: SelfLink is the link to the Network used for this
cluster.
type: string
type: object
ready:
type: boolean
required:
- ready
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 71a343e

Please sign in to comment.