Skip to content

Commit

Permalink
Release v1.1.3 cherry-pick (#4578)
Browse files Browse the repository at this point in the history
* build(deps): bump github.com/docker/docker from 27.2.0+incompatible to 27.3.1+incompatible (#4303)

build(deps): bump github.com/docker/docker

Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.2.0+incompatible to 27.3.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](moby/moby@v27.2.0...v27.3.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Huabing Zhao <[email protected]>
(cherry picked from commit cd4e9b1)
Signed-off-by: Guy Daich <[email protected]>

* bugfix: EG loglevel error for admin and metrics module (#4340)

* bugfix: EG loglevel error for admin and metrics module

Signed-off-by: qicz <[email protected]>

* fix ut

Signed-off-by: qicz <[email protected]>

* polish

Signed-off-by: qicz <[email protected]>

---------

Signed-off-by: qicz <[email protected]>
(cherry picked from commit 9b161ee)
Signed-off-by: Guy Daich <[email protected]>

* fix: some status updates are discarded by the status updater (#4337)

Signed-off-by: Huabing Zhao <[email protected]>
(cherry picked from commit 14830c7)
Signed-off-by: Guy Daich <[email protected]>

* fix: Unsupported listener protocol type error for nil supportKinds assign gateway status. (#4345)

(cherry picked from commit 7babca9)
Signed-off-by: Guy Daich <[email protected]>

* set invalid Listener.SupportedKinds to empty list (#4352)

* set invalid Listener.SupportedKinds to empty list

Fixes: #4216

Relates to https://kubernetes.slack.com/archives/CR0H13KGA/p1727457195236889

Signed-off-by: Arko Dasgupta <[email protected]>

* lint

Signed-off-by: Arko Dasgupta <[email protected]>

---------

Signed-off-by: Arko Dasgupta <[email protected]>
(cherry picked from commit 2fdf069)
Signed-off-by: Guy Daich <[email protected]>

* bugfix: ignore some unnecessary requests to apiserver. (#4362)

Signed-off-by: qicz <[email protected]>
Co-authored-by: zirain <[email protected]>
(cherry picked from commit fe1e8bd)
Signed-off-by: Guy Daich <[email protected]>

* fix: rateLimitDeployment ignoring pod labels and annotation merge (#4228)

* fix labels and annotation merges for rate limit deployment

Signed-off-by: Oscar Boher <[email protected]>

* fix tests and label merge

Signed-off-by: Oscar Boher <[email protected]>

* fix annotation merge if prometheus was disabled and annotations were defined

Signed-off-by: Oscar Boher <[email protected]>

* renamed labels and annotations to specify they apply to pods only

Signed-off-by: Oscar Boher <[email protected]>

* linter

Signed-off-by: Oscar Boher <[email protected]>

* fix resource provider tests to new annotation behavior

Signed-off-by: Oscar Boher <[email protected]>

* go linter

Signed-off-by: Oscar Boher <[email protected]>

* fix gen-check

Signed-off-by: Oscar Boher <[email protected]>

* pod labels selector comment

Signed-off-by: Oscar Boher <[email protected]>

---------

Signed-off-by: Oscar Boher <[email protected]>
Co-authored-by: zirain <[email protected]>
Co-authored-by: Arko Dasgupta <[email protected]>
(cherry picked from commit cf84927)
Signed-off-by: Guy Daich <[email protected]>

* fix dashboard typos (#4422)

Signed-off-by: haorenfsa <[email protected]>
Signed-off-by: Guy Daich <[email protected]>

* fix: ratelimit not working with both headers and cidr matches  (#4377)

* fix ratelimit descriptors do not respect both headers and cidr match for one rule

Signed-off-by: shawnh2 <[email protected]>

* fix gen-check and lint

Signed-off-by: shawnh2 <[email protected]>

* fix ratelimit e2e test

Signed-off-by: shawnh2 <[email protected]>

* add more comment and update test case

Signed-off-by: shawnh2 <[email protected]>

---------

Signed-off-by: shawnh2 <[email protected]>
Co-authored-by: Huabing Zhao <[email protected]>
(cherry picked from commit 66c0b51)
Signed-off-by: Guy Daich <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Guy Daich <[email protected]>
Signed-off-by: qicz <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Arko Dasgupta <[email protected]>
Signed-off-by: Oscar Boher <[email protected]>
Signed-off-by: haorenfsa <[email protected]>
Signed-off-by: shawnh2 <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Huabing Zhao <[email protected]>
Co-authored-by: qi <[email protected]>
Co-authored-by: Arko Dasgupta <[email protected]>
Co-authored-by: zirain <[email protected]>
Co-authored-by: Oscar Boher <[email protected]>
Co-authored-by: shaoyue <[email protected]>
Co-authored-by: sh2 <[email protected]>
  • Loading branch information
9 people authored Oct 31, 2024
1 parent f0f2275 commit 13fee13
Show file tree
Hide file tree
Showing 38 changed files with 1,176 additions and 104 deletions.
4 changes: 2 additions & 2 deletions charts/gateway-addons-helm/dashboards/envoy-clusters.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
"uid": "$datasource"
},
"editorMode": "builder",
"expr": "SUM(envoy_server_memory_allocated{})",
"expr": "sum(envoy_server_memory_allocated{})",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "",
Expand Down Expand Up @@ -339,7 +339,7 @@
"uid": "$datasource"
},
"editorMode": "code",
"expr": "SUM(envoy_server_memory_heap_size)",
"expr": "sum(envoy_server_memory_heap_size)",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@
"uid": "${datasource}"
},
"editorMode": "builder",
"expr": "sum by(namespace) (rate(envoy_cluster_upstream_cx_rx_bytes_total{namespace=~\"$Namespace\"}[5m]))",
"expr": "sum by(namespace) (rate(envoy_cluster_upstream_cx_tx_bytes_total{namespace=~\"$Namespace\"}[5m]))",
"instant": false,
"legendFormat": "{{namespace}}",
"range": true,
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ require (
)

require (
github.com/docker/docker v27.0.3+incompatible
github.com/docker/docker v27.3.1+incompatible
github.com/replicatedhq/troubleshoot v0.95.1-0.20240707233129-f5f02f5a807c
)

Expand Down Expand Up @@ -164,6 +164,7 @@ require (
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ github.com/docker/cli v27.0.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvM
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v27.0.3+incompatible h1:aBGI9TeQ4MPlhquTQKq9XbK79rKFVwXNUAYz9aXyEBE=
github.com/docker/docker v27.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI=
github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
Expand Down Expand Up @@ -871,6 +871,8 @@ github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU=
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
7 changes: 2 additions & 5 deletions internal/admin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import (

"github.com/davecgh/go-spew/spew"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/logging"
)

var adminLogger = logging.DefaultLogger(egv1a1.LogLevelInfo).WithName("admin")

func Init(cfg *config.Server) error {
if cfg.EnvoyGateway.GetEnvoyGatewayAdmin().EnableDumpConfig {
spewConfig := spew.NewDefaultConfig()
Expand All @@ -34,6 +30,7 @@ func start(cfg *config.Server) error {
address := cfg.EnvoyGateway.GetEnvoyGatewayAdminAddress()
enablePprof := cfg.EnvoyGateway.GetEnvoyGatewayAdmin().EnablePprof

adminLogger := cfg.Logger.WithName("admin")
adminLogger.Info("starting admin server", "address", address, "enablePprof", enablePprof)

if enablePprof {
Expand All @@ -57,7 +54,7 @@ func start(cfg *config.Server) error {
// Listen And Serve Admin Server.
go func() {
if err := adminServer.ListenAndServe(); err != nil {
cfg.Logger.Error(err, "start admin server failed")
adminLogger.Error(err, "start admin server failed")
}
}()

Expand Down
3 changes: 3 additions & 0 deletions internal/admin/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/logging"
)

func TestInitAdminServer(t *testing.T) {
Expand All @@ -20,6 +21,8 @@ func TestInitAdminServer(t *testing.T) {
EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{},
},
}

svrConfig.Logger = logging.NewLogger(egv1a1.DefaultEnvoyGatewayLogging())
err := Init(svrConfig)
require.NoError(t, err)
}
3 changes: 2 additions & 1 deletion internal/gatewayapi/contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ type ListenerContext struct {
}

func (l *ListenerContext) SetSupportedKinds(kinds ...gwapiv1.RouteGroupKind) {
l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = kinds
l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = make([]gwapiv1.RouteGroupKind, 0, len(kinds))
l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = append(l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds, kinds...)
}

func (l *ListenerContext) IncrementAttachedRoutes() {
Expand Down
1 change: 1 addition & 0 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR XdsIRMap
case gwapiv1.UDPProtocolType:
t.validateAllowedRoutes(listener, KindUDPRoute)
default:
listener.SetSupportedKinds()
status.SetGatewayListenerStatusCondition(listener.gateway.Gateway,
listener.listenerStatusIdx,
gwapiv1.ListenerConditionAccepted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ gateways:
status: "True"
type: ResolvedRefs
name: unsupported
supportedKinds: null
supportedKinds: []
httpRoutes:
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
Expand Down
4 changes: 4 additions & 0 deletions internal/infrastructure/kubernetes/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ type ResourceRender interface {
Service() (*corev1.Service, error)
ConfigMap() (*corev1.ConfigMap, error)
Deployment() (*appsv1.Deployment, error)
DeploymentSpec() (*egv1a1.KubernetesDeploymentSpec, error)
DaemonSet() (*appsv1.DaemonSet, error)
DaemonSetSpec() (*egv1a1.KubernetesDaemonSetSpec, error)
HorizontalPodAutoscaler() (*autoscalingv2.HorizontalPodAutoscaler, error)
HorizontalPodAutoscalerSpec() (*egv1a1.KubernetesHorizontalPodAutoscalerSpec, error)
PodDisruptionBudget() (*policyv1.PodDisruptionBudget, error)
PodDisruptionBudgetSpec() (*egv1a1.KubernetesPodDisruptionBudgetSpec, error)
}

// Infra manages the creation and deletion of Kubernetes infrastructure
Expand Down
40 changes: 40 additions & 0 deletions internal/infrastructure/kubernetes/infra_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ func (i *Infra) createOrUpdateConfigMap(ctx context.Context, r ResourceRender) (
// createOrUpdateDeployment creates a Deployment in the kube api server based on the provided
// ResourceRender, if it doesn't exist and updates it if it does.
func (i *Infra) createOrUpdateDeployment(ctx context.Context, r ResourceRender) (err error) {
// If deployment config is nil,ignore Deployment.
if deploymentConfig, er := r.DeploymentSpec(); deploymentConfig == nil {
return er
}

var (
deployment *appsv1.Deployment
startTime = time.Now()
Expand Down Expand Up @@ -122,6 +127,11 @@ func (i *Infra) createOrUpdateDeployment(ctx context.Context, r ResourceRender)
// createOrUpdateDaemonSet creates a DaemonSet in the kube api server based on the provided
// ResourceRender, if it doesn't exist and updates it if it does.
func (i *Infra) createOrUpdateDaemonSet(ctx context.Context, r ResourceRender) (err error) {
// If daemonset config is nil, ignore DaemonSet.
if daemonSetConfig, er := r.DaemonSetSpec(); daemonSetConfig == nil {
return er
}

var (
daemonSet *appsv1.DaemonSet
startTime = time.Now()
Expand Down Expand Up @@ -157,6 +167,11 @@ func (i *Infra) createOrUpdateDaemonSet(ctx context.Context, r ResourceRender) (
}

func (i *Infra) createOrUpdatePodDisruptionBudget(ctx context.Context, r ResourceRender) (err error) {
// If podDisruptionBudget config is nil or MinAvailable is nil, ignore PodDisruptionBudget.
if podDisruptionBudget, er := r.PodDisruptionBudgetSpec(); podDisruptionBudget == nil {
return er
}

var (
pdb *policyv1.PodDisruptionBudget
startTime = time.Now()
Expand Down Expand Up @@ -194,6 +209,11 @@ func (i *Infra) createOrUpdatePodDisruptionBudget(ctx context.Context, r Resourc
// the provided ResourceRender, if it doesn't exist and updates it if it does,
// and delete hpa if not set.
func (i *Infra) createOrUpdateHPA(ctx context.Context, r ResourceRender) (err error) {
// If hpa config is nil, ignore HorizontalPodAutoscaler.
if hpaConfig, er := r.HorizontalPodAutoscalerSpec(); hpaConfig == nil {
return er
}

var (
hpa *autoscalingv2.HorizontalPodAutoscaler
startTime = time.Now()
Expand Down Expand Up @@ -289,6 +309,11 @@ func (i *Infra) deleteServiceAccount(ctx context.Context, r ResourceRender) (err

// deleteDeployment deletes the Envoy Deployment in the kube api server, if it exists.
func (i *Infra) deleteDeployment(ctx context.Context, r ResourceRender) (err error) {
// If deployment config is nil,ignore Deployment.
if deploymentConfig, er := r.DeploymentSpec(); deploymentConfig == nil {
return er
}

var (
name, ns = r.Name(), i.Namespace
deployment = &appsv1.Deployment{
Expand Down Expand Up @@ -319,6 +344,11 @@ func (i *Infra) deleteDeployment(ctx context.Context, r ResourceRender) (err err

// deleteDaemonSet deletes the Envoy DaemonSet in the kube api server, if it exists.
func (i *Infra) deleteDaemonSet(ctx context.Context, r ResourceRender) (err error) {
// If daemonset config is nil, ignore DaemonSet.
if daemonSetConfig, er := r.DaemonSetSpec(); daemonSetConfig == nil {
return er
}

var (
name, ns = r.Name(), i.Namespace
daemonSet = &appsv1.DaemonSet{
Expand Down Expand Up @@ -409,6 +439,11 @@ func (i *Infra) deleteService(ctx context.Context, r ResourceRender) (err error)

// deleteHpa deletes the Horizontal Pod Autoscaler associated to its renderer, if it exists.
func (i *Infra) deleteHPA(ctx context.Context, r ResourceRender) (err error) {
// If hpa config is nil, ignore HorizontalPodAutoscaler.
if hpaConfig, er := r.HorizontalPodAutoscalerSpec(); hpaConfig == nil {
return er
}

var (
name, ns = r.Name(), i.Namespace
hpa = &autoscalingv2.HorizontalPodAutoscaler{
Expand Down Expand Up @@ -439,6 +474,11 @@ func (i *Infra) deleteHPA(ctx context.Context, r ResourceRender) (err error) {

// deletePDB deletes the PodDistribution budget associated to its renderer, if it exists.
func (i *Infra) deletePDB(ctx context.Context, r ResourceRender) (err error) {
// If podDisruptionBudget config is nil or MinAvailable is nil, ignore PodDisruptionBudget.
if podDisruptionBudget, er := r.PodDisruptionBudgetSpec(); podDisruptionBudget == nil {
return er
}

var (
name, ns = r.Name(), i.Namespace
pdb = &policyv1.PodDisruptionBudget{
Expand Down
58 changes: 47 additions & 11 deletions internal/infrastructure/kubernetes/proxy/resource_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,30 @@ func (r *ResourceRender) ConfigMap() (*corev1.ConfigMap, error) {
}, nil
}

// Deployment returns the expected Deployment based on the provided infra.
func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
// DeploymentSpec returns the `Deployment` sets spec.
func (r *ResourceRender) DeploymentSpec() (*egv1a1.KubernetesDeploymentSpec, error) {
proxyConfig := r.infra.GetProxyConfig()

// Get the EnvoyProxy config to configure the deployment.
provider := proxyConfig.GetEnvoyProxyProvider()
if provider.Type != egv1a1.ProviderTypeKubernetes {
return nil, fmt.Errorf("invalid provider type %v for Kubernetes infra manager", provider.Type)
}

deploymentConfig := provider.GetEnvoyProxyKubeProvider().EnvoyDeployment

// If deployment config is nil, it's not Deployment installation.
return deploymentConfig, nil
}

// Deployment returns the expected Deployment based on the provided infra.
func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
deploymentConfig, er := r.DeploymentSpec()
// If deployment config is nil,ignore Deployment.
if deploymentConfig == nil {
return nil, nil
return nil, er
}

proxyConfig := r.infra.GetProxyConfig()
// Get expected bootstrap configurations rendered ProxyContainers
containers, err := expectedProxyContainers(r.infra, deploymentConfig.Container, proxyConfig.Spec.Shutdown, r.ShutdownManager)
if err != nil {
Expand Down Expand Up @@ -274,6 +282,8 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
deployment.ObjectMeta.Name = r.Name()
}

provider := proxyConfig.GetEnvoyProxyProvider()

// omit the deployment replicas if HPA is being set
if provider.GetEnvoyProxyKubeProvider().EnvoyHpa != nil {
deployment.Spec.Replicas = nil
Expand All @@ -287,7 +297,8 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
return deployment, nil
}

func (r *ResourceRender) DaemonSet() (*appsv1.DaemonSet, error) {
// DaemonSetSpec returns the `DaemonSet` sets spec.
func (r *ResourceRender) DaemonSetSpec() (*egv1a1.KubernetesDaemonSetSpec, error) {
proxyConfig := r.infra.GetProxyConfig()

// Get the EnvoyProxy config to configure the daemonset.
Expand All @@ -296,13 +307,18 @@ func (r *ResourceRender) DaemonSet() (*appsv1.DaemonSet, error) {
return nil, fmt.Errorf("invalid provider type %v for Kubernetes infra manager", provider.Type)
}

daemonSetConfig := provider.GetEnvoyProxyKubeProvider().EnvoyDaemonSet
return provider.GetEnvoyProxyKubeProvider().EnvoyDaemonSet, nil
}

// If daemonset config is nil, it's not DaemonSet installation.
func (r *ResourceRender) DaemonSet() (*appsv1.DaemonSet, error) {
daemonSetConfig, err := r.DaemonSetSpec()
// If daemonset config is nil, ignore DaemonSet.
if daemonSetConfig == nil {
return nil, nil
return nil, err
}

proxyConfig := r.infra.GetProxyConfig()

// Get expected bootstrap configurations rendered ProxyContainers
containers, err := expectedProxyContainers(r.infra, daemonSetConfig.Container, proxyConfig.Spec.Shutdown, r.ShutdownManager)
if err != nil {
Expand Down Expand Up @@ -358,7 +374,8 @@ func (r *ResourceRender) DaemonSet() (*appsv1.DaemonSet, error) {
return daemonSet, nil
}

func (r *ResourceRender) PodDisruptionBudget() (*policyv1.PodDisruptionBudget, error) {
// PodDisruptionBudgetSpec returns the `PodDisruptionBudget` sets spec.
func (r *ResourceRender) PodDisruptionBudgetSpec() (*egv1a1.KubernetesPodDisruptionBudgetSpec, error) {
provider := r.infra.GetProxyConfig().GetEnvoyProxyProvider()
if provider.Type != egv1a1.ProviderTypeKubernetes {
return nil, fmt.Errorf("invalid provider type %v for Kubernetes infra manager", provider.Type)
Expand All @@ -369,6 +386,16 @@ func (r *ResourceRender) PodDisruptionBudget() (*policyv1.PodDisruptionBudget, e
return nil, nil
}

return podDisruptionBudget, nil
}

func (r *ResourceRender) PodDisruptionBudget() (*policyv1.PodDisruptionBudget, error) {
podDisruptionBudget, er := r.PodDisruptionBudgetSpec()
// If podDisruptionBudget config is nil or MinAvailable is nil, ignore PodDisruptionBudget.
if podDisruptionBudget == nil {
return nil, er
}

labels, err := r.getLabels()
if err != nil {
return nil, err
Expand All @@ -392,15 +419,22 @@ func (r *ResourceRender) PodDisruptionBudget() (*policyv1.PodDisruptionBudget, e
}, nil
}

func (r *ResourceRender) HorizontalPodAutoscaler() (*autoscalingv2.HorizontalPodAutoscaler, error) {
// HorizontalPodAutoscalerSpec returns the `HorizontalPodAutoscaler` sets spec.
func (r *ResourceRender) HorizontalPodAutoscalerSpec() (*egv1a1.KubernetesHorizontalPodAutoscalerSpec, error) {
provider := r.infra.GetProxyConfig().GetEnvoyProxyProvider()
if provider.Type != egv1a1.ProviderTypeKubernetes {
return nil, fmt.Errorf("invalid provider type %v for Kubernetes infra manager", provider.Type)
}

hpaConfig := provider.GetEnvoyProxyKubeProvider().EnvoyHpa
return hpaConfig, nil
}

func (r *ResourceRender) HorizontalPodAutoscaler() (*autoscalingv2.HorizontalPodAutoscaler, error) {
hpaConfig, err := r.HorizontalPodAutoscalerSpec()
// If hpa config is nil, ignore HorizontalPodAutoscaler.
if hpaConfig == nil {
return nil, nil
return nil, err
}

hpa := &autoscalingv2.HorizontalPodAutoscaler{
Expand All @@ -426,6 +460,8 @@ func (r *ResourceRender) HorizontalPodAutoscaler() (*autoscalingv2.HorizontalPod
},
}

provider := r.infra.GetProxyConfig().GetEnvoyProxyProvider()

// set deployment target ref name
deploymentConfig := provider.GetEnvoyProxyKubeProvider().EnvoyDeployment
if deploymentConfig.Name != nil {
Expand Down
Loading

0 comments on commit 13fee13

Please sign in to comment.