How to specify K8s credentials that are associated with the infrastructure that is used in a workflow when executing "kubectl" in a bash script?

For this use case within the shell script you can simply reference credentials it as ${HARNESS_KUBE_CONFIG_PATH}

export KUBECONFIG=${HARNESS_KUBE_CONFIG_PATH} kubectl get pods -n pod-test

With this even when running the shell script on delegate host, it can refer the credentials of the K8s cloud provider which is used inside infrastructure defintion associated with the workflow.

More information around HARNESS_KUBE_CONFIG_PATH is listed in docs: