用于创建、操作和编辑kubeconfig文件的轻量级python模块
kubeconf的Python项目详细描述
库贝孔夫
用于创建、操作和编辑kubeconfig文件的轻量级python模块
为什么不使用或包装kubectl config
?kubectl config
很好,编写python包装器是一个很好的解决方案。然而,kubectl config
在功能上非常有限。我想要更多的控制我的kubernetes配置。kubeconfig给了我这个控制权。它根本不使用kubectl。相反,它完全独立地读取、编辑和写入配置文件。
开始
使用pip安装此软件包:
pip install kubeconf
基本用法
fromkubeconfimportKubeConfk=KubeConf(path='path/to/config')# Open the filek.open()# Add a clusterk.add_cluster(name='mycluster',server='...',certificate_authority_data='...',)# Add a user for that clusterk.add_user(user='me')# Add a context to map the user to the clusterk.add_context(name='mycontext',cluster_name='mycluster',user_name='me')# Commit change to the file.k.close()
开发
从源代码下载并安装此repo,然后移动到基本目录。
git clone https://github.com/Zsailer/kubeconf
cd kubeconf
如果使用pipenv,则可以安装开发版本:
pipenv install --dev
否则,可以使用pip安装开发版本
pip install -e .
许可
此项目中的代码是在麻省理工学院许可下授权的。