OpenStack K8s MCP
用于查询OpenStack Kubernetes操作员的模型上下文协议(MCP)服务器。此工具提供对Kubernetes集群中OpenStackVersion CRD的MCP兼容访问。
特性
- get_openstack_version:查询OpenStackVersion CRD以检索:
- 目标版本 - 可用版本 - 已部署版本 - 状态条件
- update_openstack_version:修补OpenStackVersion CRD的targetVersion和可选的customContainerImages字段
- wait_openstack_version:等待OpenStackVersion CRD满足特定条件
- get_openstack_control平面图:查询OpenStackControlPlane CRD以检索规格和状态信息
- 验证压力跟踪控制平面:验证OpenStackControlPlane CRD上的所有条件是否处于就绪状态
- create_dataplane_部署:创建OpenStackDataplaneDeployment CR以在数据平面节点上部署服务
- get_dataplane_部署:查询OpenStackDataplaneDeployment CRD以检索规格和状态信息
- list_dataplane_部署:列出命名空间中的所有OpenStackDataplaneDeployment CR
- list_dataplane_节点集:列出命名空间中的所有OpenStackDataplaneNodeSet CR
- verify_penstack_taplane节点集:验证命名空间中所有OpenStackDataplaneNodeSet CR上的所有条件都处于就绪状态
先决条件
- 达到1.22或更高
- 访问安装了OpenStack运营商的Kubernetes集群
- 有效的kubeconfig或集群配置
安装
# Clone the repository
git clone
cd openstack-k8s-mcp
# Build the binary
go build -o openstack-k8s-mcp .用法
运行MCP服务器
服务器通过stdio按照MCP协议进行通信:
./openstack-k8s-mcpMCP工具:get_openstack_version
查询OpenStackVersion自定义资源:
参数:
namespace(可选):OpenStackVersion CR所在的Kubernetes命名空间。默认为openstack如果没有提供。name(可选):要查询的OpenStackVersion CR的名称。如果未提供,则自动发现命名空间中的第一个CR。
退货: JSON对象包含:
name:CR名称namespace:CR命名空间targetVersion:所需的OpenStack版本availableVersion:可用版本deployedVersion:当前部署的版本readyConditions:准备就绪的条件类型数组(状态:True)notReadyConditions:未就绪的条件类型数组customContainerImages:自定义容器图像(如果存在)
示例响应
{
"name": "openstack",
"namespace": "openstack",
"targetVersion": "0.3.0",
"availableVersion": "0.3.0",
"deployedVersion": "0.3.0",
"readyConditions": ["Ready", "Available"],
"notReadyConditions": []
}MCP工具:update_openstack_version
修补命名空间中第一个OpenStackVersion自定义资源的targetVersion和可选的customContainerImages字段:
参数:
namespace(可选):OpenStackVersion CR所在的Kubernetes命名空间。默认为openstack如果没有提供。targetVersion(必填):为OpenStackVersion CR设置的目标版本customContainerImages(可选):将服务名称映射到自定义容器映像URL。如果未提供,则不会修改customContainerImages。
退货: JSON对象包含:
name:CR名称namespace:CR命名空间spec.targetVersion:更新了目标OpenStack版本status.availableVersion:可用版本status.deployedVersion:当前部署的版本
示例响应
{
"name": "openstack",
"namespace": "openstack",
"spec": {
"targetVersion": "0.4.0"
},
"status": {
"availableVersion": "0.3.0",
"deployedVersion": "0.3.0"
}
}customContainerImages的示例用法
{
"namespace": "openstack",
"targetVersion": "0.4.0",
"customContainerImages": {
"nova": "quay.io/openstack-k8s-operators/nova-operator:v0.4.0",
"neutron": "quay.io/openstack-k8s-operators/neutron-operator:v0.4.0"
}
}MCP工具:wait_openstack_version
等待OpenStackVersion自定义资源满足特定条件:
参数:
namespace(可选):OpenStackVersion CR所在的Kubernetes命名空间。默认为openstack如果没有提供。name(可选):要等待的OpenStackVersion CR的名称。如果未提供,则自动发现命名空间中的第一个CR。condition(必填):等待的条件类型(例如,“就绪”、“可用”)timeout(可选):等待的最长时间(秒)。如果未提供,则默认为600秒。pollInterval(可选):轮询尝试之间的间隔(秒)。如果未提供,则默认为5秒。
退货: JSON对象包含:
name:CR名称namespace:CR命名空间condition:等待的条件类型met:布尔值,指示是否满足条件message:来自条件的状态消息reason:条件的原因
示例响应
{
"name": "openstack",
"namespace": "openstack",
"condition": "Ready",
"met": true,
"message": "All OpenStack components are ready",
"reason": "AllComponentsReady"
}MCP工具:get_openstack_control平面
查询OpenStackControlPlane自定义资源:
参数:
namespace(可选):OpenStackControlPlane CR所在的Kubernetes命名空间。默认为openstack如果没有提供。name(可选):要查询的OpenStackControlPlane CR的名称。如果未提供,则返回命名空间中找到的第一个CR。
退货: JSON对象包含:
name:CR名称namespace:CR命名空间spec:控制平面规范包括:
- 服务配置(新星、中子、煤渣、眩光等) - 数据库配置 - 消息队列配置 - 其他控制平面设置
status:控制平面状态包括:
- conditions:具有部署状态的条件对象数组 - 服务特定状态信息 - 其他可用的状态字段
示例响应
{
"name": "openstack",
"namespace": "openstack",
"spec": {
"secret": "osp-secret",
"storageClass": "local-storage",
"nova": {
"enabled": true,
"template": {
"secret": "osp-secret"
}
},
"neutron": {
"enabled": true,
"template": {
"secret": "osp-secret"
}
},
"cinder": {
"enabled": true,
"template": {
"cinderVolumes": {
"volume1": {
"storageClass": "local-storage"
}
}
}
}
},
"status": {
"conditions": [
{
"type": "Ready",
"status": "True",
"lastTransitionTime": "2025-01-15T10:30:00Z",
"reason": "AllServicesReady",
"message": "All OpenStack services are ready"
}
]
}
}MCP工具:验证_压力跟踪_控制平面
验证OpenStackControlPlane自定义资源上的所有条件是否处于就绪状态:
参数:
namespace(可选):OpenStackControlPlane CR所在的Kubernetes命名空间。默认为openstack如果没有提供。name(可选):要验证的OpenStackControlPlane CR的名称。如果未提供,则验证命名空间中找到的第一个CR。
退货: JSON对象包含:
name:CR名称namespace:CR命名空间allReady:布尔值,指示是否所有条件都已就绪totalConditions:条件总数readyConditions:准备就绪的条件类型字符串数组notReadyConditions:未就绪的条件对象数组,每个对象包含类型、状态、原因和消息
示例响应(全部就绪)
{
"name": "openstack",
"namespace": "openstack",
"allReady": true,
"totalConditions": 5,
"readyConditions": ["Ready", "Available", "Configured", "Deployed", "ServiceReady"],
"notReadyConditions": []
}示例响应(未就绪)
{
"name": "openstack",
"namespace": "openstack",
"allReady": false,
"totalConditions": 5,
"readyConditions": ["Configured", "Deployed"],
"notReadyConditions": [
{
"type": "Ready",
"status": "False",
"reason": "Deploying",
"message": "OpenStack services are being deployed"
},
{
"type": "Available",
"status": "False",
"reason": "Deploying",
"message": "Some services are not yet available"
}
]
}MCP工具:create_dataplane_deployment
创建OpenStackDataplaneDeployment自定义资源以在数据平面节点上部署服务:
参数:
namespace(可选):Kubernetes命名空间,将在其中创建OpenStackDataplaneDeployment CR。默认为openstack如果没有提供。name(必填):要创建的OpenStackDataplaneDeployment CR的名称(使用破折号/下划线,而不是点)spec(可选):作为JSON对象完成部署规范。可以包括节点集、服务覆盖、ansibleTag、ansibleLimit等。nodeSets(可选):要部署到的节点集名称数组。如果未提供且未给出规范,则自动发现命名空间中的所有节点集。servicesOverride(可选):覆盖部署默认服务的服务名称数组
退货: 成功消息,确认创建了具有指定节点集和可选服务覆盖的OpenStackDataplaneDeployment CR。
示例用法
基本部署到单个节点集:
{
"name": "my-deployment",
"namespace": "openstack",
"nodeSets": ["compute-nodes"]
}部署到具有服务覆盖的多个节点集:
{
"name": "my-deployment",
"namespace": "openstack",
"nodeSets": ["compute-nodes", "storage-nodes"],
"servicesOverride": ["nova", "neutron", "ovn"]
}MCP工具:get_dataplane_deployment
查询OpenStackDataplaneDeployment自定义资源以检索部署信息:
参数:
namespace(可选):OpenStackDataplaneDeployment CR所在的Kubernetes命名空间。默认为openstack如果没有提供。name(必填):要查询的OpenStackDataplaneDeployment CR的名称
退货: JSON对象包含:
name:CR名称namespace:CR命名空间spec:部署规范包括:
- nodeSets:节点集名称数组 - servicesOverride:服务名称数组(如果指定)
status:部署状态包括:
- conditions:具有部署进度和状态的条件对象数组 - nodeSetConditions:每个节点设置部署状态 - 其他可用的状态字段
示例响应
{
"name": "my-deployment",
"namespace": "openstack",
"spec": {
"nodeSets": ["compute-nodes"],
"servicesOverride": ["nova", "neutron"]
},
"status": {
"conditions": [
{
"type": "Ready",
"status": "True",
"lastTransitionTime": "2025-01-15T10:30:00Z",
"reason": "DeploymentComplete",
"message": "All nodeSets have been deployed successfully"
}
],
"nodeSetConditions": {
"compute-nodes": {
"Ready": {
"status": "True",
"message": "NodeSet deployment complete"
}
}
}
}
}MCP工具:list_dataplane_部署
列出命名空间中的所有OpenStackDataplaneDeployment自定义资源:
参数:
namespace(可选):OpenStackDataplaneDeployment CR所在的Kubernetes命名空间。默认为openstack如果没有提供。
退货: 包含以下对象的JSON数组:
name:部署CR名称namespace:部署CR命名空间spec:部署规范包括:
- nodeSets:节点集名称数组 - servicesOverride:服务名称数组(如果指定)
status:部署状态包括:
- conditions:条件对象数组 - nodeSetConditions:每个节点设置部署状态 - 其他可用的状态字段
示例响应
[
{
"name": "edpm-deployment",
"namespace": "openstack",
"spec": {
"nodeSets": ["compute-nodes", "storage-nodes"],
"servicesOverride": ["nova", "neutron", "ovn"]
},
"status": {
"conditions": [
{
"type": "Ready",
"status": "True",
"lastTransitionTime": "2025-01-15T10:30:00Z",
"reason": "DeploymentComplete",
"message": "All nodeSets have been deployed successfully"
}
],
"nodeSetConditions": {
"compute-nodes": {
"Ready": {
"status": "True",
"message": "NodeSet deployment complete"
}
},
"storage-nodes": {
"Ready": {
"status": "True",
"message": "NodeSet deployment complete"
}
}
}
}
},
{
"name": "upgrade-deployment",
"namespace": "openstack",
"spec": {
"nodeSets": ["compute-nodes"]
},
"status": {
"conditions": [
{
"type": "Ready",
"status": "False",
"lastTransitionTime": "2025-01-15T11:00:00Z",
"reason": "DeploymentInProgress",
"message": "Deployment in progress"
}
]
}
}
]MCP工具:list_dataplane_nodeset
列出命名空间中的所有OpenStackDataplaneNodeSet自定义资源:
参数:
namespace(可选):OpenStackDataplaneNodeSet CR所在的Kubernetes命名空间。默认为openstack如果没有提供。
退货: 包含以下对象的JSON数组:
name:NodeSet CR名称namespace:NodeSet CR命名空间spec:NodeSet规范包括:
- nodeTemplate:节点配置模板 - nodes:将节点名称映射到其配置 - services:要在nodeSet上部署的服务 - 其他规格字段
status:NodeSet状态包括:
- conditions:条件对象数组 - deploymentStatus:部署进度信息 - 其他可用的状态字段
示例响应
[
{
"name": "compute-nodes",
"namespace": "openstack",
"spec": {
"nodeTemplate": {
"ansibleSSHPrivateKeySecret": "dataplane-ansible-ssh-private-key-secret"
},
"nodes": {
"compute-0": {
"hostName": "compute-0",
"ansible": {
"ansibleHost": "192.168.1.10"
}
},
"compute-1": {
"hostName": "compute-1",
"ansible": {
"ansibleHost": "192.168.1.11"
}
}
},
"services": ["nova", "neutron", "ovn"]
},
"status": {
"conditions": [
{
"type": "Ready",
"status": "True",
"lastTransitionTime": "2025-01-15T10:30:00Z",
"message": "NodeSet is ready"
}
]
}
},
{
"name": "storage-nodes",
"namespace": "openstack",
"spec": {
"nodes": {
"storage-0": {
"hostName": "storage-0",
"ansible": {
"ansibleHost": "192.168.1.20"
}
}
},
"services": ["ceph"]
},
"status": {
"conditions": [
{
"type": "Ready",
"status": "True",
"message": "NodeSet is ready"
}
]
}
}
]MCP工具:验证_openstack_dataplannodesets
验证命名空间中所有OpenStackDataplaneNodeSet自定义资源上的所有条件是否处于就绪状态:
参数:
namespace(可选):OpenStackDataplaneNodeSet CR所在的Kubernetes命名空间。默认为openstack如果没有提供。
退货: JSON对象包含:
namespace:已检查的命名空间allReady:布尔值,指示是否所有节点集都已就绪totalNodeSets:命名空间中的NodeSet总数readyNodeSets:已准备好的NodeSet名称数组notReadyNodeSets:尚未就绪的NodeSet的NodeSet验证结果数组
每 notReadyNodeSets 条目包含:
name:节点集名称allReady:布尔值,指示是否所有条件都已就绪totalConditions:条件总数readyConditions:准备就绪的条件类型字符串数组notReadyConditions:具有类型、状态、原因和消息的条件对象数组
示例响应(全部就绪)
{
"namespace": "openstack",
"allReady": true,
"totalNodeSets": 2,
"readyNodeSets": ["compute-nodes", "controller-nodes"],
"notReadyNodeSets": []
}示例响应(未全部就绪)
{
"namespace": "openstack",
"allReady": false,
"totalNodeSets": 2,
"readyNodeSets": ["controller-nodes"],
"notReadyNodeSets": [
{
"name": "compute-nodes",
"allReady": false,
"totalConditions": 3,
"readyConditions": ["SetupReady"],
"notReadyConditions": [
{
"type": "DeploymentReady",
"status": "False",
"reason": "Deploying",
"message": "Deployment in progress"
},
{
"type": "Ready",
"status": "False",
"reason": "NotReady",
"message": "NodeSet is not ready"
}
]
}
]
}使用Claude Desktop进行配置
添加到您的Claude Desktop MCP设置中:
{
"mcpServers": {
"openstack-k8s": {
"command": "/path/to/openstack-k8s-mcp"
}
}
}发展
项目结构
main.go:MCP服务器实现client.go:Kubernetes客户端包装器go.mod:Go模块依赖关系
依赖项
github.com/mark3labs/mcp-go:MCP SDK for Gogithub.com/openstack-k8s-operators/openstack-operator/apis:OpenStack运算符API类型k8s.io/client-go:Kubernetes Go客户端k8s.io/apimachinery:Kubernetes API机器
许可证
麻省理工学院
