You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SVC_IP=$(kubectl -n <name space> get svc <service name> --output jsonpath='{.status.loadBalancer.ingress[0].ip}')
16
-
```
13
+
`kubectl`'s `port-forward` command allows accessing applications running in a Kubernetes cluster using a local port.
17
14
18
-
```Powershell
19
-
$Env:SVC_IP=$(kubectl -n <name space> get svc <service name> --output jsonpath='{.status.loadBalancer.ingress[0].ip}')
15
+
For example, the following command will make `my-service`'s port `80` accessible as `localhost:8080`:
16
+
17
+
```sh
18
+
kubectl port-forward svc/my-service 8080:80
19
+
Forwarding from 127.0.0.1:8080 -> 80
20
20
```
21
21
22
-
</CodeGroup>
22
+
### Limitations using port forwarding
23
+
24
+
To be able to inject faults, `xk6-disruptor` must [install an agent on each target](/javascript-api/xk6-disruptor/explanations/how-xk6-disruptor-works) that intercepts the requests and applies the desired disruptions. This process requires any existing connection to the targets to be redirected to the agent.
25
+
26
+
Due to a existing bug in `kubectl`, the process of installing the disruptor can potentially [break the port forwarding](https://github.com/grafana/xk6-disruptor/issues/254). Notice that this issue happens only if the faults are injected in the service that is exposed using port forward. If the faults are injected in another service not exposed by port-forwarding, there shouldn't be any issue.
27
+
28
+
Until this issue is solved in `kubectl`, tests using port forwarding to access a service should ensure the agent is installed in the targets before any traffic is sent by the test.
29
+
30
+
The simplest way to accomplish this is to ensure the scenario that executes the load (2) starts after the scenario that injects the faults (1):
31
+
32
+
```javascript
33
+
scenarios: {
34
+
disrupt: { (1)
35
+
executor:'shared-iterations',
36
+
iterations:1,
37
+
vus:1,
38
+
exec:"disrupt",
39
+
startTime:"0s",
40
+
}
41
+
load: { (2)
42
+
executor:'constant-arrival-rate',
43
+
rate:100,
44
+
preAllocatedVUs:10,
45
+
maxVUs:100,
46
+
exec:"default",
47
+
startTime:'20s', // give time for the agents to be installed
0 commit comments