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:
1---2name: kubekey3description: Manage Kubernetes clusters with KubeKey: check installation, install KubeKey, create clusters, scale nodes, upgrade clusters, and view configurations. Use when working with Kubernetes cluster deployment, management, or when the user mentions KubeKey, kk, or Kubernetes cluster operations.4license: MIT5---6
7# KubeKey Skill
8
9## Description
10
11KubeKey is a tool for deploying Kubernetes clusters. This skill provides capabilities to check, install KubeKey, create and scale Kubernetes clusters, and view cluster configurations.
12
13## Capabilities
14
15This skill enables the agent to:
16
171. **Check KubeKey installation**: Verify if KubeKey is installed and check its version
182. **Install KubeKey**: Download and install KubeKey tool with specified version
193. **Generate cluster configurations**: Create KubeKey cluster configuration files based on user requirements, including:
20 - Kubernetes version selection
21 - CNI (Container Network Interface) plugin selection
22 - CRI (Container Runtime Interface) selection
23 - Network CIDR configuration
24 - Node role assignment
25 - Registry configuration
264. **Create Kubernetes clusters**: Deploy new Kubernetes clusters using KubeKey configuration files
275. **Scale clusters**: Add nodes using `kk add nodes` or remove nodes using `kk delete node` from existing Kubernetes clusters
286. **Upgrade clusters**: Upgrade Kubernetes and optionally KubeSphere to newer versions
297. **View cluster configurations**: Display and analyze cluster installation configurations
30
31## Instructions
32
33When the user needs to work with KubeKey or Kubernetes cluster management:
34
35### Checking KubeKey Installation
36
371. Run the check script: `scripts/check_kubekey.sh`
382. The script will check if `kk` command is available in PATH
393. If installed, it will display the version
404. If not installed, provide guidance on installation
41
42### Installing KubeKey
43
441. Determine the desired version (default: latest)
452. Run the install script: `scripts/install_kubekey.sh [VERSION]`
463. The script will:
47 - Download KubeKey from GitHub releases
48 - Extract and install to `/usr/local/bin/kk`
49 - Verify installation
504. Ensure the user has appropriate permissions (may require sudo)
51
52### Creating a Kubernetes Cluster Configuration
53
54When the user wants to create a Kubernetes cluster, you need to gather requirements and generate a configuration file. Follow this process:
55
56#### Step 1: Gather Cluster Requirements
57
58Ask the user or infer from context the following information:
59
60**Essential Information:**
61- **Node Information**:
62 - IP addresses of all nodes
63 - SSH credentials (username, password, or SSH key path)
64 - Node roles (master/worker/etcd)
65 - Internal IP addresses (if different from external)
66
67**Kubernetes Configuration:**
68- **Kubernetes Version**:
69 - Common versions: v1.28.x, v1.27.x, v1.26.x, v1.25.x
70 - If not specified, recommend latest stable (v1.28.x)
71 - Format: `v1.28.0` (with 'v' prefix)
72
73- **Container Runtime Interface (CRI)**:
74 - Options: `docker`, `containerd`, `cri-o`, `isula`
75 - Default: `containerd` (recommended for newer K8s versions)
76 - Docker: Traditional, widely used
77 - Containerd: Lightweight, CNCF standard
78
79- **Network Plugin (CNI)**:
80 - Options: `calico`, `flannel`, `cilium`, `kube-ovn`, `weave`
81 - **Calico**: Best for production, supports network policies, BGP routing
82 - **Flannel**: Simple, good for small clusters
83 - **Cilium**: eBPF-based, high performance
84 - **Kube-OVN**: Advanced networking features
85 - **Weave**: Simple, automatic mesh networking
86 - Default: `calico` (if not specified)
87
88- **Pod CIDR**:
89 - Default: `10.233.64.0/18` (if not specified)
90 - Should not overlap with service CIDR
91 - Calculate based on expected pod count: `/18` = ~16k pods, `/16` = ~65k pods
92
93- **Service CIDR**:
94 - Default: `10.233.0.0/18` (if not specified)
95 - Should not overlap with pod CIDR or node networks
96
97- **Control Plane Endpoint**:
98 - Load balancer domain or IP (for HA)
99 - Or leave empty for single master
100 - Port: typically `6443`
101
102**Optional Advanced Settings:**
103- **Image Registry**:
104 - Private registry URL (if using private registry)
105 - Registry mirrors (for faster downloads in China)
106 - Insecure registries list
107
108- **Proxy Mode**:
109 - `iptables` (default, simpler)
110 - `ipvs` (better performance for large clusters)
111
112- **Max Pods per Node**:
113 - Default: `110`
114 - Calculate: (available IPs in node CIDR) - 1
115
116- **Node CIDR Mask Size**:
117 - Default: `24`
118 - Determines subnet size for each node
119
120#### Step 2: Generate Configuration File
121
1221. Use the configuration template in `examples/cluster-config.yaml` as a base
1232. Use the script `scripts/generate_config.sh` to interactively generate a config, OR
1243. Manually create the YAML file with the following structure:
125
126```yaml
127apiVersion: kubekey.kubesphere.io/v1alpha2
128kind: Cluster
129metadata:
130 name: <cluster-name>
131spec:
132 hosts:
133 - {name: <node-name>, address: <external-ip>, internalAddress: <internal-ip>, user: <ssh-user>, password: "<password>"}
134 # Or use privateKeyPath for SSH key authentication
135 # - {name: <node-name>, address: <external-ip>, internalAddress: <internal-ip>, user: <ssh-user>, privateKeyPath: "<key-path>"}
136 roleGroups:
137 etcd:
138 - <master-node-names>
139 master:
140 - <master-node-names>
141 worker:
142 - <worker-node-names>
143 controlPlaneEndpoint:
144 domain: <lb-domain-or-empty>
145 address: ""
146 port: 6443
147 kubernetes:
148 version: <k8s-version> # e.g., v1.28.0
149 imageRepo: kubesphere
150 clusterName: cluster.local
151 masqueradeAll: false
152 maxPods: 110
153 nodeCidrMaskSize: 24
154 proxyMode: ipvs # or iptables
155 network:
156 plugin: <cni-plugin> # calico, flannel, cilium, etc.
157 kubePodsCIDR: <pod-cidr>
158 kubeServiceCIDR: <service-cidr>
159 multusCNI:
160 enabled: false
161 registry:
162 privateRegistry: "<registry-url>"
163 namespaceOverride: ""
164 registryMirrors: []
165 insecureRegistries: []
166 addons: []
167```
168
169#### Step 3: Validate Configuration
170
1711. Check YAML syntax is valid
1722. Verify IP addresses are reachable
1733. Ensure CIDR ranges don't overlap
1744. Confirm SSH credentials are correct
1755. Validate node roles are assigned correctly
176
177#### Step 4: Create the Cluster
178
1791. Run: `kk create cluster -f <config-file>`
1802. Monitor the installation process
1813. Handle any errors that occur
1824. Verify cluster is running: `kubectl get nodes`
183
184#### Configuration Examples by Use Case
185
186**Small Development Cluster (3 nodes, 1 master + 2 workers):**
187- Version: v1.28.0
188- CNI: flannel (simpler)
189- CRI: containerd
190- Pod CIDR: 10.233.64.0/18
191- Service CIDR: 10.233.0.0/18
192
193**Production Cluster (5+ nodes, HA):**
194- Version: v1.28.0 (or latest stable)
195- CNI: calico (network policies, production-ready)
196- CRI: containerd
197- Proxy Mode: ipvs
198- Control Plane Endpoint: Load balancer required
199- Pod CIDR: 10.233.64.0/18 or larger
200- Service CIDR: 10.233.0.0/18
201
202**High Performance Cluster:**
203- CNI: cilium (eBPF-based)
204- CRI: containerd
205- Proxy Mode: ipvs
206- Larger CIDR ranges if needed
207
208### Scaling a Cluster
209
210KubeKey uses separate commands for adding and deleting nodes:
211
212#### Adding Nodes to a Cluster
213
2141. **Get current cluster configuration**:
215 ```bash
216 kk create config --from-cluster -f current-cluster.yaml
217 ```
218 This generates a configuration file with all existing nodes from the current cluster.
219
220 **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`.
221
2222. **Edit the configuration file**:
223 - Add new node information to `spec.hosts` section
224 - Add new node names to appropriate `roleGroups` (worker, master, etcd)
225 - Example:
226 ```yaml
227 spec:
228 hosts:
229 - {name: master1, address: 192.168.0.2, ...} # existing
230 - {name: worker1, address: 192.168.0.3, ...} # existing
231 - {name: worker2, address: 192.168.0.4, ...} # existing
232 - {name: worker3, address: 192.168.0.5, ...} # NEW node
233 roleGroups:
234 worker:
235 - worker1
236 - worker2
237 - worker3 # NEW node added
238 ```
239
2403. **Add nodes**:
241 ```bash
242 kk add nodes -f current-cluster.yaml
243 ```
244 Or use the script: `scripts/add_nodes.sh current-cluster.yaml`
245
2464. **Verify**: `kubectl get nodes`
247
248#### Deleting Nodes from a Cluster
249
2501. **Drain the node** (recommended before deletion):
251 ```bash
252 kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
253 ```
254 This safely evicts all pods from the node.
255
2562. **Delete the node**:
257 ```bash
258 kk delete node <node-name>
259 ```
260 Or use the script: `scripts/delete_node.sh <node-name>`
261
2623. **Verify**: `kubectl get nodes`
263
264**Important Notes**:
265- When adding nodes, the config file must include ALL existing nodes plus new ones
266- Before deleting a node, ensure workloads are migrated or stopped
267- Master nodes should not be deleted unless you have HA setup (3+ masters)
268
269### Upgrading a Cluster
270
271KubeKey supports upgrading Kubernetes clusters and optionally KubeSphere. Follow these steps:
272
273#### Prerequisites for Upgrade
274
2751. **Backup**: Ensure all important data is backed up
2762. **Node Time Sync**: All nodes must have synchronized time (use NTP)
2773. **Resource Check**: Verify nodes have sufficient resources
2784. **Version Compatibility**: Check compatibility between current and target versions
2795. **Low Traffic Period**: Perform upgrade during low-traffic periods if possible
280
281#### Upgrade Process
282
2831. **Check Current Versions**:
284 ```bash
285 kubectl version --short
286 kk version
287 ```
288
2892. **Determine Target Version**:
290 - Kubernetes: Typically upgrade one minor version at a time (e.g., v1.27.x → v1.28.x)
291 - KubeSphere: Check compatibility with target Kubernetes version
292 - Common upgrade paths:
293 - v1.26.x → v1.27.x → v1.28.x
294 - v1.27.x → v1.28.x
295
2963. **Upgrade Options**:
297
298 **Option A: Interactive Upgrade (Recommended)**
299 ```bash
300 ./scripts/upgrade_cluster.sh
301 ```
302 The script will prompt for:
303 - Target Kubernetes version
304 - Whether to upgrade KubeSphere
305 - Target KubeSphere version (if applicable)
306
307 **Option B: Command Line with Options**
308 ```bash
309 # Upgrade Kubernetes only
310 ./scripts/upgrade_cluster.sh --k8s-version v1.28.0
311
312 # Upgrade Kubernetes and KubeSphere
313 ./scripts/upgrade_cluster.sh --k8s-version v1.28.0 --ks-version v3.4.1 --with-kubesphere
314
315 # Using configuration file
316 ./scripts/upgrade_cluster.sh --config cluster-config.yaml --k8s-version v1.28.0
317 ```
318
319 **Option C: Direct KubeKey Command**
320 ```bash
321 # Kubernetes only
322 kk upgrade --with-kubernetes --kubernetes-version v1.28.0
323
324 # Kubernetes + KubeSphere
325 kk upgrade --with-kubernetes --with-kubesphere \
326 --kubernetes-version v1.28.0 \
327 --kubesphere-version v3.4.1
328 ```
329
3304. **Monitor Upgrade Progress**:
331 - The upgrade process typically takes 30-60 minutes
332 - Monitor node status: `kubectl get nodes -w`
333 - Check pod status: `kubectl get pods -A`
334 - Review KubeKey logs if issues occur
335
3365. **Verify Upgrade**:
337 ```bash
338 kubectl version --short
339 kubectl get nodes
340 kubectl get pods -A
341 ```
342
343#### Upgrade Considerations
344
345**Kubernetes Version Selection**:
346- Upgrade one minor version at a time (e.g., 1.27 → 1.28, not 1.26 → 1.28)
347- Check Kubernetes release notes for breaking changes
348- Verify CNI plugin compatibility with new version
349- Ensure CRI version is compatible
350
351**KubeSphere Upgrade**:
352- Only upgrade if KubeSphere is installed
353- Check KubeSphere compatibility matrix with Kubernetes versions
354- Review KubeSphere upgrade documentation for specific versions
355- Some KubeSphere features may require specific Kubernetes versions
356
357**Rollback**:
358- KubeKey does not provide automatic rollback
359- Manual rollback requires restoring from backups
360- Always backup before upgrading
361
362**Common Issues**:
363- Node time synchronization errors → Ensure NTP is configured
364- Insufficient resources → Check node CPU/memory/disk
365- Network connectivity issues → Verify all nodes are reachable
366- Pod eviction failures → Drain nodes manually if needed
367
368### Viewing Cluster Configuration
369
3701. If a configuration file exists, display its contents
3712. Explain the key configuration parameters:
372 - Kubernetes version
373 - Node specifications (master/worker nodes)
374 - Network plugins
375 - Storage configurations
376 - Authentication settings
3773. Use `kk version` to check KubeKey version and cluster info
378
379## Prerequisites
380
381- Linux or macOS system
382- SSH access to target nodes (for cluster deployment)
383- Root or sudo privileges (for installation)
384- Network connectivity to download KubeKey and container images
385
386## Common Workflows
387
388### Initial Setup
3891. Check if KubeKey is installed
3902. If not, install KubeKey
3913. Verify installation with `kk version`
392
393### Creating a New Cluster
3941. Review example configuration
3952. Create cluster configuration file
3963. Validate configuration
3974. Deploy cluster
3985. Verify cluster status
399
400### Adding Nodes to Existing Cluster
4011. Get current cluster config: `kk create config --from-cluster -f config.yaml`
4022. Edit config file to add new nodes to `spec.hosts` and `roleGroups`
4033. Run: `kk add nodes -f config.yaml` (or use `scripts/add_nodes.sh`)
4044. Verify new nodes joined: `kubectl get nodes`
405
406### Removing Nodes from Cluster
4071. Drain the node: `kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data`
4082. Delete the node: `kk delete node <node-name>` (or use `scripts/delete_node.sh`)
4093. Verify node removed: `kubectl get nodes`
410
411### Upgrading Cluster
4121. Check current versions: `kubectl version --short`
4132. Determine target Kubernetes version (upgrade one minor version at a time)
4143. Run upgrade: `./scripts/upgrade_cluster.sh` (interactive) or with options
4154. Monitor progress and verify: `kubectl get nodes` and `kubectl version`
416
417## Error Handling
418
419- If KubeKey is not found, suggest installation
420- If configuration file is invalid, help user fix YAML syntax
421- If cluster creation fails, check:
422 - Network connectivity
423 - SSH access to nodes
424 - Node prerequisites (Docker, etc.)
425 - Disk space and resources
426- If adding nodes fails, verify:
427 - Config file includes ALL existing nodes plus new ones
428 - New nodes meet requirements (CPU, memory, disk)
429 - SSH access to new nodes
430 - Network connectivity
431 - New nodes are not already in the cluster
432- If deleting nodes fails, verify:
433 - Node name is correct
434 - Node is not a critical master (unless HA setup)
435 - Workloads have been drained/migrated
436- If upgrade fails, check:
437 - Node time synchronization (NTP)
438 - Sufficient resources on all nodes
439 - Version compatibility (upgrade one minor version at a time)
440 - Network connectivity to all nodes
441 - CNI/CRI compatibility with target Kubernetes version
442
443## Configuration Reference
444
445For detailed information about all configuration options, see:
446- `references/config-options.md` - Complete reference of all configuration options
447- `examples/cluster-config.yaml` - Example configuration file
448- `scripts/generate_config.sh` - Interactive configuration generator
449
450Key configuration decisions:
451- **Kubernetes Version**: Latest stable (v1.28.x) unless compatibility required
452- **CNI Plugin**: Calico for production, Flannel for simple deployments
453- **CRI**: Containerd (recommended) or Docker
454- **Proxy Mode**: iptables for small/medium, ipvs for large clusters
455- **CIDR Ranges**: Ensure no overlaps, use /18 for pods and services typically
456
457## References
458
459For detailed technical references, see:
460- [KubeKey Reference Guide](references/reference.md) - Comprehensive links to KubeKey, Kubernetes, CNI plugins, and related documentation
461- [KubeKey Commands Reference](references/commands.md) - Quick reference for all kk commands
462- [Configuration Options](references/config-options.md) - Detailed configuration options reference
463- [Example Configuration](examples/cluster-config.yaml) - Sample cluster configuration file
464
465Key resources:
466- KubeKey GitHub: https://github.com/kubesphere/kubekey
467- KubeKey Documentation: https://kubesphere.io/docs/installing-on-linux/introduction/kubekey/
468- Kubernetes Documentation: https://kubernetes.io/docs/
469