Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gateway API and Envoy Gateway install to Calico Enterprise #3638

Merged
merged 42 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
829789c
Add Gateway API and Envoy Gateway install to Calico Enterprise
nelljerram Oct 11, 2024
316d6ab
WIP
nelljerram Dec 6, 2024
dc6e756
Revert removal of non-CRD resources from pkg/render/gateway_api_crds.…
nelljerram Dec 6, 2024
7d81fe9
Use calico-system namespace for Gateway API
nelljerram Dec 6, 2024
fc3412b
Rework to use YAML instead of equivalent Golang coding
nelljerram Dec 9, 2024
d69c0e3
Merge remote-tracking branch 'origin/master' into gateway-api-cr
nelljerram Dec 9, 2024
363e958
Add GatewayControllerDeployment to override fields test
nelljerram Dec 9, 2024
81b3699
Merge remote-tracking branch 'origin/master' into gateway-api-cr
nelljerram Dec 10, 2024
1e7064f
Don't start GatewayAPI controller if not on an Enterprise system
nelljerram Dec 10, 2024
3d34cc8
Fix gen-versions
nelljerram Dec 10, 2024
21dcadf
Make GatewayAPI a non-namespaced resource
nelljerram Dec 10, 2024
ae05d26
Add overrides for the certgen job
nelljerram Dec 10, 2024
a39973c
Rendering UT (and fix!)
nelljerram Dec 10, 2024
c05bf21
Use separate namespace for Gateway API deployments
nelljerram Dec 11, 2024
ee44615
WIP - configure EnvoyProxy
nelljerram Dec 11, 2024
40d5419
Import Envoy API, so we can provision EnvoyProxy and EnvoyGateway res…
nelljerram Dec 11, 2024
54df43b
Provision EnvoyProxy
nelljerram Dec 11, 2024
9a261c0
Add pull secrets to EnvoyGateway provisioning
nelljerram Dec 11, 2024
4d2fdbd
Allow full EnvoyProxy customization according to standard pattern
nelljerram Dec 11, 2024
ddccdd6
Complete UT
nelljerram Dec 12, 2024
9138936
Regenerate GatewayAPI CRD
nelljerram Dec 12, 2024
4208242
Merge remote-tracking branch 'origin/master' into gateway-api-cr
nelljerram Dec 12, 2024
f88bd94
Regenerate GatewayAPI CRD
nelljerram Dec 12, 2024
bfa79c9
Fix static-checks
nelljerram Dec 12, 2024
0700e47
Rename namespace "tigera-gateway-system" to "tigera-gateway"
nelljerram Dec 16, 2024
05d7db3
Remove unused ResourceName constant
nelljerram Dec 16, 2024
051adb7
Controller: get the GatewayAPI CR first of all
nelljerram Dec 16, 2024
6d8a813
Call r.status.SetMetaData as soon as the GatewayAPI CR is found
nelljerram Dec 16, 2024
ecb2315
Create CRDs if they don't already exist, but never update existing ones
nelljerram Dec 16, 2024
7d1a48e
Merge remote-tracking branch 'origin/master' into gateway-api-cr
nelljerram Dec 16, 2024
1b81681
Regen
nelljerram Dec 16, 2024
16b4532
Placate `make vet`
nelljerram Dec 16, 2024
f4b6cf4
componentHandler methods need a pointer receiver now
nelljerram Dec 16, 2024
aebcae8
Use normal templating for gateway API images
nelljerram Dec 16, 2024
a78f246
Object rendering improvements, from review comments
nelljerram Dec 16, 2024
749efcc
Align API commenting with godoc convention
nelljerram Dec 16, 2024
662b629
Regen
nelljerram Dec 16, 2024
fe82261
Only deep copy the objects that need it, i.e. those read from YAML
nelljerram Dec 16, 2024
06dac6c
Provision GatewayClass
nelljerram Dec 16, 2024
5ed00a1
Add Envoy and Gateway APIs to scheme
nelljerram Dec 16, 2024
0d03e32
Clear degraded status when everything is good
nelljerram Dec 16, 2024
fe6a1b6
Specify docker.io as default registry for envoy image
nelljerram Dec 17, 2024
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
31 changes: 28 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,33 @@ else
GIT_VERSION?=$(shell git describe --tags --dirty --always --abbrev=12)
endif

ENVOY_GATEWAY_HELM_CHART ?= oci://docker.io/envoyproxy/gateway-helm
ENVOY_GATEWAY_VERSION ?= v1.1.2
ENVOY_GATEWAY_PREFIX ?= tigera-gateway-api
ENVOY_GATEWAY_NAMESPACE ?= tigera-gateway-system
ENVOY_GATEWAY_RESOURCES = pkg/render/gateway_api_resources.yaml

$(ENVOY_GATEWAY_RESOURCES): hack/bin/helm-$(BUILDARCH)
echo "---" > $@
echo "apiVersion: v1" >> $@
echo "kind: Namespace" >> $@
echo "metadata:" >> $@
echo " name: $(ENVOY_GATEWAY_NAMESPACE)" >> $@
hack/bin/helm-$(BUILDARCH) template $(ENVOY_GATEWAY_PREFIX) $(ENVOY_GATEWAY_HELM_CHART) \
--version $(ENVOY_GATEWAY_VERSION) \
-n $(ENVOY_GATEWAY_NAMESPACE) \
--include-crds \
>> $@

hack/bin/helm-$(BUILDARCH):
mkdir -p hack/bin
curl -sSf -L --retry 5 -o hack/bin/helm3.tar.gz https://get.helm.sh/helm-v3.11.3-linux-$(BUILDARCH).tar.gz
tar -zxvf hack/bin/helm3.tar.gz -C hack/bin linux-$(BUILDARCH)/helm
mv hack/bin/linux-$(BUILDARCH)/helm hack/bin/helm-$(BUILDARCH)
rmdir hack/bin/linux-$(BUILDARCH)

build: $(BINDIR)/operator-$(ARCH)
$(BINDIR)/operator-$(ARCH): $(SRC_FILES)
$(BINDIR)/operator-$(ARCH): $(SRC_FILES) $(ENVOY_GATEWAY_RESOURCES)
mkdir -p $(BINDIR)
$(CONTAINERIZED) -e CGO_ENABLED=$(CGO_ENABLED) -e GOEXPERIMENT=$(GOEXPERIMENT) $(CALICO_BUILD) \
sh -c '$(GIT_CONFIG_SSH) \
Expand Down Expand Up @@ -284,14 +309,14 @@ GINKGO_ARGS?= -v -trace -r
GINKGO_FOCUS?=.*

.PHONY: ut
ut:
ut: $(ENVOY_GATEWAY_RESOURCES)
-mkdir -p .go-pkg-cache report
$(CONTAINERIZED) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
ginkgo -focus="$(GINKGO_FOCUS)" $(GINKGO_ARGS) "$(UT_DIR)"'

## Run the functional tests
fv: cluster-create load-container-images run-fvs cluster-destroy
run-fvs:
run-fvs: $(ENVOY_GATEWAY_RESOURCES)
-mkdir -p .go-pkg-cache report
$(CONTAINERIZED) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
ginkgo -focus="$(GINKGO_FOCUS)" $(GINKGO_ARGS) "$(FV_DIR)"'
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,12 @@ resources:
kind: TLSPassthroughRoute
path: github.com/tigera/operator/api/v1
version: v1
- api:
crdVersion: v1
controller: true
domain: tigera.io
group: operator.tigera.io
kind: GatewayAPI
path: github.com/tigera/operator/api/v1
version: v1
version: "3"
296 changes: 296 additions & 0 deletions api/v1/gatewayapi_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
// Copyright (c) 2024 Tigera, Inc. All rights reserved.
/*

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 v1

import (
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// GatewayAPISpec has fields that can be used to customize our GatewayAPI support.
type GatewayAPISpec struct {
// Allow optional customization of the gateway controller deployment.
GatewayControllerDeployment *GatewayControllerDeployment `json:"gatewayControllerDeployment,omitempty"`

// Allow optional customization of the gateway certgen job.
GatewayCertgenJob *GatewayCertgenJob `json:"gatewayCertgenJob,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we generally write out api field names. I am assuming Certgen stands for Certificate Generation, meaning it is two words and both words should be capitalized in the field name as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the Envoy resources here, which have "certgen" as a single word.


// Allow optional customization of gateway deployments.
GatewayDeployment *GatewayDeployment `json:"gatewayDeployment,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:scope=Cluster

type GatewayAPI struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

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

//+kubebuilder:object:root=true

type GatewayAPIList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GatewayAPI `json:"items"`
}

func init() {
SchemeBuilder.Register(&GatewayAPI{}, &GatewayAPIList{})
}

// Optional customization of the gateway controller deployment.
rene-dekker marked this conversation as resolved.
Show resolved Hide resolved
//
// If GatewayControllerDeployment.Metadata is non-nil, non-clashing labels and annotations from that
// metadata are added into the deployment's top-level metadata.
//
// For customization of the deployment spec see GatewayControllerDeploymentSpec.
type GatewayControllerDeployment struct {
// +optional
Metadata *Metadata `json:"metadata,omitempty"`

// +optional
Spec *GatewayControllerDeploymentSpec `json:"spec,omitempty"`
}

// Optional customization of the gateway controller deployment.
//
// If GatewayControllerDeployment.Spec.MinReadySeconds is non-nil, it sets the minReadySeconds field
// for the deployment.
//
// For customization of the pod template see GatewayControllerDeploymentPodTemplate.
type GatewayControllerDeploymentSpec struct {
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=2147483647
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`

// +optional
Template *GatewayControllerDeploymentPodTemplate `json:"template,omitempty"`
}

// Optional customization of the gateway controller deployment.
//
// If GatewayControllerDeployment.Spec.Template.Metadata is non-nil, non-clashing labels and
// annotations from that metadata are added into the deployment's pod template.
//
// For customization of the pod template spec see GatewayControllerDeploymentPodSpec.
type GatewayControllerDeploymentPodTemplate struct {
// +optional
Metadata *Metadata `json:"metadata,omitempty"`

// +optional
Spec *GatewayControllerDeploymentPodSpec `json:"spec,omitempty"`
}

// Optional customization of the gateway controller deployment.
//
// If GatewayControllerDeployment.Spec.Template.Spec.Affinity is non-nil, it sets the affinity field
// of the deployment's pod template.
//
// If GatewayControllerDeployment.Spec.Template.Spec.Containers["envoy-gateway"].Resources is
// non-nil, it overrides the ResourceRequirements of the controller's "envoy-gateway" container.
//
// If GatewayControllerDeployment.Spec.Template.Spec.NodeSelector is non-nil, it sets a node
// selector for where controller pods may be scheduled.
//
// If GatewayControllerDeployment.Spec.Template.Spec.Tolerations is non-nil, it sets the tolerations
// field of the deployment's pod template.
type GatewayControllerDeploymentPodSpec struct {
// +optional
Affinity *v1.Affinity `json:"affinity"`

// +optional
Containers []GatewayControllerDeploymentContainer `json:"containers,omitempty"`

// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +optional
Tolerations []v1.Toleration `json:"tolerations"`
}

// See GatewayControllerDeploymentPodSpec for how this struct can be used.
type GatewayControllerDeploymentContainer struct {
// +kubebuilder:validation:Enum=envoy-gateway
Name string `json:"name"`

// +optional
Resources *v1.ResourceRequirements `json:"resources,omitempty"`
}

// Optional customization of the gateway certgen job.
//
// If GatewayCertgenJob.Metadata is non-nil, non-clashing labels and annotations from that metadata
// are added into the job's top-level metadata.
//
// For customization of the job spec see GatewayCertgenJobSpec.
type GatewayCertgenJob struct {
// +optional
Metadata *Metadata `json:"metadata,omitempty"`

// +optional
Spec *GatewayCertgenJobSpec `json:"spec,omitempty"`
}

// Optional customization of the gateway certgen job.
//
// For customization of the job template see GatewayCertgenJobPodTemplate.
type GatewayCertgenJobSpec struct {
// +optional
Template *GatewayCertgenJobPodTemplate `json:"template,omitempty"`
}

// Optional customization of the gateway certgen job.
//
// If GatewayCertgenJob.Spec.Template.Metadata is non-nil, non-clashing labels and
// annotations from that metadata are added into the job's pod template.
//
// For customization of the pod template spec see GatewayCertgenJobPodSpec.
type GatewayCertgenJobPodTemplate struct {
// +optional
Metadata *Metadata `json:"metadata,omitempty"`

// +optional
Spec *GatewayCertgenJobPodSpec `json:"spec,omitempty"`
}

// Optional customization of the gateway certgen job.
//
// If GatewayCertgenJob.Spec.Template.Spec.Affinity is non-nil, it sets the affinity field of the
// job's pod template.
//
// If GatewayCertgenJob.Spec.Template.Spec.Containers["envoy-gateway-certgen"].Resources is non-nil,
// it overrides the ResourceRequirements of the job's "envoy-gateway-certgen" container.
//
// If GatewayCertgenJob.Spec.Template.Spec.NodeSelector is non-nil, it sets a node selector for
// where job pods may be scheduled.
//
// If GatewayCertgenJob.Spec.Template.Spec.Tolerations is non-nil, it sets the tolerations field of
// the job's pod template.
type GatewayCertgenJobPodSpec struct {
// +optional
Affinity *v1.Affinity `json:"affinity"`

// +optional
Containers []GatewayCertgenJobContainer `json:"containers,omitempty"`

// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +optional
Tolerations []v1.Toleration `json:"tolerations"`
}

// See GatewayCertgenJobPodSpec for how this struct can be used.
type GatewayCertgenJobContainer struct {
// +kubebuilder:validation:Enum=envoy-gateway-certgen
Name string `json:"name"`

// +optional
Resources *v1.ResourceRequirements `json:"resources,omitempty"`
}

// Optional customization of gateway deployments.
//
// For customization of the deployment spec see GatewayDeploymentSpec.
type GatewayDeployment struct {
// +optional
Spec *GatewayDeploymentSpec `json:"spec,omitempty"`
}

// Optional customization of gateway deployments.
//
// For customization of the pod template see GatewayDeploymentPodTemplate.
type GatewayDeploymentSpec struct {
// +optional
Template *GatewayDeploymentPodTemplate `json:"template,omitempty"`

// The deployment strategy to use to replace existing pods with new ones.
// +optional
// +patchStrategy=retainKeys
Strategy *GatewayDeploymentStrategy `json:"strategy,omitempty" patchStrategy:"retainKeys" protobuf:"bytes,4,opt,name=strategy"`
}

// Optional customization of gateway deployments.
//
// If GatewayDeployment.Spec.Template.Metadata is non-nil, non-clashing labels and annotations from
// that metadata are added into the deployment's pod template.
//
// For customization of the pod template spec see GatewayDeploymentPodSpec.
type GatewayDeploymentPodTemplate struct {
// +optional
Metadata *Metadata `json:"metadata,omitempty"`

// +optional
Spec *GatewayDeploymentPodSpec `json:"spec,omitempty"`
}

// Optional customization of gateway deployments.
//
// If GatewayDeployment.Spec.Template.Spec.Affinity is non-nil, it sets the affinity field of the
// deployment's pod template.
//
// If GatewayDeployment.Spec.Template.Spec.Containers["envoy"].Resources is non-nil, it
// overrides the ResourceRequirements of the "envoy" container.
//
// If GatewayDeployment.Spec.Template.Spec.NodeSelector is non-nil, it sets a node selector for
// where gateway pods may be scheduled.
//
// If GatewayDeployment.Spec.Template.Spec.Tolerations is non-nil, it sets the tolerations field of
// the deployment's pod template.
type GatewayDeploymentPodSpec struct {
// +optional
Affinity *v1.Affinity `json:"affinity"`

// +optional
Containers []GatewayDeploymentContainer `json:"containers,omitempty"`

// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// TopologySpreadConstraints describes how a group of pods ought to spread across topology
// domains. Scheduler will schedule pods in a way which abides by the constraints.
// All topologySpreadConstraints are ANDed.
// +optional
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`

// +optional
Tolerations []v1.Toleration `json:"tolerations"`
}

// See GatewayDeploymentPodSpec for how this struct can be used.
type GatewayDeploymentContainer struct {
// +kubebuilder:validation:Enum=envoy
Name string `json:"name"`

// +optional
Resources *v1.ResourceRequirements `json:"resources,omitempty"`
}

// GatewayDeploymentStrategy describes how to replace existing pods with new ones. Only RollingUpdate is supported
// at this time so the Type field is not exposed.
type GatewayDeploymentStrategy struct {
// Rolling update config params. Present only if DeploymentStrategyType =
// RollingUpdate.
// to be.
// +optional
RollingUpdate *appsv1.RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
}
Loading
Loading