Skip to content

Commit

Permalink
remove ratelimit changes
Browse files Browse the repository at this point in the history
Signed-off-by: jukie <[email protected]>
  • Loading branch information
jukie committed Oct 13, 2024
1 parent 2c8c8c4 commit 36100da
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 44 deletions.
13 changes: 2 additions & 11 deletions api/v1alpha1/envoygateway_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,11 @@ func (r *EnvoyGatewayProvider) GetEnvoyGatewayKubeProvider() *EnvoyGatewayKubern
r.Kubernetes.LeaderElection = DefaultLeaderElection()
}

// if RateLimitDeployment and RateLimitDaemonset are both nil, use RateLimitDeployment
if r.Kubernetes.RateLimitDeployment == nil && r.Kubernetes.RateLimitDaemonset == nil {
if r.Kubernetes.RateLimitDeployment == nil {
r.Kubernetes.RateLimitDeployment = DefaultKubernetesDeployment(DefaultRateLimitImage)
}

// if use RateLimitDeployment, set default values
if r.Kubernetes.RateLimitDeployment != nil {
r.Kubernetes.RateLimitDeployment.defaultKubernetesDeploymentSpec(DefaultRateLimitImage)
}

// if use RateLimitDaemonset, set default values
if r.Kubernetes.RateLimitDaemonset != nil {
r.Kubernetes.RateLimitDaemonset.defaultKubernetesDaemonSetSpec(DefaultRateLimitImage)
}
r.Kubernetes.RateLimitDeployment.defaultKubernetesDeploymentSpec(DefaultRateLimitImage)

if r.Kubernetes.ShutdownManager == nil {
r.Kubernetes.ShutdownManager = &ShutdownManager{Image: ptr.To(DefaultShutdownManagerImage)}
Expand Down
7 changes: 0 additions & 7 deletions api/v1alpha1/envoygateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,6 @@ type EnvoyGatewayKubernetesProvider struct {
// +optional
RateLimitDeployment *KubernetesDeploymentSpec `json:"rateLimitDeployment,omitempty"`

// RateLimitDaemonset defines the desired state of the Envoy ratelimit daemonset resource.
// If unspecified, default settings for the managed Envoy ratelimit daemonset resource
// are applied.
//
// +optional
RateLimitDaemonset *KubernetesDaemonSetSpec `json:"rateLimitDaemonset,omitempty"`

// Watch holds configuration of which input resources should be watched and reconciled.
// +optional
Watch *KubernetesWatchMode `json:"watch,omitempty"`
Expand Down
5 changes: 0 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

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

30 changes: 15 additions & 15 deletions internal/infrastructure/kubernetes/ratelimit/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func rateLimitLabels() map[string]string {
}

// expectedRateLimitContainers returns expected rateLimit containers.
func expectedRateLimitContainers(rateLimit *egv1a1.RateLimit, rateLimitContainerSpec *egv1a1.KubernetesContainerSpec,
func expectedRateLimitContainers(rateLimit *egv1a1.RateLimit, rateLimitDeployment *egv1a1.KubernetesDeploymentSpec,
namespace string,
) []corev1.Container {
ports := []corev1.ContainerPort{
Expand All @@ -152,16 +152,16 @@ func expectedRateLimitContainers(rateLimit *egv1a1.RateLimit, rateLimitContainer
containers := []corev1.Container{
{
Name: InfraName,
Image: *rateLimitContainerSpec.Image,
Image: *rateLimitDeployment.Container.Image,
ImagePullPolicy: corev1.PullIfNotPresent,
Command: []string{
"/bin/ratelimit",
},
Env: expectedRateLimitContainerEnv(rateLimit, rateLimitContainerSpec, namespace),
Env: expectedRateLimitContainerEnv(rateLimit, rateLimitDeployment, namespace),
Ports: ports,
Resources: *rateLimitContainerSpec.Resources,
SecurityContext: expectedRateLimitContainerSecurityContext(rateLimitContainerSpec),
VolumeMounts: expectedContainerVolumeMounts(rateLimit, rateLimitContainerSpec),
Resources: *rateLimitDeployment.Container.Resources,
SecurityContext: expectedRateLimitContainerSecurityContext(rateLimitDeployment),
VolumeMounts: expectedContainerVolumeMounts(rateLimit, rateLimitDeployment),
TerminationMessagePolicy: corev1.TerminationMessageReadFile,
TerminationMessagePath: "/dev/termination-log",
StartupProbe: &corev1.Probe{
Expand Down Expand Up @@ -197,7 +197,7 @@ func expectedRateLimitContainers(rateLimit *egv1a1.RateLimit, rateLimitContainer
}

// expectedContainerVolumeMounts returns expected rateLimit container volume mounts.
func expectedContainerVolumeMounts(rateLimit *egv1a1.RateLimit, rateLimitContainerSpec *egv1a1.KubernetesContainerSpec) []corev1.VolumeMount {
func expectedContainerVolumeMounts(rateLimit *egv1a1.RateLimit, rateLimitDeployment *egv1a1.KubernetesDeploymentSpec) []corev1.VolumeMount {
var volumeMounts []corev1.VolumeMount

// mount the cert
Expand All @@ -223,11 +223,11 @@ func expectedContainerVolumeMounts(rateLimit *egv1a1.RateLimit, rateLimitContain
})
}

return resource.ExpectedContainerVolumeMounts(rateLimitContainerSpec, volumeMounts)
return resource.ExpectedContainerVolumeMounts(rateLimitDeployment.Container, volumeMounts)
}

// expectedDeploymentVolumes returns expected rateLimit deployment volumes.
func expectedDeploymentVolumes(rateLimit *egv1a1.RateLimit, rateLimitPodSpec *egv1a1.KubernetesPodSpec) []corev1.Volume {
func expectedDeploymentVolumes(rateLimit *egv1a1.RateLimit, rateLimitDeployment *egv1a1.KubernetesDeploymentSpec) []corev1.Volume {
var volumes []corev1.Volume

if rateLimit.Backend.Redis != nil &&
Expand Down Expand Up @@ -269,11 +269,11 @@ func expectedDeploymentVolumes(rateLimit *egv1a1.RateLimit, rateLimitPodSpec *eg
})
}

return resource.ExpectedVolumes(rateLimitPodSpec, volumes)
return resource.ExpectedVolumes(rateLimitDeployment.Pod, volumes)
}

// expectedRateLimitContainerEnv returns expected rateLimit container envs.
func expectedRateLimitContainerEnv(rateLimit *egv1a1.RateLimit, rateLimitContainerSpec *egv1a1.KubernetesContainerSpec,
func expectedRateLimitContainerEnv(rateLimit *egv1a1.RateLimit, rateLimitDeployment *egv1a1.KubernetesDeploymentSpec,
namespace string,
) []corev1.EnvVar {
env := []corev1.EnvVar{
Expand Down Expand Up @@ -445,7 +445,7 @@ func expectedRateLimitContainerEnv(rateLimit *egv1a1.RateLimit, rateLimitContain
env = append(env, tracingEnvs...)
}

return resource.ExpectedContainerEnv(rateLimitContainerSpec, env)
return resource.ExpectedContainerEnv(rateLimitDeployment.Container, env)
}

// Validate the ratelimit tls secret validating.
Expand Down Expand Up @@ -489,9 +489,9 @@ func checkTraceEndpointScheme(url string) string {
return fmt.Sprintf("%s%s", httpScheme, url)
}

func expectedRateLimitContainerSecurityContext(rateLimitContainerSpec *egv1a1.KubernetesContainerSpec) *corev1.SecurityContext {
if rateLimitContainerSpec.SecurityContext != nil {
return rateLimitContainerSpec.SecurityContext
func expectedRateLimitContainerSecurityContext(rateLimitDeployment *egv1a1.KubernetesDeploymentSpec) *corev1.SecurityContext {
if rateLimitDeployment.Container.SecurityContext != nil {
return rateLimitDeployment.Container.SecurityContext
}
return defaultSecurityContext()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
return nil, er
}

containers := expectedRateLimitContainers(r.rateLimit, r.rateLimitDeployment.Container, r.Namespace)
containers := expectedRateLimitContainers(r.rateLimit, r.rateLimitDeployment, r.Namespace)
selector := resource.GetSelector(rateLimitLabels())

podLabels := rateLimitLabels()
Expand Down Expand Up @@ -250,7 +250,7 @@ func (r *ResourceRender) Deployment() (*appsv1.Deployment, error) {
RestartPolicy: corev1.RestartPolicyAlways,
SchedulerName: "default-scheduler",
SecurityContext: r.rateLimitDeployment.Pod.SecurityContext,
Volumes: expectedDeploymentVolumes(r.rateLimit, r.rateLimitDeployment.Pod),
Volumes: expectedDeploymentVolumes(r.rateLimit, r.rateLimitDeployment),
Affinity: r.rateLimitDeployment.Pod.Affinity,
Tolerations: r.rateLimitDeployment.Pod.Tolerations,
ImagePullSecrets: r.rateLimitDeployment.Pod.ImagePullSecrets,
Expand Down
2 changes: 0 additions & 2 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,6 @@ _Appears in:_
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rateLimitDeployment` | _[KubernetesDeploymentSpec](#kubernetesdeploymentspec)_ | false | RateLimitDeployment defines the desired state of the Envoy ratelimit deployment resource.<br />If unspecified, default settings for the managed Envoy ratelimit deployment resource<br />are applied. |
| `rateLimitDaemonset` | _[KubernetesDaemonSetSpec](#kubernetesdaemonsetspec)_ | false | RateLimitDaemonset defines the desired state of the Envoy ratelimit daemonset resource.<br />If unspecified, default settings for the managed Envoy ratelimit daemonset resource<br />are applied. |
| `watch` | _[KubernetesWatchMode](#kuberneteswatchmode)_ | false | Watch holds configuration of which input resources should be watched and reconciled. |
| `deploy` | _[KubernetesDeployMode](#kubernetesdeploymode)_ | false | Deploy holds configuration of how output managed resources such as the Envoy Proxy data plane<br />should be deployed |
| `overwriteControlPlaneCerts` | _boolean_ | false | OverwriteControlPlaneCerts updates the secrets containing the control plane certs, when set. |
Expand Down Expand Up @@ -2433,7 +2432,6 @@ _Appears in:_
KubernetesDaemonsetSpec defines the desired state of the Kubernetes daemonset resource.

_Appears in:_
- [EnvoyGatewayKubernetesProvider](#envoygatewaykubernetesprovider)
- [EnvoyProxyKubernetesProvider](#envoyproxykubernetesprovider)

| Field | Type | Required | Description |
Expand Down
2 changes: 0 additions & 2 deletions site/content/zh/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,6 @@ _Appears in:_
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rateLimitDeployment` | _[KubernetesDeploymentSpec](#kubernetesdeploymentspec)_ | false | RateLimitDeployment defines the desired state of the Envoy ratelimit deployment resource.<br />If unspecified, default settings for the managed Envoy ratelimit deployment resource<br />are applied. |
| `rateLimitDaemonset` | _[KubernetesDaemonSetSpec](#kubernetesdaemonsetspec)_ | false | RateLimitDaemonset defines the desired state of the Envoy ratelimit daemonset resource.<br />If unspecified, default settings for the managed Envoy ratelimit daemonset resource<br />are applied. |
| `watch` | _[KubernetesWatchMode](#kuberneteswatchmode)_ | false | Watch holds configuration of which input resources should be watched and reconciled. |
| `deploy` | _[KubernetesDeployMode](#kubernetesdeploymode)_ | false | Deploy holds configuration of how output managed resources such as the Envoy Proxy data plane<br />should be deployed |
| `overwriteControlPlaneCerts` | _boolean_ | false | OverwriteControlPlaneCerts updates the secrets containing the control plane certs, when set. |
Expand Down Expand Up @@ -2433,7 +2432,6 @@ _Appears in:_
KubernetesDaemonsetSpec defines the desired state of the Kubernetes daemonset resource.

_Appears in:_
- [EnvoyGatewayKubernetesProvider](#envoygatewaykubernetesprovider)
- [EnvoyProxyKubernetesProvider](#envoyproxykubernetesprovider)

| Field | Type | Required | Description |
Expand Down

0 comments on commit 36100da

Please sign in to comment.