Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
testbin/
15 changes: 9 additions & 6 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Developer documentation

Envoy Gateway is built using a [make](https://www.gnu.org/software/make/)-based
build system. Our CI is based on [Github Actions](https://docs.github.com/en/actions) (see: [workflows](.github/workflows))
Envoy Gateway is built using a [make][make]-based build system. Our CI is based on [Github Actions][gha]
(see: [workflows](.github/workflows)).

## Prerequisites

Expand All @@ -24,16 +24,19 @@ build system. Our CI is based on [Github Actions](https://docs.github.com/en/act

### yamllint
* Recommended Version: 1.24.2
* Installation Guide: https://github.com/adrienverge/yamllint#installation
* Installation Guide: https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint

### codespell
* Recommended Version: 2.1.0
* Installation Guide: https://github.com/codespell-project/codespell#installation

* If you do not have these tools installed on your machine,
you can alternatively run `MAKE_IN_DOCKER=1 make <target>` to run `make` inside a Docker container which has all the
preinstalled tools needed to support all the `make` targets.
__Note:__ If you do not have these tools installed on your machine, you can alternatively run
`MAKE_IN_DOCKER=1 make <target>` to run `make` inside a Docker container which has all the preinstalled tools needed to
support all the `make` targets.

## Quick start

Run `make help` to see all the available targets to build, test and run `envoy-gateway`.

[make]: https://www.gnu.org/software/make/
[gha]: https://docs.github.com/en/actions
103 changes: 96 additions & 7 deletions Makefile.targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,42 @@ IMAGE ?= ${REGISTRY}/gateway-dev
REV=$(shell git rev-parse --short HEAD)
# Tag is the tag to use for build and push image targets.
TAG ?= $(REV)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the tools should follow the convention highlighted here https://github.com/envoyproxy/gateway/blob/main/tools/docker/Dockerfile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we expect the user to either have the tools installed locally or run the make target inside a container

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Based on this vote, the community has decided to focus on using the "local dev" approach and no longer support the MAKE_IN_DOCKER approach. @LukeShu is assigned #124 and will have a PR submitted to transition the current Docker-based linters. With that said, IMHO the targets added by this PR should be acceptable.

ENVTEST_K8S_VERSION = 1.23

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

##@ General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Display this help
@echo Envoy Gateway is an open source project for managing Envoy Proxy as a standalone or Kubernetes-based application gateway
@echo
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Build

.PHONY: build
build: ## Build the envoy-gateway binary
Expand All @@ -36,13 +72,6 @@ docker-build: build-all ## Build the envoy-gateway docker image.
docker-push: ## Push the docker image for envoy-gateway.
@docker push $(IMAGE):$(TAG)

.PHONY: help
help: ## Display this help
@echo Envoy Gateway is an open source project for managing Envoy Proxy as a standalone or Kubernetes-based application gateway
@echo
@echo Targets:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9._-]+:.*?## / {printf " %-25s %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

.PHONY: lint
lint: ## Run lint checks
lint: lint-golint lint-yamllint lint-codespell
Expand All @@ -62,3 +91,63 @@ lint-yamllint:
lint-codespell: CODESPELL_SKIP := $(shell cat tools/codespell/.codespell.skip | tr \\n ',')
lint-codespell:
@codespell --skip $(CODESPELL_SKIP) --ignore-words tools/codespell/.codespell.ignorewords --check-filenames --check-hidden -q2

##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=envoy-gateway-role crd webhook paths="./..." output:crd:artifacts:config=pkg/provider/kubernetes/config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object paths="./..."

.PHONY: kube-test
kube-test: manifests generate lint envtest ## Run Kubernetes provider tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

##@ Deployment

ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: kube-install
kube-install: manifests kustomize ## Install CRDs into the Kubernetes cluster specified in ~/.kube/config.
$(KUSTOMIZE) build pkg/provider/kubernetes/config/crd | kubectl apply -f -

.PHONY: kube-uninstall
kube-uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build pkg/provider/kubernetes/config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.8.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
16 changes: 16 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
domain: gateway.envoyproxy.io
layout:
- go.kubebuilder.io/v3
projectName: kube
repo: github.com/envoyproxy/gateway
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: gateway.envoyproxy.io
group: config
kind: EnvoyProxy
path: github.com/envoyproxy/gateway/api/v1alpha1
version: v1alpha1
version: "3"
88 changes: 88 additions & 0 deletions api/config/v1alpha1/envoygateway_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package v1alpha1

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

//+kubebuilder:object:root=true

// EnvoyGateway is the Schema for the envoygateways API.
type EnvoyGateway struct {
metav1.TypeMeta `json:",inline"`

// EnvoyGatewaySpec defines the desired state of Envoy Gateway.
EnvoyGatewaySpec `json:",inline"`
}

// EnvoyGatewaySpec defines the desired state of Envoy Gateway.
type EnvoyGatewaySpec struct {
// Gateway defines desired Gateway API specific configuration. If unset,
// default configuration parameters will apply.
//
// +optional
Gateway *Gateway `json:"gateway,omitempty"`

// Provider defines the desired provider and provider-specific configuration.
// If unspecified, the Kubernetes provider is used with default configuration
// parameters.
//
// +optional
Provider *Provider `json:"provider,omitempty"`
}

// Gateway defines the desired Gateway API configuration of Envoy Gateway.
type Gateway struct {
// ControllerName defines the name of the Gateway API controller. If unspecified,
// defaults to "gateway.envoyproxy.io/gatewayclass-controller". See the following
// for additional details:
//
// https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.GatewayClass
//
// +optional
ControllerName string `json:"controllerName,omitempty"`
}

// Provider defines the desired configuration of a provider.
// +union
type Provider struct {
// Type is the type of provider to use.
//
// +unionDiscriminator
Type ProviderType `json:"type"`
// Kubernetes defines the configuration of the Kubernetes provider. Kubernetes
// provides runtime configuration via the Kubernetes API.
//
// +optional
Kubernetes *KubernetesProvider `json:"kubernetes,omitempty"`

// File defines the configuration of the File provider. File provides runtime
// configuration defined by one or more files.
//
// +optional
File *FileProvider `json:"file,omitempty"`
}

// ProviderType defines the types of providers supported by Envoy Gateway.
type ProviderType string

const (
// ProviderTypeKubernetes defines the "Kubernetes" provider.
ProviderTypeKubernetes ProviderType = "Kubernetes"

// ProviderTypeFile defines the "File" provider.
ProviderTypeFile ProviderType = "File"
)

// KubernetesProvider defines configuration for the Kubernetes provider.
type KubernetesProvider struct {
// TODO: Add config as use cases are better understood.
}

// FileProvider defines configuration for the File provider.
type FileProvider struct {
// TODO: Add config as use cases are better understood.
}

func init() {
SchemeBuilder.Register(&EnvoyGateway{})
}
42 changes: 42 additions & 0 deletions api/config/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package v1alpha1

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

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

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

Spec EnvoyProxySpec `json:"spec,omitempty"`
Status EnvoyProxyStatus `json:"status,omitempty"`
}

// EnvoyProxySpec defines the desired state of EnvoyProxy.
type EnvoyProxySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - define desired state of cluster.
// Important: Run "make" to regenerate code after modifying this file.
}

// EnvoyProxyStatus defines the observed state of EnvoyProxy
type EnvoyProxyStatus struct {
// INSERT ADDITIONAL STATUS FIELDS - define observed state of cluster.
// Important: Run "make" to regenerate code after modifying this file.
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&EnvoyProxy{}, &EnvoyProxyList{})
}
21 changes: 21 additions & 0 deletions api/config/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Package v1alpha1 contains API Schema definitions for the config v1alpha1 API group.
//
//+kubebuilder:object:generate=true
//+groupName=config.gateway.envoyproxy.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "config.gateway.envoyproxy.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
Loading