简体   繁体   English

Kubernetes Java 客户端 API

[英]Kubernetes Java client API

I am trying to authenticate to the kubernetes cluster while using kubernetes java client API.我正在尝试在使用 kubernetes java 客户端 API 时对 kubernetes 集群进行身份验证。 I am using config file from .kube/config and pasting it into my project directory structure.我正在使用.kube/config配置文件并将其粘贴到我的项目目录结构中。 But the config file has expiry time, and it expires so my API fails, also sometimes when i generate the kubeconfig file it does not contain expiry time, thus the API fails.但是配置文件有过期时间,它过期了所以我的 API 失败,有时当我生成kubeconfig文件时它不包含过期时间,因此 API 失败。 How to get the permanent credentials for kubernetes cluster and use it in my code?如何获取 kubernetes 集群的永久凭证并在我的代码中使用它?

Deploy the java application inside the kubernetes cluster as pod and use InClusterClientExample .里面的kubernetes为吊舱和使用集群中部署Java应用程序InClusterClientExample In this case since the pod uses service account token it is guaranteed to work always because kubernetes takes care of refreshing the token.在这种情况下,由于 pod 使用服务帐户令牌,因此可以保证始终工作,因为 kubernetes 负责刷新令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM