This repo used for auto scaling JMeter Agents with Kubernetes
docker build -t your-repo/jmeter:latest .
docker push your-repo/jmeter:latest
copy your ./kubernetes/.kube/config
to ~/.kube/config
file
Run the context
kubectl config use-context prod-cluster
Verify the ccurrent context
List All contexts
kubectl config get-contexts
Restart your kubectl
proxy (if applicable):
kubectl proxy --port=8080
Run before any other step
in powershell run as a administrator
minikube start --driver=hyperv
Validate yaml manually
kubectl apply --dry-run=client --validate=true -f jmeter-agent-deployment.yaml
Apply Configurations:
kubectl create namespace jmeter-ns
kubectl apply -f jmeter-agent-deployment.yaml
kubectl apply -f jmeter-master-deployment.yaml
kubectl apply -f jmeter-agent-service.yaml
Verify Deployments:
kubectl get pods
NAME READY STATUS RESTARTS AGE
jmeter-agent-84bcbcb4f-7zzqf 0/1 ContainerCreating 0 4s
jmeter-agent-84bcbcb4f-cj6tp 0/1 ContainerCreating 0 4s
jmeter-agent-84bcbcb4f-ptlbd 0/1 ContainerCreating 0 4s
jmeter-master-57b5c764d9-hn4wc 0/1 ContainerCreating 0 52s
kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15m
Configure test parameters
kubectl exec -it jmeter-master -n jmeter-ns -- jmeter -n -t /tests/HTTPSignInSignOffPlan.jmx -Jusers=50 -Jduration=300 -R jmeter-agent-0, jmeter-agent-1, jmeter-agent-2
Run the test
kubectl logs -f deployment/jmeter-master -n jmeter
Use Kubernetes logs to fetch results:
kubectl cp jmeter/jmeter-master:/test/test-results.jtl ./test-results.jtl
Cleanup
kubectl delete namespace jmeter-ns
kubectl autoscale deployment jmeter-agent --cpu-percent=50 --min=1 --max=10
Organize the project:
jmeter-load-testing/
├── Dockerfile
├── kubernetes/
│ ├── jmeter-master-deployment.yaml
│ ├── jmeter-agent-deployment.yaml
│ └── configmap.yaml
├── helm-chart/
└── tests/
├── test.jmx
├── test-data.csv
The error message indicates that a client application, likely kubectl
, is trying to access the Kubernetes API server at http://localhost:8080
, but the connection is being refused. This is typically caused by the API server not running, being configured incorrectly, or the client not being able to reach it. Here’s how to troubleshoot and resolve the issue:
current-context
points to the correct cluster.minikube
or kind
), ensure the cluster is started:
Minikube:
If it’s not running, start it:
Kind:
If no clusters are listed, create one:
http://localhost:8080
unless you’re running a local proxy (e.g., kubectl proxy
).Check the correct endpoint in the kubeconfig:
Look for the server
entry under the current context, which should point to the correct API server URL.
kubectl proxy
if Neededhttp://localhost:8080
, you might need to run kubectl proxy
:localhost:8080
to the API server.<API_SERVER_ENDPOINT>
with the actual API server URL (e.g., https://<your-cluster-endpoint>
).$minikube start
* minikube v1.34.0 on Microsoft Windows 11 Home 10.0.22631.4602 Build 22631.4602
* Unable to pick a default driver. Here is what was considered, in preference order:
- docker: Not healthy: "docker version --format -:" exit status 1: error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.47/version": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.
- docker: Suggestion: <https://minikube.sigs.k8s.io/docs/drivers/docker/>
- hyperv: Not healthy: Hyper-V requires Administrator privileges
- hyperv: Suggestion: Right-click the PowerShell icon and select Run as Administrator to open PowerShell in elevated mode. <>
* Alternatively you could install one of these drivers:
- virtualbox: Not installed: unable to find VBoxManage in $PATH
- qemu2: Not installed: exec: "qemu-system-x86_64": executable file not found in %PATH%
- podman: Not installed: exec: "podman": executable file not found in %PATH%
https://www.virtualbox.org/wiki/Downloads
https://www.qemu.org/download/
https://www.msys2.org/
https://podman.io/docs/installation
$kubectl get nodes
E1215 09:39:19.938225 20516 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
https://discuss.kubernetes.io/t/couldnt-get-current-server-api-group-list-get-http-localhost-8080-api-timeout-32s-dial-tcp-127-0-0-1-connect-connection-refused/25471
Resolve by
KUBECONFIG=$HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
if this still doesnt resolve. then,
All you need is to remove containerd service and reinstall it again
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
. : File C:\Users\srinivas\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:\Users\srinivas\OneDrive\Documents\WindowsPowerShell\Microsoft.P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4#msi
powershell run as a administrator
minikube start --driver=hyperv
ChatGPT said:
The error indicates that Minikube is not able to find a cluster named minikube
. This usually happens when no Minikube cluster has been created or the configuration is corrupted.
Here’s how to troubleshoot and resolve the issue:
minikube
profile is missing, you need to create a new cluster.--driver
flag with alternatives like Docker:docker
virtualbox
hyperkit
none
(bare metal)Let me know if you encounter any issues during these steps!