|
| 1 | +# Etcd Plugin |
| 2 | + |
| 3 | +A Claude Code plugin for monitoring etcd cluster health and analyzing performance in OpenShift environments. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This plugin provides commands to help diagnose and troubleshoot etcd-related issues in OpenShift clusters. Etcd is the critical distributed key-value store that holds all cluster state for Kubernetes/OpenShift, and maintaining its health and performance is essential for cluster stability. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +### `/etcd:health-check` |
| 12 | + |
| 13 | +Performs a comprehensive health check of the etcd cluster, examining: |
| 14 | +- Etcd pod status and availability |
| 15 | +- Cluster health and member status |
| 16 | +- Leadership election status |
| 17 | +- Database size and fragmentation |
| 18 | +- Disk space utilization |
| 19 | +- Recent error logs |
| 20 | +- Performance metrics (with `--verbose` flag) |
| 21 | + |
| 22 | +**Usage:** |
| 23 | +``` |
| 24 | +/etcd:health-check [--verbose] |
| 25 | +``` |
| 26 | + |
| 27 | +**Example:** |
| 28 | +``` |
| 29 | +/etcd:health-check |
| 30 | +/etcd:health-check --verbose |
| 31 | +``` |
| 32 | + |
| 33 | +### `/etcd:analyze-performance` |
| 34 | + |
| 35 | +Analyzes etcd performance metrics to identify latency issues and bottlenecks, including: |
| 36 | +- Disk I/O performance (commit latency, fsync duration) |
| 37 | +- Network latency between etcd peers |
| 38 | +- Request/response performance by operation type |
| 39 | +- Leader stability and proposal metrics |
| 40 | +- Database size and fragmentation |
| 41 | +- Performance warnings from logs |
| 42 | + |
| 43 | +**Usage:** |
| 44 | +``` |
| 45 | +/etcd:analyze-performance [--duration <minutes>] |
| 46 | +``` |
| 47 | + |
| 48 | +**Example:** |
| 49 | +``` |
| 50 | +/etcd:analyze-performance |
| 51 | +/etcd:analyze-performance --duration 15 |
| 52 | +``` |
| 53 | + |
| 54 | +## Prerequisites |
| 55 | + |
| 56 | +All commands require: |
| 57 | + |
| 58 | +1. **OpenShift CLI (oc)** - Install from https://mirror.openshift.com/pub/openshift-v4/clients/ocp/ |
| 59 | +2. **Active cluster connection** - Must be authenticated to an OpenShift cluster |
| 60 | +3. **Cluster admin permissions** - Required to access etcd pods and metrics |
| 61 | +4. **Running etcd pods** - At least one etcd pod must be running |
| 62 | + |
| 63 | +## Installation |
| 64 | + |
| 65 | +### From Marketplace |
| 66 | + |
| 67 | +```bash |
| 68 | +# Add the marketplace (if not already added) |
| 69 | +/plugin marketplace add openshift-eng/ai-helpers |
| 70 | + |
| 71 | +# Install the etcd plugin |
| 72 | +/plugin install etcd@ai-helpers |
| 73 | +``` |
| 74 | + |
| 75 | +### Manual Installation |
| 76 | + |
| 77 | +```bash |
| 78 | +# Clone the repository |
| 79 | +git clone https://github.com/openshift-eng/ai-helpers.git |
| 80 | + |
| 81 | +# Link to your Claude Code plugins directory |
| 82 | +ln -s $(pwd)/ai-helpers/plugins/etcd ~/.claude/plugins/etcd |
| 83 | +``` |
| 84 | + |
| 85 | +## Use Cases |
| 86 | + |
| 87 | +### Troubleshooting Cluster Issues |
| 88 | + |
| 89 | +When experiencing cluster-wide problems: |
| 90 | +1. Run `/etcd:health-check` to verify etcd cluster status |
| 91 | +2. If issues are found, run `/etcd:analyze-performance` to identify bottlenecks |
| 92 | +3. Follow the recommendations provided in the output |
| 93 | + |
| 94 | +### Performance Tuning |
| 95 | + |
| 96 | +For proactive performance monitoring: |
| 97 | +1. Run `/etcd:analyze-performance --duration 30` for comprehensive analysis |
| 98 | +2. Review disk I/O and network latency metrics |
| 99 | +3. Compare against recommended thresholds |
| 100 | +4. Implement suggested optimizations |
| 101 | + |
| 102 | +### Capacity Planning |
| 103 | + |
| 104 | +Before scaling operations: |
| 105 | +1. Check current database size with `/etcd:health-check` |
| 106 | +2. Analyze performance trends with `/etcd:analyze-performance` |
| 107 | +3. Identify if hardware upgrades are needed |
| 108 | + |
| 109 | +## Common Issues and Solutions |
| 110 | + |
| 111 | +### High Disk Latency |
| 112 | + |
| 113 | +**Problem:** Backend commit P99 > 100ms or WAL fsync P99 > 10ms |
| 114 | + |
| 115 | +**Solutions:** |
| 116 | +- Migrate to SSD or NVMe storage |
| 117 | +- Use dedicated disks for etcd (not shared with OS) |
| 118 | +- Check for competing I/O workloads |
| 119 | + |
| 120 | +### Frequent Leader Changes |
| 121 | + |
| 122 | +**Problem:** Leader changes > 5 |
| 123 | + |
| 124 | +**Solutions:** |
| 125 | +- Check network connectivity between etcd nodes |
| 126 | +- Ensure nodes are in same datacenter/availability zone |
| 127 | +- Verify no clock skew between nodes |
| 128 | + |
| 129 | +### Large Database Size |
| 130 | + |
| 131 | +**Problem:** Database size > 8GB or high fragmentation |
| 132 | + |
| 133 | +**Solutions:** |
| 134 | +- Run etcd defragmentation |
| 135 | +- Review event retention policies |
| 136 | +- Check for excessive key creation |
| 137 | + |
| 138 | +## Performance Benchmarks |
| 139 | + |
| 140 | +Recommended thresholds for healthy etcd: |
| 141 | +- **Backend commit P99:** < 100ms |
| 142 | +- **WAL fsync P99:** < 10ms |
| 143 | +- **Peer RTT P99:** < 50ms |
| 144 | +- **Leader changes:** < 5 total |
| 145 | +- **Database size:** < 8GB |
| 146 | +- **Disk usage:** < 80% |
| 147 | + |
| 148 | +## Security Considerations |
| 149 | + |
| 150 | +- Commands require cluster-admin or equivalent permissions |
| 151 | +- Access to etcd allows viewing all cluster secrets |
| 152 | +- Metrics and logs may contain sensitive information |
| 153 | +- Performance data should be treated as confidential |
| 154 | + |
| 155 | +## Resources |
| 156 | + |
| 157 | +- **Etcd Documentation:** https://etcd.io/docs/ |
| 158 | +- **OpenShift Etcd Docs:** https://docs.openshift.com/container-platform/latest/backup_and_restore/control_plane_backup_and_restore/ |
| 159 | +- **Performance Tuning:** https://etcd.io/docs/latest/tuning/ |
| 160 | + |
| 161 | +## Contributing |
| 162 | + |
| 163 | +To contribute improvements or report issues: |
| 164 | +1. Visit https://github.com/openshift-eng/ai-helpers |
| 165 | +2. Open an issue or pull request |
| 166 | +3. Follow the contribution guidelines in the repository |
| 167 | + |
| 168 | +## License |
| 169 | + |
| 170 | +This plugin is part of the ai-helpers project and follows the same license terms. |
0 commit comments