Localhost:8080 was refused via jenkins but works via manual execution in server

Dear All,

I am very new to Kubernetes and in the beginning days of learning it .So advance apology If mistaking with some technical terms here. I have a strange issue where i am getting error message as port 8080 is refused while I am running the command via jenkins but it works fine when I run manually.

Command ran:
kubectl apply -f <kubernetes_deployment.yml>

Error in jenkins:
“delta”: “0:00:00.049013”, “end”: “2022-04-26 14:47:53.248479”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2022-04-26 14:47:53.199466”, “stderr”: “The connection to the server localhost:8080 was refused - did you specify the right host or port?”, “stderr_lines”: [“The connection to the server localhost:8080 was refused - did you specify the right host or port?”], “stdout”: “”, “stdout_lines”: }
[WARNING]: Consider using ‘become’, ‘become_method’, and ‘become_user’ rather

Jenkins Running on Ubuntu 18.04.6 LTS on Server 1

Jenkins Version:2.332.2
Jenkins Server: Ubuntu 18.04.6 LTS

Cluster information:

Kubernets running on server 2

Kubernetes version:
Client Version: version.Info{Major:“1”, Minor:“23”, GitVersion:“v1.23.6”, GitCommit:“ad3338546da947756e8a88aa6822e9c11e7eac22”, GitTreeState:“clean”, BuildDate:“2022-04-14T08:49:13Z”, GoVersion:“go1.17.9”, Compiler:“gc”, Platform:“linux/amd64”}
Server Version: version.Info{Major:“1”, Minor:“22”, GitVersion:“v1.22.6”, GitCommit:“07959215dd83b4ae6317b33c824f845abd578642”, GitTreeState:“clean”, BuildDate:“2022-03-30T18:28:25Z”, GoVersion:“go1.16.12”, Compiler:“gc”, Platform:“linux/amd64”}

Cloud being used: (put bare-metal if not on a public cloud) : Microsoft Azure

Installation method: Minikube

Host OS: Ubuntu 20.04.4 LTS