k8s-multicluster

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Multi-Cluster Kubernetes Management

多Kubernetes集群管理

Cross-cluster operations and context management using kubectl-mcp-server's multi-cluster support.
借助kubectl-mcp-server的多集群支持实现跨集群操作与上下文管理。

When to Apply

适用场景

Use this skill when:
  • User mentions: "cluster", "context", "multi-cluster", "cross-cluster"
  • Operations: switching contexts, comparing clusters, federated deployments
  • Keywords: "different environment", "production vs staging", "all clusters"
在以下场景使用此技能:
  • 用户提及:"cluster"、"context"、"multi-cluster"、"cross-cluster"
  • 操作场景:切换上下文、对比集群、联邦部署
  • 关键词:"不同环境"、"生产环境 vs 预发布环境"、"所有集群"

Priority Rules

优先级规则

PriorityRuleImpactTools
1Always specify context for prodCRITICAL
context
parameter
2List contexts before switchingHIGH
list_contexts_tool
3Compare before promotingMEDIUM
compare_namespaces
4Use naming conventionsLOW
prod-*
,
staging-*
优先级规则影响级别工具
1针对生产环境必须指定上下文关键
context
参数
2切换前先列出所有上下文
list_contexts_tool
3升级前先进行对比
compare_namespaces
4使用命名规范
prod-*
,
staging-*

Quick Reference

快速参考

TaskToolExample
List contexts
list_contexts_tool
list_contexts_tool()
View kubeconfig
kubeconfig_view
kubeconfig_view()
List CAPI clusters
capi_clusters_list_tool
capi_clusters_list_tool(namespace)
Get CAPI kubeconfig
capi_cluster_kubeconfig_tool
capi_cluster_kubeconfig_tool(name, namespace)
任务工具示例
列出上下文
list_contexts_tool
list_contexts_tool()
查看kubeconfig
kubeconfig_view
kubeconfig_view()
列出CAPI集群
capi_clusters_list_tool
capi_clusters_list_tool(namespace)
获取CAPI kubeconfig
capi_cluster_kubeconfig_tool
capi_cluster_kubeconfig_tool(name, namespace)

Context Management

上下文管理

List Available Contexts

列出可用上下文

python
list_contexts_tool()
python
list_contexts_tool()

View Current Context

查看当前上下文

python
kubeconfig_view()
python
kubeconfig_view()

Switch Context

切换上下文

CLI:
kubectl-mcp-server context <context-name>
CLI:
kubectl-mcp-server context <context-name>

Cross-Cluster Operations

跨集群操作

All kubectl-mcp-server tools support the
context
parameter:
python
get_pods(namespace="default", context="production-cluster")

get_pods(namespace="default", context="staging-cluster")
所有kubectl-mcp-server工具均支持
context
参数:
python
get_pods(namespace="default", context="production-cluster")

get_pods(namespace="default", context="staging-cluster")

Common Multi-Cluster Patterns

常见多集群模式

Compare Environments

对比环境

python
compare_namespaces(
    namespace1="production",
    namespace2="staging",
    resource_type="deployment",
    context="production-cluster"
)
python
compare_namespaces(
    namespace1="production",
    namespace2="staging",
    resource_type="deployment",
    context="production-cluster"
)

Parallel Queries

并行查询

Query multiple clusters simultaneously:
python
get_pods(namespace="app", context="prod-us-east")
get_pods(namespace="app", context="prod-eu-west")

get_pods(namespace="app", context="development")
同时查询多个集群:
python
get_pods(namespace="app", context="prod-us-east")
get_pods(namespace="app", context="prod-eu-west")

get_pods(namespace="app", context="development")

Cross-Cluster Health Check

跨集群健康检查

python
for context in ["prod-1", "prod-2", "staging"]:
    get_nodes(context=context)
    get_pods(namespace="kube-system", context=context)
python
for context in ["prod-1", "prod-2", "staging"]:
    get_nodes(context=context)
    get_pods(namespace="kube-system", context=context)

Cluster API (CAPI) Management

Cluster API (CAPI) 管理

For managing cluster lifecycle:
用于管理集群生命周期:

List Managed Clusters

列出托管集群

python
capi_clusters_list_tool(namespace="capi-system")
python
capi_clusters_list_tool(namespace="capi-system")

Get Cluster Details

获取集群详情

python
capi_cluster_get_tool(name="prod-cluster", namespace="capi-system")
python
capi_cluster_get_tool(name="prod-cluster", namespace="capi-system")

Get Workload Cluster Kubeconfig

获取工作负载集群Kubeconfig

python
capi_cluster_kubeconfig_tool(name="prod-cluster", namespace="capi-system")
python
capi_cluster_kubeconfig_tool(name="prod-cluster", namespace="capi-system")

Machine Management

节点管理

python
capi_machines_list_tool(namespace="capi-system")
capi_machinedeployments_list_tool(namespace="capi-system")
python
capi_machines_list_tool(namespace="capi-system")
capi_machinedeployments_list_tool(namespace="capi-system")

Scale Cluster

扩缩容集群

python
capi_machinedeployment_scale_tool(
    name="prod-cluster-md-0",
    namespace="capi-system",
    replicas=5
)
See CONTEXT-SWITCHING.md for detailed patterns.
python
capi_machinedeployment_scale_tool(
    name="prod-cluster-md-0",
    namespace="capi-system",
    replicas=5
)
详细模式请参见CONTEXT-SWITCHING.md

Multi-Cluster Helm

多集群Helm管理

Deploy charts to specific clusters:
python
install_helm_chart(
    name="nginx",
    chart="bitnami/nginx",
    namespace="web",
    context="production-cluster"
)

list_helm_releases(
    namespace="web",
    context="staging-cluster"
)
将Chart部署到指定集群:
python
install_helm_chart(
    name="nginx",
    chart="bitnami/nginx",
    namespace="web",
    context="production-cluster"
)

list_helm_releases(
    namespace="web",
    context="staging-cluster"
)

Multi-Cluster GitOps

多集群GitOps

Flux Across Clusters

Flux跨集群管理

python
flux_kustomizations_list_tool(
    namespace="flux-system",
    context="cluster-1"
)

flux_reconcile_tool(
    kind="kustomization",
    name="apps",
    namespace="flux-system",
    context="cluster-2"
)
python
flux_kustomizations_list_tool(
    namespace="flux-system",
    context="cluster-1"
)

flux_reconcile_tool(
    kind="kustomization",
    name="apps",
    namespace="flux-system",
    context="cluster-2"
)

ArgoCD Across Clusters

ArgoCD跨集群管理

python
argocd_apps_list_tool(namespace="argocd", context="management-cluster")
python
argocd_apps_list_tool(namespace="argocd", context="management-cluster")

Federation Patterns

联邦模式

Secret Synchronization

密钥同步

python
get_secrets(namespace="app", context="source-cluster")

kubectl_apply(secret_manifest, namespace="app", context="target-cluster")
python
get_secrets(namespace="app", context="source-cluster")

kubectl_apply(secret_manifest, namespace="app", context="target-cluster")

Cross-Cluster Service Discovery

跨集群服务发现

With Cilium ClusterMesh or Istio multi-cluster:
python
cilium_nodes_list_tool(context="cluster-1")
istio_proxy_status_tool(context="cluster-2")
借助Cilium ClusterMesh或Istio多集群实现:
python
cilium_nodes_list_tool(context="cluster-1")
istio_proxy_status_tool(context="cluster-2")

Best Practices

最佳实践

  1. Naming Convention: Use descriptive context names (
    prod-us-east-1
    ,
    staging-eu-west-1
    )
  2. Access Control: Different kubeconfigs per environment
  3. Always Specify Context: Avoid accidental cross-cluster operations
  4. Cluster Groups: Organize by purpose (
    prod-*
    ,
    staging-*
    ,
    dev-*
    )
  1. 命名规范:使用描述性的上下文名称(
    prod-us-east-1
    ,
    staging-eu-west-1
  2. 访问控制:不同环境使用不同的kubeconfig
  3. 始终指定上下文:避免意外的跨集群操作
  4. 集群分组:按用途组织集群(
    prod-*
    ,
    staging-*
    ,
    dev-*

Related Skills

相关技能

  • k8s-troubleshoot - Debug across clusters
  • k8s-gitops - GitOps multi-cluster
  • k8s-capi - Cluster API management
  • k8s-troubleshoot - 跨集群调试
  • k8s-gitops - GitOps多集群管理
  • k8s-capi - Cluster API管理