Skip to content

Commit

Permalink
Merge branch 'main' into test/mock_test_for_reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey authored Sep 5, 2024
2 parents 30f3c73 + a3d0a24 commit 51fdeed
Show file tree
Hide file tree
Showing 20 changed files with 885 additions and 8 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
- Added command line flags to configure the certificate generator job's images.
[#516](https://github.com/Kong/gateway-operator/pull/516)
- Add `KongPluginBinding` reconciler for Konnect Plugins.
[#513](https://github.com/Kong/gateway-operator/pull/513)
[#535](https://github.com/Kong/gateway-operator/pull/535)
[#513](https://github.com/Kong/gateway-operator/pull/513), [#535](https://github.com/Kong/gateway-operator/pull/535)
- The `DataPlaneKonnectExtension` CRD has been introduced. Such a CRD can be attached
to a `DataPlane` via the extensions field to have a konnect-flavored `DataPlane`.
[#453](https://github.com/Kong/gateway-operator/pull/453)

### Fixed

Expand Down
98 changes: 98 additions & 0 deletions api/v1alpha1/dataplane_konnect_extension_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package v1alpha1

/*
Copyright 2024 Kong Inc.
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.
*/

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

configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1"
)

func init() {
SchemeBuilder.Register(&DataPlaneKonnectExtension{}, &DataPlaneKonnectExtensionList{})
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=kong;all
// +kubebuilder:subresource:status

// DataPlaneKonnectExtension is the Schema for the dataplanekonnectextension API,
// and is intended to be referenced as extension by the dataplane API.
// If a DataPlane successfully refers a DataPlaneKonnectExtension, the DataPlane
// deployment spec gets customized to include the konnect-related configuration.
type DataPlaneKonnectExtension struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec is the specification of the DataPlaneKonnectExtension resource.
Spec DataPlaneKonnectExtensionSpec `json:"spec,omitempty"`
// Status is the status of the DataPlaneKonnectExtension resource.
Status DataPlaneKonnectExtensionStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

// DataPlaneKonnectExtensionSpec defines the desired state of DataPlaneKonnectExtension.
type DataPlaneKonnectExtensionSpec struct {
// ControlPlaneRef is a reference to a ControlPlane this DataPlaneKonnectExtension is associated with.
// +kubebuilder:validation:Required
ControlPlaneRef configurationv1alpha1.ControlPlaneRef `json:"controlPlaneRef"`

// ControlPlaneRegion is the region of the Konnect Control Plane.
//
// +kubebuilder:example:=us
// +kubebuilder:validation:Required
ControlPlaneRegion string `json:"controlPlaneRegion"`

// ServerHostname is the fully qualified domain name of the konnect server. This
// matches the RFC 1123 definition of a hostname with 1 notable exception that
// numeric IP addresses are not allowed.
//
// Note that as per RFC1035 and RFC1123, a *label* must consist of lower case
// alphanumeric characters or '-', and must start and end with an alphanumeric
// character. No other punctuation is allowed.
//
// +kubebuilder:example:=foo.example.com
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
ServerHostname string `json:"serverHostname"`

// ClusterCertificateSecretName is a name of the Secret containing the Konnect Control Plane's cluster certificate.
// +kubebuilder:validation:Required
ClusterCertificateSecretName string `json:"clusterCertificateSecretName"`

// ClusterDataPlaneLabels is a set of labels that will be applied to the Konnect DataPlane.
// +optional
ClusterDataPlaneLabels map[string]string `json:"clusterDataPlaneLabels,omitempty"`
}

// DataPlaneKonnectExtensionStatus defines the observed state of DataPlaneKonnectExtension.
type DataPlaneKonnectExtensionStatus struct {
// DataPlaneRefs is the array of DataPlane references this is associated with.
// A new reference is set by the operator when this extension is associated with
// a DataPlane through its extensions spec.
//
// +kube:validation:Optional
DataPlaneRefs []NamespacedRef `json:"dataPlaneRefs,omitempty"`
}
2 changes: 2 additions & 0 deletions api/v1alpha1/extensionref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package v1alpha1
// defines extended behavior for a resource (e.g. ControlPlane).
type ExtensionRef struct {
// Group is the group of the extension resource.
// +kubebuilder:validation:Optional
// +kubebuilder:default=gateway-operator.konghq.com
Group string `json:"group"`

// Kind is kind of the extension resource.
Expand Down
104 changes: 104 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

12 changes: 12 additions & 0 deletions api/v1beta1/dataplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
policyv1 "k8s.io/api/policy/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/kong/gateway-operator/api/v1alpha1"
)

func init() {
Expand All @@ -32,6 +34,7 @@ func init() {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=kodp,categories=kong;all
// +kubebuilder:validation:XValidation:message="Extension not allowed for DataPlane",rule="has(self.spec.extensions) ? self.spec.extensions.all(e, e.group == 'gateway-operator.konghq.com' && e.kind == 'DataPlaneKonnectExtension') : true"
// +kubebuilder:printcolumn:name="Ready",description="The Resource is ready",type=string,JSONPath=`.status.conditions[?(@.type=='Ready')].status`

// DataPlane is the Schema for the dataplanes API
Expand Down Expand Up @@ -68,6 +71,15 @@ type DataPlaneOptions struct {

// +optional
Resources DataPlaneResources `json:"resources"`

// Extensions provide additional or replacement features for the DataPlane
// resources to influence or enhance functionality.
// NOTE: since we have one extension only (DataPlaneKonnectExtension), we limit the amount of extensions to 1.
//
// +optional
// +kubebuilder:validation:MinItems=0
// +kubebuilder:validation:MaxItems=1
Extensions []v1alpha1.ExtensionRef `json:"extensions,omitempty"`
}

// DataPlaneResources defines the resources that will be created and managed
Expand Down
20 changes: 16 additions & 4 deletions api/v1beta1/gatewayconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ package v1beta1

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

"github.com/kong/gateway-operator/api/v1alpha1"
)

func init() {
SchemeBuilder.Register(&GatewayConfiguration{}, &GatewayConfigurationList{})
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=kogc,categories=kong;all
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=kogc,categories=kong;all
// +kubebuilder:validation:XValidation:message="Extension not allowed for DataPlane config options",rule="has(self.spec.dataPlaneOptions.extensions) ? self.spec.dataPlaneOptions.extensions.all(e, e.group == 'gateway-operator.konghq.com' && e.kind == 'DataPlaneKonnectExtension') : true"

// GatewayConfiguration is the Schema for the gatewayconfigurations API
type GatewayConfiguration struct {
Expand Down Expand Up @@ -61,6 +64,15 @@ type GatewayConfigDataPlaneOptions struct {

// +optional
Network GatewayConfigDataPlaneNetworkOptions `json:"network"`

// Extensions provide additional or replacement features for the DataPlane
// resources to influence or enhance functionality.
// NOTE: since we have one extension only (DataPlaneKonnectExtension), we limit the amount of extensions to 1.
//
// +optional
// +kubebuilder:validation:MinItems=0
// +kubebuilder:validation:MaxItems=1
Extensions []v1alpha1.ExtensionRef `json:"extensions,omitempty"`
}

// GatewayConfigDataPlaneNetworkOptions defines network related options for a DataPlane.
Expand Down
14 changes: 14 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
Expand Up @@ -8094,6 +8094,7 @@ spec:
defines extended behavior for a resource (e.g. ControlPlane).
properties:
group:
default: gateway-operator.konghq.com
description: Group is the group of the extension resource.
type: string
kind:
Expand All @@ -8114,7 +8115,6 @@ spec:
This field MUST not be set when referring to cluster-scoped resources.
type: string
required:
- group
- kind
- name
type: object
Expand Down
Loading

0 comments on commit 51fdeed

Please sign in to comment.