Several SidecarGateway CRs point to the same Pod

As described in CR SidecarGateway, the podSelector selects the Pods to which the CustomResource SidecarGateway should be applied.

Two different ​SidecarGateway CRs might point to the same Pod. That is an invalid configuration and could be detected as follows:

  1. List the SidecarGateway CustomResources
  2. kubectl get sidecargateways.microgateway.airlock.com  
    NAME        STATUS    AGE 
    webapp      Active    140m 
    webapp2     Error     21m
  3. The status Error indicates that something is wrong.
  4. Use kubectl describe sidecargateways.microgateway.airlock.com to inspect the status.
  5. kubectl describe sidecargateways.microgateway.airlock.com webapp2
    ...
    ... 
    Status: 
      Conditions: 
        Last Transition Time:  2022-09-13T14:55:26Z 
        Status:                True 
        Type:                  ConfigReferencesLoaded 
        Last Transition Time:  2022-09-13T14:55:26Z 
        Message:               The Pod 'webapp-84b785f954-r49wt' is already owned by the SidecarGateway 'webapp' 
        Reason:                PodAlreadyOwned 
        Status:                False 
        Type:                  PodsSelected 
        Last Transition Time:  2022-09-13T14:55:26Z 
        Status:                True 
        Type:                  EnvoyConfigSynced 
      Pods: 
        Envoy Config:  webapp-84b785f954-r49wt 
        Name:          webapp-84b785f954-r49wt 
      Status:          Error 
    Events:            <none>  

    The Status.Conditions.Message field contains the reason for the issue and says, that already another SidecarGateway is configuring the same Pod.

  6. Adjust the existing SidecarGateway CustomResources which point to the same Pod.
  7. The status of the SidecarGateway CRs has changed to Active.