Skip to content

Commit

Permalink
Configure Gateway Deployment Resources (#2723)
Browse files Browse the repository at this point in the history
* Update comments on Deployment

* Move resources into managedGatewayClass

* Add resource configuration to GatewayClassConfig

* Regenerate CRDs

* Pass resource configuration into the gateway-resources-job

* Pull in resources from GatewayClassConfig

* Add flag for resources in `gateway-resources` subcommand

* Clean up some comments in existing code

* Add gateway-resources configmap

* Load configmap into gateway-resources job

* Load resources from json

* Update CRDs

* Read resources in from the configmap

* Add BATs for Gateway Resources Configmap

* Add Changelog

* Fix unquoted value in BATs

* Fix how resources.json is read

* Fix BATs errors for real

* Fix seg fault bug

* Fix reading of resources file

* Quote "$actual"

* Fix zsh/sh differences in BATs

* Update control-plane/api-gateway/common/helm_config.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* Move resources into DeploymentSpec

* Remove extra split in crds

---------

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
  • Loading branch information
Thomas Eckert and nathancoleman authored Aug 28, 2023
1 parent ae2b318 commit 085c812
Show file tree
Hide file tree
Showing 39 changed files with 413 additions and 102 deletions.
3 changes: 3 additions & 0 deletions .changelog/2723.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
helm: Add ability to configure resource requests and limits for Gateway API deployments.
```
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: consul.hashicorp.com/v1alpha1
kind: ConsulGatewayPolicy
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: consul.hashicorp.com/v1alpha1
kind: JWTProvider
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: consul.hashicorp.com/v1alpha1
kind: HTTPRouteAuthFilter
metadata:
Expand Down
9 changes: 6 additions & 3 deletions charts/consul/templates/crd-controlplanerequestlimits.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{{- if .Values.connectInject.enabled }}
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: controlplanerequestlimits.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: controlplanerequestlimits.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
9 changes: 6 additions & 3 deletions charts/consul/templates/crd-exportedservices.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{{- if .Values.connectInject.enabled }}
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: exportedservices.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: exportedservices.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
81 changes: 64 additions & 17 deletions charts/consul/templates/crd-gatewayclassconfigs.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{{- if .Values.connectInject.enabled }}
---
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: gatewayclassconfigs.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: gatewayclassconfigs.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down Expand Up @@ -78,14 +80,72 @@ spec:
maximum: 8
minimum: 1
type: integer
resources:
description: Resources defines the resource requirements for the
gateway.
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in
pod.spec.resourceClaims of the Pod where this field
is used. It makes that resource available inside a
container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
type: object
mapPrivilegedContainerPorts:
description: The value to add to privileged ports ( ports < 1024)
for gateway containers
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
description: 'NodeSelector is a selector which must be true for the
pod to fit on a node. Selector which must match a node''s labels
for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/'
type: object
openshiftSCCName:
description: The name of the OpenShift SecurityContextConstraints
resource for this gateway class to use.
type: string
podSecurityPolicy:
description: The name of an existing Kubernetes PodSecurityPolicy
to bind to the managed ServiceAccount if ACLs are managed.
Expand Down Expand Up @@ -138,19 +198,6 @@ spec:
type: string
type: object
type: array
openshiftSCCName:
description: The name of an existing SecurityContextConstraints
resource to bind to the managed role when running on OpenShift.
type: string
mapPrivilegedContainerPorts:
type: integer
format: int32
minimum: 0
maximum: 64512
description: mapPrivilegedContainerPorts is the value which Consul will add to privileged container port
values (ports < 1024) defined on a Gateway when the number is greater than 0. This cannot be more than
64512 as the highest privileged port is 1023, which would then map to 65535, which is the highest
valid port number.
type: object
type: object
served: true
Expand Down
5 changes: 3 additions & 2 deletions charts/consul/templates/crd-gatewayclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/1538
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: gatewayclasses.gateway.networking.k8s.io
spec:
group: gateway.networking.k8s.io
Expand Down
5 changes: 3 additions & 2 deletions charts/consul/templates/crd-gateways.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/1538
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: gateways.gateway.networking.k8s.io
spec:
group: gateway.networking.k8s.io
Expand Down
5 changes: 3 additions & 2 deletions charts/consul/templates/crd-grpcroutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/1538
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: grpcroutes.gateway.networking.k8s.io
spec:
group: gateway.networking.k8s.io
Expand Down
5 changes: 3 additions & 2 deletions charts/consul/templates/crd-httproutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/1538
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
gateway.networking.k8s.io/bundle-version: v0.6.2
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: httproutes.gateway.networking.k8s.io
spec:
group: gateway.networking.k8s.io
Expand Down
9 changes: 6 additions & 3 deletions charts/consul/templates/crd-ingressgateways.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{{- if .Values.connectInject.enabled }}
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: ingressgateways.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: ingressgateways.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
9 changes: 6 additions & 3 deletions charts/consul/templates/crd-jwtproviders.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{{- if .Values.connectInject.enabled }}
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: jwtproviders.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: jwtproviders.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
9 changes: 6 additions & 3 deletions charts/consul/templates/crd-meshes.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{{- if .Values.connectInject.enabled }}
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: meshes.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: meshes.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
10 changes: 6 additions & 4 deletions charts/consul/templates/crd-meshservices.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{{- if .Values.connectInject.enabled }}
---
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: meshservices.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: meshservices.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
9 changes: 6 additions & 3 deletions charts/consul/templates/crd-peeringacceptors.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{{- if and .Values.connectInject.enabled .Values.global.peering.enabled }}
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: peeringacceptors.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: crd
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: peeringacceptors.consul.hashicorp.com
spec:
group: consul.hashicorp.com
names:
Expand Down
Loading

0 comments on commit 085c812

Please sign in to comment.