I am building a pipeline for K8s in VSTS. I have a set of tests written in NodeJS that use kubernetes-client in order to check if everything has been deployed properly.
For the deployment itself we have two service connections created. I would like to access kube config files associated with those connection in to execute test code according to deployment cluster configuration.
To make long story short if we deploy to staging env use staging kubernetes config, if we deploy to prod use the other one. I could commit those configs but that's not the proper way of doing it.
I have also tried to use Rest endpoint _apis/distributedtask/serviceendpoints
but I can only reach the metadata and not the config itself.
I have also tried importing vsts task library in my test scripts but I am not able to auth.
const tl = require('vsts-task-lib/task');
let kubeconfig = tl.getEndpointAuthorizationParameter(endpointName, 'kubeconfig', false);
The workaround could be create a custom VSTS task read the service connection value and pass it to output but I guess it is not the proper approach either.
Regards
You can put the config file to the repository or other server (e.g. FTP), then retrieve the content during build/release.
You also can store it in service endpoint and retrieve the config content by custom build/release task (tl.getEndpointAuthorizationParameter(kubernetesEndpoint, 'kubeconfig', false);
), you can refer to the source code of Kubernetes task to custom build/release task.
Which way is better is based on your requirement (e.g. simple, security).