#use host kubectl inside dagger function

1 messages · Page 1 of 1 (latest)

proper cove
#

Hi i am trying to use kubectl from host to generate a token for aws, i am passing it to a dagger function as a service --kube-service=tcp://kubenetes.deefault:443, and also passing the /var/run/secrets to mount the files . The command is kubectl create token <service-account> --audience="sts.amazonaws.com" command. In the host there is no kubeconfig file but command works. When i try to use it inside the dagger function, i need to generate a config file but then i am unable to generate the token, it fails with error tls: failed to verify certificate: x509: certificate is valid for <some-string>.eks.amazonaws.com, kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster.local, not kubectl. Is there any example out there?

lusty plaza
#

In your setup is it possible to pass the aws token itself rather than generating it inside the module? Something like --aws-token cmd:"kubectl create token ..."

proper cove
#

I am doing a loop inside the function, to listen for some status, the problem is that after some time there is a risk of token expiration, that's why i wanted to trigger the command inside the function, so that the token is generated at the right time

proper cove
#

OK so i managed to make it work, i was calling my service kubectl and it needs one of kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster.local

#

i had ctr.WithServiceBinding("kubectl", cpe.KubectlService) = wrong

#

and fixed it with ctr.WithServiceBinding("kubernetes.default", cpe.KubectlService)

proper cove
#

use host kubectl inside dagger function