I get temp token using STS-AssumeRole, then I use the token to construct k8s apiClient and CoreV1Api:
ApiClient apiClient = new ClientBuilder()
.setAuthentication(new AccessTokenAuthentication(token))
.setBasePath(endpointUrl)
.setCertificateAuthority(cacert)
.setVerifyingSsl(true)
.build();
CoreV1Api api = new CoreV1Api(apiClient);
V1PodList podList = api.listPodForAllNamespaces(null, null, labelSelector, null, null, null, null, null);
I call listPodForAllNamespaces every few minutes. However, token expires in 1 hour. How can I update tokens in ApiClient?
Token construction is the same as this: Get authentication token from AWS EKS using the AWS Java SDK v2. And I hava seen how to auto-refresh AWS STS Temporary security credentials when it expires while accessing Amazon SQS?, however, apiclient doesn't have the Credentials parameter.