searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

K8S脚本--Kubernetes集群的故障排除

2025-03-13 16:48:48
0
0

#!/bin/bash

# 配置参数
LOG_FILE="/var/log/k8s_troubleshooting.log"

# 检查并创建日志文件
if [ ! -f "$LOG_FILE" ]; then
  touch "$LOG_FILE"
fi

# 记录日志函数
log() {
  echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" >> "$LOG_FILE"
}

# 检查节点状态
log "Checking node status..."
kubectl get nodes -o wide

# 检查Pod状态
log "Checking Pod status..."
kubectl get pods --all-namespaces -o wide

# 检查事件
log "Checking events..."
kubectl describe nodes
kubectl describe pods --all-namespaces

# 检查日志
log "Checking logs..."
kubectl logs -l app=my-app -n default

log "Troubleshooting completed successfully."

0条评论
0 / 1000
王****际
180文章数
2粉丝数
王****际
180 文章 | 2 粉丝
原创

K8S脚本--Kubernetes集群的故障排除

2025-03-13 16:48:48
0
0

#!/bin/bash

# 配置参数
LOG_FILE="/var/log/k8s_troubleshooting.log"

# 检查并创建日志文件
if [ ! -f "$LOG_FILE" ]; then
  touch "$LOG_FILE"
fi

# 记录日志函数
log() {
  echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" >> "$LOG_FILE"
}

# 检查节点状态
log "Checking node status..."
kubectl get nodes -o wide

# 检查Pod状态
log "Checking Pod status..."
kubectl get pods --all-namespaces -o wide

# 检查事件
log "Checking events..."
kubectl describe nodes
kubectl describe pods --all-namespaces

# 检查日志
log "Checking logs..."
kubectl logs -l app=my-app -n default

log "Troubleshooting completed successfully."

文章来自个人专栏
文章 | 订阅
0条评论
0 / 1000
请输入你的评论
0
0