awx-on-k3s排错宝典:Pod状态异常与日志分析实战指南
awx-on-k3s排错宝典Pod状态异常与日志分析实战指南【免费下载链接】awx-on-k3sAn example implementation of AWX on single node K3s using AWX Operator, with easy-to-use simplified configuration with ownership of data and passwords.项目地址: https://gitcode.com/gh_mirrors/aw/awx-on-k3s在使用awx-on-k3s部署和日常运维过程中Pod状态异常是常见的技术难题。本文将系统梳理Pod故障排查流程通过实战案例详解日志分析技巧帮助用户快速定位并解决各类容器运行问题确保AWX在K3s环境中稳定运行。排错准备核心工具与基础命令必备kubectl命令集排查Pod问题的第一步是掌握基础状态查询命令这些命令能帮助你快速定位异常Pod# 查看awx命名空间下所有Pod状态 kubectl -n awx get pod # 查看特定Pod的详细事件 kubectl -n awx describe pod Pod名称 # 查看Pod内容器日志 kubectl -n awx logs -f Pod名称 -c 容器名称日志分析关键路径针对AWX部署的特殊架构这些日志路径尤为重要AWX Operator日志kubectl -n awx logs -f deployment/awx-operator-controller-managerWeb容器初始化日志kubectl -n awx logs -f deployment/awx-web -c init数据库迁移日志kubectl -n awx logs -f job/awx-migration-VERSIONPostgreSQL日志kubectl -n awx logs -f statefulset/awx-postgres-15常见Pod状态异常解决方案ErrImagePull镜像拉取失败典型症状Pod状态显示ErrImagePull或ImagePullBackOff事件日志出现429 Too Many Requests错误。故障原因Docker Hub匿名用户拉取限制每6小时200次导致PostgreSQL等基础镜像无法拉取。解决方法等待限制解除通常6小时后自动恢复配置Docker Hub认证参考tips/dockerhub-rate-limit.md配置镜像拉取凭证使用私有镜像仓库通过registry/目录配置本地镜像仓库Pending资源不足或存储未绑定场景1资源不足事件日志显示1 Insufficient cpu, 1 Insufficient memory时说明节点资源不足。解决方案增加节点CPU/内存至至少3核5GB修改base/awx.yaml降低资源需求spec: web_resource_requirements: {} task_resource_requirements: {} ee_resource_requirements: {} postgres_resource_requirements: {}场景2存储未绑定事件日志显示unbound immediate PersistentVolumeClaims时需检查PV状态# 查看PV状态 kubectl get pv # 清除PV绑定记录 kubectl patch pv PV名称 -p {spec:{claimRef: null}}CrashLoopBackOffPostgreSQL权限问题典型日志PostgreSQL容器日志出现Permission denied错误mkdir: cannot create directory /var/lib/pgsql/data/userdata: Permission denied解决步骤根据PostgreSQL版本修复宿主机目录权限# PostgreSQL 13 sudo chown 999:0 /data/postgres-13 /data/postgres-13/data sudo chmod 755 /data/postgres-13 /data/postgres-13/data # PostgreSQL 15 sudo chown 26:0 /data/postgres-15 /data/postgres-15/data sudo chmod 700 /data/postgres-15 /data/postgres-15/dataRunning状态但功能异常数据库连接问题典型症状Pod状态显示Running但日志反复出现wait-for-migrations[wait-for-migrations] Waiting for database migrations... [wait-for-migrations] Attempt 1 of 30排查方向检查PostgreSQL Pod状态kubectl -n awx get pod | grep postgres验证数据库连接配置检查base/kustomization.yaml中awx-postgres-configuration的host参数关闭防火墙或网络策略确保K3s节点间网络通畅高级排错技巧解密Operator日志当AWX Operator日志出现censored信息时修改base/awx.yaml显示完整日志spec: # 取消注释以显示详细日志 no_log: false解决日志丢失问题长运行任务日志丢失时调整K3s日志配置# 重新安装K3s并配置日志参数 curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644 \ --kubelet-arg container-log-max-files4 \ --kubelet-arg container-log-max-size50Mi修复Provisioning Callback问题Traefik反向代理导致客户端IP无法识别时创建traefik-config.yaml配置apiVersion: helm.cattle.io/v1 kind: HelmChartConfig metadata: name: traefik namespace: kube-system spec: valuesContent: |- hostNetwork: true排错工作流总结状态检查kubectl -n awx get pod确定异常Pod事件分析kubectl -n awx describe pod Pod名称查看事件日志日志深入根据Pod类型选择对应日志命令配置验证检查相关YAML配置文件如base/awx.yaml操作修复应用解决方案后验证状态通过这套系统化的排错方法大多数awx-on-k3s部署问题都能在30分钟内定位并解决。对于复杂场景可参考tips/troubleshooting.md获取更多高级解决方案。【免费下载链接】awx-on-k3sAn example implementation of AWX on single node K3s using AWX Operator, with easy-to-use simplified configuration with ownership of data and passwords.项目地址: https://gitcode.com/gh_mirrors/aw/awx-on-k3s创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考