envoyproxy / gateway

Manages Envoy Proxy as a Standalone or Kubernetes-based Application Gateway
https://gateway.envoyproxy.io
Apache License 2.0
1.58k stars 344 forks source link

Envoy Proxy deployment is not cleaned up when we customize the deployment name, replicas using EnvoyProxy resource #4380

Open tejaboppana opened 3 weeks ago

tejaboppana commented 3 weeks ago

Description: Envoy Proxy deployment is not cleaned up when we customize the deployment name, replicas etc using EnvoyProxy resource,

Repro steps:

  1. Create a Gateway and use a EnvoyProxy to set a custom name and increase the replicas.
  2. I tried deleting the Gateway and expected the envoy gateway to delete the envoy proxy deployment and service, but it did not. '
  3. Next I created another Gateway with an EnvoyProxy resource. Then I deleted the EnvoyProxy, envoy gateway created a single replica deployment with the a default name but did not delete the older deployment.
  4. Now when I deleted the Gateway , the new deployment with default name and the service were deleted but the older deployment with custom name still exists.

Environment: Envoy Gateway version - 1.1.2

Logs: I could not see any logs in Envoy Gateway pods when I deleted the Gateway.

arkodg commented 3 weeks ago

@tejaboppana thanks for flagging this in step 1, did you create the Gateway resource first (a.) and then create a EnvoyProxy specifying the custom deployment name (b.) and then link the EnvoyProxy resource to the Gateway by editing it (c.) ?

For this case the I think the infra layer will create a new deployment with the new name but not delete the older deployment When a custom name is set, we also need to delete the older deployment https://github.com/envoyproxy/gateway/blob/0f4cb27f0110051f7811122a2dd73652c93a15b2/internal/infrastructure/kubernetes/proxy/resource_provider.go#L153

tejaboppana commented 3 weeks ago

@arkodg I tried 2 things and below are my observations

  1. Steps that you mentioned i.e a) Create Gateway b) Create EnvoyProxy c) Edit Gatewayto link it with EnvoyProxy In this case a new deployment is created but the older deployment is not deleted which is not ideal. In addition to that, when I delete the Gateway and EnvoyProxy, I expected everything to be cleaned up. Only the older deployment and the service are deleted but the deployment with custom name is not deleted.

  2. a) Create EnvoyProxy b) Create Gateway and link it to the EnvoyProxy In this case the deployment is created with the custom name that I specified which is expected. But when I delete the Gateway and EnvoyProxy resources I expected the deployment and service to be deleted. However, this did not happen and both the deployment and service were still running. I had to manually delete them.

arkodg commented 2 weeks ago

thanks, yeah an additional item here to delete based on gateway owning labels, and not just deployment to svc name https://github.com/envoyproxy/gateway/blob/0f4cb27f0110051f7811122a2dd73652c93a15b2/internal/infrastructure/kubernetes/infra_resource.go#L402