KubeKey Skill
Description
KubeKey is a tool for deploying Kubernetes clusters. This skill provides capabilities to check, install KubeKey, create and scale Kubernetes clusters, and view cluster configurations.
Capabilities
This skill enables the agent to:
- Check KubeKey installation: Verify if KubeKey is installed and check its version
- Install KubeKey: Download and install KubeKey tool with specified version
- Generate cluster configurations: Create KubeKey cluster configuration files based on user requirements, including:
- Kubernetes version selection
- CNI (Container Network Interface) plugin selection
- CRI (Container Runtime Interface) selection
- Network CIDR configuration
- Node role assignment
- Registry configuration
- Create Kubernetes clusters: Deploy new Kubernetes clusters using KubeKey configuration files
- Scale clusters: Add nodes using
kk add nodes or remove nodes using kk delete node from existing Kubernetes clusters
- Upgrade clusters: Upgrade Kubernetes and optionally KubeSphere to newer versions
- View cluster configurations: Display and analyze cluster installation configurations
Instructions
When the user needs to work with KubeKey or Kubernetes cluster management:
Checking KubeKey Installation
- Run the check script:
scripts/check_kubekey.sh
- The script will check if
kk command is available in PATH
- If installed, it will display the version
- If not installed, provide guidance on installation
Installing KubeKey
- Determine the desired version (default: latest)
- Run the install script:
scripts/install_kubekey.sh [VERSION]
- The script will:
- Download KubeKey from GitHub releases
- Extract and install to
/usr/local/bin/kk
- Verify installation
- Ensure the user has appropriate permissions (may require sudo)
Creating a Kubernetes Cluster Configuration
When the user wants to create a Kubernetes cluster, you need to gather requirements and generate a configuration file. Follow this process:
Step 1: Gather Cluster Requirements
Ask the user or infer from context the following information:
Essential Information:
- Node Information:
- IP addresses of all nodes
- SSH credentials (username, password, or SSH key path)
- Node roles (master/worker/etcd)
- Internal IP addresses (if different from external)
Kubernetes Configuration:
Optional Advanced Settings:
Image Registry:
- Private registry URL (if using private registry)
- Registry mirrors (for faster downloads in China)
- Insecure registries list
Proxy Mode:
iptables (default, simpler)
ipvs (better performance for large clusters)
Max Pods per Node:
- Default:
110
- Calculate: (available IPs in node CIDR) - 1
Node CIDR Mask Size:
- Default:
24
- Determines subnet size for each node
Step 2: Generate Configuration File
- Use the configuration template in
examples/cluster-config.yaml as a base
- Use the script
scripts/generate_config.sh to interactively generate a config, OR
- Manually create the YAML file with the following structure:
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
name: <cluster-name>
spec:
hosts:
- {name: <node-name>, address: <external-ip>, internalAddress: <internal-ip>, user: <ssh-user>, password: "<password>"}
# Or use privateKeyPath for SSH key authentication
# - {name: <node-name>, address: <external-ip>, internalAddress: <internal-ip>, user: <ssh-user>, privateKeyPath: "<key-path>"}
roleGroups:
etcd:
- <master-node-names>
master:
- <master-node-names>
worker:
- <worker-node-names>
controlPlaneEndpoint:
domain: <lb-domain-or-empty>
address: ""
port: 6443
kubernetes:
version: <k8s-version> # e.g., v1.28.0
imageRepo: kubesphere
clusterName: cluster.local
masqueradeAll: false
maxPods: 110
nodeCidrMaskSize: 24
proxyMode: ipvs # or iptables
network:
plugin: <cni-plugin> # calico, flannel, cilium, etc.
kubePodsCIDR: <pod-cidr>
kubeServiceCIDR: <service-cidr>
multusCNI:
enabled: false
registry:
privateRegistry: "<registry-url>"
namespaceOverride: ""
registryMirrors: []
insecureRegistries: []
addons: []
Step 3: Validate Configuration
- Check YAML syntax is valid
- Verify IP addresses are reachable
- Ensure CIDR ranges don't overlap
- Confirm SSH credentials are correct
- Validate node roles are assigned correctly
Step 4: Create the Cluster
- Run:
kk create cluster -f <config-file>
- Monitor the installation process
- Handle any errors that occur
- Verify cluster is running:
kubectl get nodes
Configuration Examples by Use Case
Small Development Cluster (3 nodes, 1 master + 2 workers):
- Version: v1.28.0
- CNI: flannel (simpler)
- CRI: containerd
- Pod CIDR: 10.233.64.0/18
- Service CIDR: 10.233.0.0/18
Production Cluster (5+ nodes, HA):
- Version: v1.28.0 (or latest stable)
- CNI: calico (network policies, production-ready)
- CRI: containerd
- Proxy Mode: ipvs
- Control Plane Endpoint: Load balancer required
- Pod CIDR: 10.233.64.0/18 or larger
- Service CIDR: 10.233.0.0/18
High Performance Cluster:
- CNI: cilium (eBPF-based)
- CRI: containerd
- Proxy Mode: ipvs
- Larger CIDR ranges if needed
Scaling a Cluster
KubeKey uses separate commands for adding and deleting nodes:
Adding Nodes to a Cluster
Get current cluster configuration:
kk create config --from-cluster -f current-cluster.yaml
This generates a configuration file with all existing nodes from the current cluster.
Note: The --from-cluster flag is used to generate a config file from an existing cluster. For new clusters, create the config file manually or use scripts/generate_config.sh.
Edit the configuration file:
- Add new node information to
spec.hosts section
- Add new node names to appropriate
roleGroups (worker, master, etcd)
- Example:
spec:
hosts:
- {name: master1, address: 192.168.0.2, ...} # existing
- {name: worker1, address: 192.168.0.3, ...} # existing
- {name: worker2, address: 192.168.0.4, ...} # existing
- {name: worker3, address: 192.168.0.5, ...} # NEW node
roleGroups:
worker:
- worker1
- worker2
- worker3 # NEW node added
Add nodes:
kk add nodes -f current-cluster.yaml
Or use the script: scripts/add_nodes.sh current-cluster.yaml
Verify: kubectl get nodes
Deleting Nodes from a Cluster
Drain the node (recommended before deletion):
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
This safely evicts all pods from the node.
Delete the node:
kk delete node <node-name>
Or use the script: scripts/delete_node.sh <node-name>
Verify: kubectl get nodes
Important Notes:
- When adding nodes, the config file must include ALL existing nodes plus new ones
- Before deleting a node, ensure workloads are migrated or stopped
- Master nodes should not be deleted unless you have HA setup (3+ masters)
Upgrading a Cluster
KubeKey supports upgrading Kubernetes clusters and optionally KubeSphere. Follow these steps:
Prerequisites for Upgrade
- Backup: Ensure all important data is backed up
- Node Time Sync: All nodes must have synchronized time (use NTP)
- Resource Check: Verify nodes have sufficient resources
- Version Compatibility: Check compatibility between current and target versions
- Low Traffic Period: Perform upgrade during low-traffic periods if possible
Upgrade Process
Check Current Versions:
kubectl version --short
kk version
Determine Target Version:
- Kubernetes: Typically upgrade one minor version at a time (e.g., v1.27.x → v1.28.x)
- KubeSphere: Check compatibility with target Kubernetes version
- Common upgrade paths:
- v1.26.x → v1.27.x → v1.28.x
- v1.27.x → v1.28.x
Upgrade Options:
Option A: Interactive Upgrade (Recommended)
./scripts/upgrade_cluster.sh
The script will prompt for:
- Target Kubernetes version
- Whether to upgrade KubeSphere
- Target KubeSphere version (if applicable)
Option B: Command Line with Options
# Upgrade Kubernetes only
./scripts/upgrade_cluster.sh --k8s-version v1.28.0
# Upgrade Kubernetes and KubeSphere
./scripts/upgrade_cluster.sh --k8s-version v1.28.0 --ks-version v3.4.1 --with-kubesphere
# Using configuration file
./scripts/upgrade_cluster.sh --config cluster-config.yaml --k8s-version v1.28.0
Option C: Direct KubeKey Command
# Kubernetes only
kk upgrade --with-kubernetes --kubernetes-version v1.28.0
# Kubernetes + KubeSphere
kk upgrade --with-kubernetes --with-kubesphere \
--kubernetes-version v1.28.0 \
--kubesphere-version v3.4.1
Monitor Upgrade Progress:
- The upgrade process typically takes 30-60 minutes
- Monitor node status:
kubectl get nodes -w
- Check pod status:
kubectl get pods -A
- Review KubeKey logs if issues occur
Verify Upgrade:
kubectl version --short
kubectl get nodes
kubectl get pods -A
Upgrade Considerations
Kubernetes Version Selection:
- Upgrade one minor version at a time (e.g., 1.27 → 1.28, not 1.26 → 1.28)
- Check Kubernetes release notes for breaking changes
- Verify CNI plugin compatibility with new version
- Ensure CRI version is compatible
KubeSphere Upgrade:
- Only upgrade if KubeSphere is installed
- Check KubeSphere compatibility matrix with Kubernetes versions
- Review KubeSphere upgrade documentation for specific versions
- Some KubeSphere features may require specific Kubernetes versions
Rollback:
- KubeKey does not provide automatic rollback
- Manual rollback requires restoring from backups
- Always backup before upgrading
Common Issues:
- Node time synchronization errors → Ensure NTP is configured
- Insufficient resources → Check node CPU/memory/disk
- Network connectivity issues → Verify all nodes are reachable
- Pod eviction failures → Drain nodes manually if needed
Viewing Cluster Configuration
- If a configuration file exists, display its contents
- Explain the key configuration parameters:
- Kubernetes version
- Node specifications (master/worker nodes)
- Network plugins
- Storage configurations
- Authentication settings
- Use
kk version to check KubeKey version and cluster info
Prerequisites
- Linux or macOS system
- SSH access to target nodes (for cluster deployment)
- Root or sudo privileges (for installation)
- Network connectivity to download KubeKey and container images
Common Workflows
Initial Setup
- Check if KubeKey is installed
- If not, install KubeKey
- Verify installation with
kk version
Creating a New Cluster
- Review example configuration
- Create cluster configuration file
- Validate configuration
- Deploy cluster
- Verify cluster status
Adding Nodes to Existing Cluster
- Get current cluster config:
kk create config --from-cluster -f config.yaml
- Edit config file to add new nodes to
spec.hosts and roleGroups
- Run:
kk add nodes -f config.yaml (or use scripts/add_nodes.sh)
- Verify new nodes joined:
kubectl get nodes
Removing Nodes from Cluster
- Drain the node:
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
- Delete the node:
kk delete node <node-name> (or use scripts/delete_node.sh)
- Verify node removed:
kubectl get nodes
Upgrading Cluster
- Check current versions:
kubectl version --short
- Determine target Kubernetes version (upgrade one minor version at a time)
- Run upgrade:
./scripts/upgrade_cluster.sh (interactive) or with options
- Monitor progress and verify:
kubectl get nodes and kubectl version
Error Handling
- If KubeKey is not found, suggest installation
- If configuration file is invalid, help user fix YAML syntax
- If cluster creation fails, check:
- Network connectivity
- SSH access to nodes
- Node prerequisites (Docker, etc.)
- Disk space and resources
- If adding nodes fails, verify:
- Config file includes ALL existing nodes plus new ones
- New nodes meet requirements (CPU, memory, disk)
- SSH access to new nodes
- Network connectivity
- New nodes are not already in the cluster
- If deleting nodes fails, verify:
- Node name is correct
- Node is not a critical master (unless HA setup)
- Workloads have been drained/migrated
- If upgrade fails, check:
- Node time synchronization (NTP)
- Sufficient resources on all nodes
- Version compatibility (upgrade one minor version at a time)
- Network connectivity to all nodes
- CNI/CRI compatibility with target Kubernetes version
Configuration Reference
For detailed information about all configuration options, see:
references/config-options.md - Complete reference of all configuration options
examples/cluster-config.yaml - Example configuration file
scripts/generate_config.sh - Interactive configuration generator
Key configuration decisions:
- Kubernetes Version: Latest stable (v1.28.x) unless compatibility required
- CNI Plugin: Calico for production, Flannel for simple deployments
- CRI: Containerd (recommended) or Docker
- Proxy Mode: iptables for small/medium, ipvs for large clusters
- CIDR Ranges: Ensure no overlaps, use /18 for pods and services typically
References
For detailed technical references, see:
- KubeKey Reference Guide - Comprehensive links to KubeKey, Kubernetes, CNI plugins, and related documentation
- KubeKey Commands Reference - Quick reference for all kk commands
- Configuration Options - Detailed configuration options reference
- Example Configuration - Sample cluster configuration file
Key resources:
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: hb-chen-opskills-kubekey3description: KubeKey Skill4---56# KubeKey Skill78## Description910KubeKey is a tool for deploying Kubernetes clusters. This skill provides capabilities to check, install KubeKey, create and scale Kubernetes clusters, and view cluster configurations.1112## Capabilities1314This skill enables the agent to:15161. **Check KubeKey installation**: Verify if KubeKey is installed and check its version172. **Install KubeKey**: Download and install KubeKey tool with specified version183. **Generate cluster configurations**: Create KubeKey cluster configuration files based on user requirements, including:19 - Kubernetes version selection20 - CNI (Container Network Interface) plugin selection21 - CRI (Container Runtime Interface) selection22 - Network CIDR configuration23 - Node role assignment24 - Registry configuration254. **Create Kubernetes clusters**: Deploy new Kubernetes clusters using KubeKey configuration files265. **Scale clusters**: Add nodes using `kk add nodes` or remove nodes using `kk delete node` from existing Kubernetes clusters276. **Upgrade clusters**: Upgrade Kubernetes and optionally KubeSphere to newer versions287. **View cluster configurations**: Display and analyze cluster installation configurations2930## Instructions3132When the user needs to work with KubeKey or Kubernetes cluster management:3334### Checking KubeKey Installation35361. Run the check script: `scripts/check_kubekey.sh`372. The script will check if `kk` command is available in PATH383. If installed, it will display the version394. If not installed, provide guidance on installation4041### Installing KubeKey42431. Determine the desired version (default: latest)442. Run the install script: `scripts/install_kubekey.sh [VERSION]`453. The script will:46 - Download KubeKey from GitHub releases47 - Extract and install to `/usr/local/bin/kk`48 - Verify installation494. Ensure the user has appropriate permissions (may require sudo)5051### Creating a Kubernetes Cluster Configuration5253When the user wants to create a Kubernetes cluster, you need to gather requirements and generate a configuration file. Follow this process:5455#### Step 1: Gather Cluster Requirements5657Ask the user or infer from context the following information:5859**Essential Information:**60- **Node Information**: 61 - IP addresses of all nodes62 - SSH credentials (username, password, or SSH key path)63 - Node roles (master/worker/etcd)64 - Internal IP addresses (if different from external)65 66**Kubernetes Configuration:**67- **Kubernetes Version**: 68 - Common versions: v1.28.x, v1.27.x, v1.26.x, v1.25.x69 - If not specified, recommend latest stable (v1.28.x)70 - Format: `v1.28.0` (with 'v' prefix)71 72- **Container Runtime Interface (CRI)**:73 - Options: `docker`, `containerd`, `cri-o`, `isula`74 - Default: `containerd` (recommended for newer K8s versions)75 - Docker: Traditional, widely used76 - Containerd: Lightweight, CNCF standard77 78- **Network Plugin (CNI)**:79 - Options: `calico`, `flannel`, `cilium`, `kube-ovn`, `weave`80 - **Calico**: Best for production, supports network policies, BGP routing81 - **Flannel**: Simple, good for small clusters82 - **Cilium**: eBPF-based, high performance83 - **Kube-OVN**: Advanced networking features84 - **Weave**: Simple, automatic mesh networking85 - Default: `calico` (if not specified)86 87- **Pod CIDR**: 88 - Default: `10.233.64.0/18` (if not specified)89 - Should not overlap with service CIDR90 - Calculate based on expected pod count: `/18` = ~16k pods, `/16` = ~65k pods91 92- **Service CIDR**: 93 - Default: `10.233.0.0/18` (if not specified)94 - Should not overlap with pod CIDR or node networks95 96- **Control Plane Endpoint**:97 - Load balancer domain or IP (for HA)98 - Or leave empty for single master99 - Port: typically `6443`100101**Optional Advanced Settings:**102- **Image Registry**: 103 - Private registry URL (if using private registry)104 - Registry mirrors (for faster downloads in China)105 - Insecure registries list106 107- **Proxy Mode**: 108 - `iptables` (default, simpler)109 - `ipvs` (better performance for large clusters)110 111- **Max Pods per Node**: 112 - Default: `110`113 - Calculate: (available IPs in node CIDR) - 1114 115- **Node CIDR Mask Size**: 116 - Default: `24`117 - Determines subnet size for each node118119#### Step 2: Generate Configuration File1201211. Use the configuration template in `examples/cluster-config.yaml` as a base1222. Use the script `scripts/generate_config.sh` to interactively generate a config, OR1233. Manually create the YAML file with the following structure:124125```yaml126apiVersion: kubekey.kubesphere.io/v1alpha2127kind: Cluster128metadata:129 name: <cluster-name>130spec:131 hosts:132 - {name: <node-name>, address: <external-ip>, internalAddress: <internal-ip>, user: <ssh-user>, password: "<password>"}133 # Or use privateKeyPath for SSH key authentication134 # - {name: <node-name>, address: <external-ip>, internalAddress: <internal-ip>, user: <ssh-user>, privateKeyPath: "<key-path>"}135 roleGroups:136 etcd:137 - <master-node-names>138 master:139 - <master-node-names>140 worker:141 - <worker-node-names>142 controlPlaneEndpoint:143 domain: <lb-domain-or-empty>144 address: ""145 port: 6443146 kubernetes:147 version: <k8s-version> # e.g., v1.28.0148 imageRepo: kubesphere149 clusterName: cluster.local150 masqueradeAll: false151 maxPods: 110152 nodeCidrMaskSize: 24153 proxyMode: ipvs # or iptables154 network:155 plugin: <cni-plugin> # calico, flannel, cilium, etc.156 kubePodsCIDR: <pod-cidr>157 kubeServiceCIDR: <service-cidr>158 multusCNI:159 enabled: false160 registry:161 privateRegistry: "<registry-url>"162 namespaceOverride: ""163 registryMirrors: []164 insecureRegistries: []165 addons: []166```167168#### Step 3: Validate Configuration1691701. Check YAML syntax is valid1712. Verify IP addresses are reachable1723. Ensure CIDR ranges don't overlap1734. Confirm SSH credentials are correct1745. Validate node roles are assigned correctly175176#### Step 4: Create the Cluster1771781. Run: `kk create cluster -f <config-file>`1792. Monitor the installation process1803. Handle any errors that occur1814. Verify cluster is running: `kubectl get nodes`182183#### Configuration Examples by Use Case184185**Small Development Cluster (3 nodes, 1 master + 2 workers):**186- Version: v1.28.0187- CNI: flannel (simpler)188- CRI: containerd189- Pod CIDR: 10.233.64.0/18190- Service CIDR: 10.233.0.0/18191192**Production Cluster (5+ nodes, HA):**193- Version: v1.28.0 (or latest stable)194- CNI: calico (network policies, production-ready)195- CRI: containerd196- Proxy Mode: ipvs197- Control Plane Endpoint: Load balancer required198- Pod CIDR: 10.233.64.0/18 or larger199- Service CIDR: 10.233.0.0/18200201**High Performance Cluster:**202- CNI: cilium (eBPF-based)203- CRI: containerd204- Proxy Mode: ipvs205- Larger CIDR ranges if needed206207### Scaling a Cluster208209KubeKey uses separate commands for adding and deleting nodes:210211#### Adding Nodes to a Cluster2122131. **Get current cluster configuration**:214 ```bash215 kk create config --from-cluster -f current-cluster.yaml216 ```217 This generates a configuration file with all existing nodes from the current cluster.218 219 **Note**: The `--from-cluster` flag is used to generate a config file from an existing cluster. For new clusters, create the config file manually or use `scripts/generate_config.sh`.2202212. **Edit the configuration file**:222 - Add new node information to `spec.hosts` section223 - Add new node names to appropriate `roleGroups` (worker, master, etcd)224 - Example:225 ```yaml226 spec:227 hosts:228 - {name: master1, address: 192.168.0.2, ...} # existing229 - {name: worker1, address: 192.168.0.3, ...} # existing230 - {name: worker2, address: 192.168.0.4, ...} # existing231 - {name: worker3, address: 192.168.0.5, ...} # NEW node232 roleGroups:233 worker:234 - worker1235 - worker2236 - worker3 # NEW node added237 ```2382393. **Add nodes**:240 ```bash241 kk add nodes -f current-cluster.yaml242 ```243 Or use the script: `scripts/add_nodes.sh current-cluster.yaml`2442454. **Verify**: `kubectl get nodes`246247#### Deleting Nodes from a Cluster2482491. **Drain the node** (recommended before deletion):250 ```bash251 kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data252 ```253 This safely evicts all pods from the node.2542552. **Delete the node**:256 ```bash257 kk delete node <node-name>258 ```259 Or use the script: `scripts/delete_node.sh <node-name>`2602613. **Verify**: `kubectl get nodes`262263**Important Notes**:264- When adding nodes, the config file must include ALL existing nodes plus new ones265- Before deleting a node, ensure workloads are migrated or stopped266- Master nodes should not be deleted unless you have HA setup (3+ masters)267268### Upgrading a Cluster269270KubeKey supports upgrading Kubernetes clusters and optionally KubeSphere. Follow these steps:271272#### Prerequisites for Upgrade2732741. **Backup**: Ensure all important data is backed up2752. **Node Time Sync**: All nodes must have synchronized time (use NTP)2763. **Resource Check**: Verify nodes have sufficient resources2774. **Version Compatibility**: Check compatibility between current and target versions2785. **Low Traffic Period**: Perform upgrade during low-traffic periods if possible279280#### Upgrade Process2812821. **Check Current Versions**:283 ```bash284 kubectl version --short285 kk version286 ```2872882. **Determine Target Version**:289 - Kubernetes: Typically upgrade one minor version at a time (e.g., v1.27.x → v1.28.x)290 - KubeSphere: Check compatibility with target Kubernetes version291 - Common upgrade paths:292 - v1.26.x → v1.27.x → v1.28.x293 - v1.27.x → v1.28.x2942953. **Upgrade Options**:296297 **Option A: Interactive Upgrade (Recommended)**298 ```bash299 ./scripts/upgrade_cluster.sh300 ```301 The script will prompt for:302 - Target Kubernetes version303 - Whether to upgrade KubeSphere304 - Target KubeSphere version (if applicable)305306 **Option B: Command Line with Options**307 ```bash308 # Upgrade Kubernetes only309 ./scripts/upgrade_cluster.sh --k8s-version v1.28.0310 311 # Upgrade Kubernetes and KubeSphere312 ./scripts/upgrade_cluster.sh --k8s-version v1.28.0 --ks-version v3.4.1 --with-kubesphere313 314 # Using configuration file315 ./scripts/upgrade_cluster.sh --config cluster-config.yaml --k8s-version v1.28.0316 ```317318 **Option C: Direct KubeKey Command**319 ```bash320 # Kubernetes only321 kk upgrade --with-kubernetes --kubernetes-version v1.28.0322 323 # Kubernetes + KubeSphere324 kk upgrade --with-kubernetes --with-kubesphere \325 --kubernetes-version v1.28.0 \326 --kubesphere-version v3.4.1327 ```3283294. **Monitor Upgrade Progress**:330 - The upgrade process typically takes 30-60 minutes331 - Monitor node status: `kubectl get nodes -w`332 - Check pod status: `kubectl get pods -A`333 - Review KubeKey logs if issues occur3343355. **Verify Upgrade**:336 ```bash337 kubectl version --short338 kubectl get nodes339 kubectl get pods -A340 ```341342#### Upgrade Considerations343344**Kubernetes Version Selection**:345- Upgrade one minor version at a time (e.g., 1.27 → 1.28, not 1.26 → 1.28)346- Check Kubernetes release notes for breaking changes347- Verify CNI plugin compatibility with new version348- Ensure CRI version is compatible349350**KubeSphere Upgrade**:351- Only upgrade if KubeSphere is installed352- Check KubeSphere compatibility matrix with Kubernetes versions353- Review KubeSphere upgrade documentation for specific versions354- Some KubeSphere features may require specific Kubernetes versions355356**Rollback**:357- KubeKey does not provide automatic rollback358- Manual rollback requires restoring from backups359- Always backup before upgrading360361**Common Issues**:362- Node time synchronization errors → Ensure NTP is configured363- Insufficient resources → Check node CPU/memory/disk364- Network connectivity issues → Verify all nodes are reachable365- Pod eviction failures → Drain nodes manually if needed366367### Viewing Cluster Configuration3683691. If a configuration file exists, display its contents3702. Explain the key configuration parameters:371 - Kubernetes version372 - Node specifications (master/worker nodes)373 - Network plugins374 - Storage configurations375 - Authentication settings3763. Use `kk version` to check KubeKey version and cluster info377378## Prerequisites379380- Linux or macOS system381- SSH access to target nodes (for cluster deployment)382- Root or sudo privileges (for installation)383- Network connectivity to download KubeKey and container images384385## Common Workflows386387### Initial Setup3881. Check if KubeKey is installed3892. If not, install KubeKey3903. Verify installation with `kk version`391392### Creating a New Cluster3931. Review example configuration3942. Create cluster configuration file3953. Validate configuration3964. Deploy cluster3975. Verify cluster status398399### Adding Nodes to Existing Cluster4001. Get current cluster config: `kk create config --from-cluster -f config.yaml`4012. Edit config file to add new nodes to `spec.hosts` and `roleGroups`4023. Run: `kk add nodes -f config.yaml` (or use `scripts/add_nodes.sh`)4034. Verify new nodes joined: `kubectl get nodes`404405### Removing Nodes from Cluster4061. Drain the node: `kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data`4072. Delete the node: `kk delete node <node-name>` (or use `scripts/delete_node.sh`)4083. Verify node removed: `kubectl get nodes`409410### Upgrading Cluster4111. Check current versions: `kubectl version --short`4122. Determine target Kubernetes version (upgrade one minor version at a time)4133. Run upgrade: `./scripts/upgrade_cluster.sh` (interactive) or with options4144. Monitor progress and verify: `kubectl get nodes` and `kubectl version`415416## Error Handling417418- If KubeKey is not found, suggest installation419- If configuration file is invalid, help user fix YAML syntax420- If cluster creation fails, check:421 - Network connectivity422 - SSH access to nodes423 - Node prerequisites (Docker, etc.)424 - Disk space and resources425- If adding nodes fails, verify:426 - Config file includes ALL existing nodes plus new ones427 - New nodes meet requirements (CPU, memory, disk)428 - SSH access to new nodes429 - Network connectivity430 - New nodes are not already in the cluster431- If deleting nodes fails, verify:432 - Node name is correct433 - Node is not a critical master (unless HA setup)434 - Workloads have been drained/migrated435- If upgrade fails, check:436 - Node time synchronization (NTP)437 - Sufficient resources on all nodes438 - Version compatibility (upgrade one minor version at a time)439 - Network connectivity to all nodes440 - CNI/CRI compatibility with target Kubernetes version441442## Configuration Reference443444For detailed information about all configuration options, see:445- `references/config-options.md` - Complete reference of all configuration options446- `examples/cluster-config.yaml` - Example configuration file447- `scripts/generate_config.sh` - Interactive configuration generator448449Key configuration decisions:450- **Kubernetes Version**: Latest stable (v1.28.x) unless compatibility required451- **CNI Plugin**: Calico for production, Flannel for simple deployments452- **CRI**: Containerd (recommended) or Docker453- **Proxy Mode**: iptables for small/medium, ipvs for large clusters454- **CIDR Ranges**: Ensure no overlaps, use /18 for pods and services typically455456## References457458For detailed technical references, see:459- [KubeKey Reference Guide](references/reference.md) - Comprehensive links to KubeKey, Kubernetes, CNI plugins, and related documentation460- [KubeKey Commands Reference](references/commands.md) - Quick reference for all kk commands461- [Configuration Options](references/config-options.md) - Detailed configuration options reference462- [Example Configuration](examples/cluster-config.yaml) - Sample cluster configuration file463464Key resources:465- KubeKey GitHub: https://github.com/kubesphere/kubekey466- KubeKey Documentation: https://kubesphere.io/docs/installing-on-linux/introduction/kubekey/467- Kubernetes Documentation: https://kubernetes.io/docs/468469---470> Converted and distributed by [TomeVault](https://tomevault.io/claim/hb-chen) — claim your Tome and manage your conversions.471<!-- tomevault:4.0:skill_md:2026-04-11 -->