Kmesh v0.2.0 needs to be restarted for configuration changes to take effect (using Istio 1.19 and Kubernetes 1.27)
tmodak27 opened this issue · comments
What happened:
With Kmesh v0.2.0 already running, I deployed a Virtual Service for L7 url routing. Below are my two observations
- The exported bpf config was NOT updated with the routing rule
- The request did NOT get routed as expected.
However, after restarting Kmesh, the following was observed
- The exported bpf config was updated with the routing rule
- The request got routed as expected.
For reference, refer to this comment from another github issue:
What you expected to happen:
After deploying the virtual service, the bpf map should get updated and the routing should take effect WITHOUT having to restart Kmesh
How to reproduce it (as minimally and precisely as possible):
Run the below steps with Kmesh v0.2.0 already running
Step 1
Deploy 2 Backend Services httpecho-a and httpecho-b
- yaml for service httpecho-a
# kubectl apply -f service-a.yaml
apiVersion: v1
kind: Service
metadata:
name: httpecho-a
labels:
app: httpecho-a
service: httpecho-a
spec:
ports:
- port: 5000
name: http
selector:
app: httpecho-a
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpecho-a
labels:
app: httpecho-a
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: httpecho-a
version: v1
template:
metadata:
labels:
app: httpecho-a
version: v1
spec:
containers:
- name: httpecho-a
image: docker.io/istio/examples-helloworld-v1
resources:
requests:
cpu: "100m"
imagePullPolicy: IfNotPresent #Always
ports:
- containerPort: 5000
- yaml for httpecho-b
# kubectly apply -f service-b.yaml
apiVersion: v1
kind: Service
metadata:
name: httpecho-b
labels:
app: httpecho-b
service: httpecho-b
spec:
ports:
- port: 5000
name: httpb
selector:
app: httpecho-b
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpecho-b
labels:
app: httpecho-b
version: v2
spec:
replicas: 1
selector:
matchLabels:
app: httpecho-b
version: v2
template:
metadata:
labels:
app: httpecho-b
version: v2
spec:
containers:
- name: httpecho-b
image: docker.io/istio/examples-helloworld-v1
resources:
requests:
cpu: "100m"
imagePullPolicy: IfNotPresent #Always
ports:
- containerPort: 5000
Step 2: Deploy netutils client for sending http requests
kubectl run --image=hwchiu/netutils netutils
Send requests to http-echo-a and httpecho-b with the netutils client. Note the difference in pod names in the response from each service
$ kubectl exec -it netutils -- curl httpecho-a:5000
Hello V1, routed from pod httpecho-a-gu83s
$ kubectl exec -it netutils -- curl httpecho-b:5000
Hello V1, routed from pod httpecho-b-t7wx5
Step 3: Deploy Virtual Service for L7 Url Routing
This rule should route all requests sent to httpecho-b to httpecho-a instead
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: route-b-to-a
spec:
hosts:
- httpecho-b
http:
- match:
- port: 5000
route:
- destination:
host: httpecho-a.default.svc.cluster.local
port:
number: 5000
Step 4: Send request to httpecho-b
Note the pod name in the response. If routing works, it should be httpecho-a-gu83s, and NOT httpecho-b-t7wx5.
$ kubectl exec -it netutils -- curl httpecho-b:5000/hello
Hello V1, routed from pod httpecho-b-t7wx5
Also, export the bpf config using curl GET /bpf/kmesh/maps:15200. The newly added rule is NOT a part of the bpf config.
Step 4: Restart Kmesh and run the above command once again:
The request gets routed to httpecho-a
$ kubectl exec -it netutils -- curl httpecho-b:5000/hello
Hello V1, routed from pod httpecho-a-gu83s
export the bpf config using curl GET /bpf/kmesh/maps:15200. The newly added rule is a part of the exported bpf config.
![bpf_config_image](https://private-user-images.githubusercontent.com/60729152/309835000-9c466b07-0c76-487d-934e-665e11c09fc3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4NzcwNjIsIm5iZiI6MTcyMTg3Njc2MiwicGF0aCI6Ii82MDcyOTE1Mi8zMDk4MzUwMDAtOWM0NjZiMDctMGM3Ni00ODdkLTkzNGUtNjY1ZTExYzA5ZmMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI1VDAzMDYwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM2YmM1YzlhYzY1MmRmYTI3YWNkMGU2OGFmMmM2YWJhZWRkNDU5ZDRlNzg5OWUyODliYzk3NjM1Y2ZhOTE4MDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7TzDPfeSEsEGsM5sR65DlD5e15buGXrIcwASRIB-Jw0)
The same issue occurs when we try to delete the routing rule. The request keeps getting routed to httpecho-a. Once we restart kmesh, the request gets routed to httpecho-b
Anything else we need to know?:
Environment:
- Kmesh version: v0.2.0
- Istio: 1.19.0
- Kubernetes: 1.27.0
A code optimization is required:The resource name field needs to be filled in newAckRequest when the xDS type is RDS or EDS, will fix it @lec-bit