Kong OSS - Navigate traffic between 2 different pods of 2 different namespace

Hi All,
I am new in Kong. As per my POC use case, I need to manage traffic between 2 different pods of 2 different namespace using lua script. Below are related deployments and steps. Can someone please assist, it’ll be great help.

Kong Installation -
helm repo add kong https://charts.konghq.com
helm repo update
helm install kong-helm-release kong/kong --create-namespace --namespace kong --set admin.enabled=true --set admin.type=ClusterIP --set admin.http.enabled=true --set ingressController.enabled=true --set ingressController.installCRDs=true --set proxy.type=ClusterIP --set annotations.“app.kubernetes.io/managed-by"="Helm” --set annotations.“meta.helm.sh/release-name”=“kong-helm-release”

Apps Deployment YAML -
apiVersion: v1
kind: Namespace
metadata:
name: namespace1

apiVersion: v1
kind: Namespace
metadata:
name: namespace2

apiVersion: v1
kind: Service
metadata:
name: app1
namespace: namespace1
spec:
selector:
app: app1
ports:
- protocol: TCP
port: 80
targetPort: 8080

apiVersion: apps/v1
kind: Deployment
metadata:
name: app1
namespace: namespace1
spec:
replicas: 1
selector:
matchLabels:
app: app1
template:
metadata:
labels:
app: app1
spec:
containers:
- name: app1
image: hashicorp/http-echo
args:
- “-text=app1”
ports:
- containerPort: 8080

apiVersion: v1
kind: Service
metadata:
name: app2
namespace: namespace2
spec:
selector:
app: app2
ports:
- protocol: TCP
port: 80
targetPort: 8080

apiVersion: apps/v1
kind: Deployment
metadata:
name: app2
namespace: namespace2
spec:
replicas: 1
selector:
matchLabels:
app: app2
template:
metadata:
labels:
app: app2
spec:
containers:
- name: app2
image: hashicorp/http-echo
args:
- “-text=app2”
ports:
- containerPort: 8080

KongPlugin YAML -
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: luakongredirect
namespace: kong
config:
access:
- |
local customRouting=require(“customrouting”)
customRouting()
plugin: pre-function

ConfigMap -
apiVersion: v1
kind: ConfigMap
metadata:
name: customroutingconfigmap
namespace: kong
data:
customrouting.lua: |
function redirect()
if ngx.req.get_method() == “GET” then
ngx.var.target = “http://app1.namespace1.svc.cluster.local:8080
end
end

    return {
        access = redirect
    }

Kong-ingress-custom-plugin-
gateway:
plugins:
configMaps:

  • name: customroutingconfigmap
    pluginName: customroutingconfigmap2

Ingress Installation-
helm install kong kong/ingress -n kong --values Kong-ingress-custom-plugin.yaml