With Sauce Connect Helm chart you can easily run Sauce Connect Proxy version 4 in Kubernetes.
The repo contains a reference Helm chart. It can be used to deploy the Sauce Connect Proxy to Kubernetes.
To use this chart
---
sc:
region: us-west
user: johndoe
accessKey: "xxx-xxx-xxx"
tunnelName: "my-k8s-tunnel"
$ POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=sauce-connect-4,app.kubernetes.io/instance=sauce-connect-4" -o jsonpath="{.items[0].metadata.name}")
$ CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
$ kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
$ curl -s 127.0.0.1:8080/api/v1/status | jq .
$ curl -s http://127.0.0.1:8080/api/v1/status | jq .
{
"firstConnectedTime": 1662098351,
"tunnelID": "11111",
"tunnelName": "my-k8s-tunnel",
"tunnelServer": "tunnel-59569b.tunnels.us-west-1.saucelabs.com",
"lastStatusChange": 1662098350,
"reconnectCount": 0,
"tunnelStatus": "connected"
}
$ kubectl logs $POD_NAME -f
...
2022-08-02 02:59:11.464 [8] [CLI] [info] Connection state has changed: previous: INIT, actual: CONNECTED.
2022-08-02 02:59:11.464 [8] [CLI] [info] Sauce Connect is up, you may start your tests.
The terminationGracePeriodSeconds
is set to 600 seconds to allow sufficient time for jobs using the Sauce Connect Proxy to finish.