对单个 VM 设置问题进行故障诊断

任务管理器 Pod 故障 - 存储所有权问题

有时,在单个 VM 环境中升级到版本 2.0.0 后,任务管理器 Pod 可能无法启动。要解决此问题,请执行以下操作:
  • 如果您使用在线脚本升级 AppScan 360°,请运行以下命令:
    ./AppScan360_SingleVMsetup_v2.0.0.run -- $PWD remediateStorageIssues
  • 如果您使用离线脚本升级 AppScan 360°,请运行以下命令:
    ./AppScan360_SingleVMsetup_v2.0.0_Offline.run -- $PWD remediateStorageIssues

Pod 映像提取问题

在单个 VM 的 Ubuntu 环境中部署 AppScan 360° 时,如果使用的是本地 Docker 注册表,则您可能会遇到因注册表连接错误而导致 Pod 无法启动的问题。

Pod 事件中的典型错误可能如下所示:
Normal   Pulling    60s (x4 over 4m1s)   kubelet            
Pulling image "<ip>:5443/as360-k8s-docker-images/reloader:v1.2.1"
Warning  Failed     30s (x4 over 3m31s)  kubelet            
Failed to pull image 
"<ip>:5443/as360-k8s-docker-images/reloader:v1.2.1": rpc error: code = 
DeadlineExceeded desc = failed to pull and unpack image 
"<ip>:5443/as360-k8s-docker-images/reloader:v1.2.1": failed to resolve 
reference "<ip>/as360-k8s-docker-images/reloader:v1.2.1": failed to do 
request: Head 
"https://<ip>/v2/as360-k8s-docker-images/reloader/manifests/v1.2.1": 
dial tcp <ip>:5443: i/o timeout

如果您在错误消息中看到 dial tcp <ip>:5443: i/o timeout,这通常表示您的 Kubernetes 节点(k0s 容器)与 Docker 注册表之间存在网络连接问题。

要解决此问题,请执行以下操作:

  • 连接到 k0s 容器并安装诊断工具:
    docker exec -it k0s sh
  • 从容器中测试网络连接:

    • 使用 netcat 检查与注册表的连接:
      nc -zv <registry-ip> 5443
    • 如果您在消息中未看到开放,则连接失败,表明存在网络问题。
    • 尝试从容器中直接使用 ctr 命令来提取映像:
      k0s ctr images pull --user <user>:<pass> 
      <registry-ip>:5443/as360-k8s-docker-images/reloader:v1.2.1
    • 如果此操作失败,则问题可能与防火墙规则相关。
  • 检查防火墙 (UFW) 和 IPTables 规则:
    • 在主机上,检查防火墙规则:
      iptables -L -n -v
    • 查找与 ufw(简单防火墙)相关并且可能会拦截流量的链,如以下示例所示:
      Chain INPUT (policy DROP 39231 packets, 2148K bytes)
       pkts bytes target     prot opt in     out     source               destination         
      6603K 9311M ufw-before-logging-input  all  --  *      *       0.0.0.0/0            
      0.0.0.0/0           
      6603K 9311M ufw-before-input  all  --  *      *       0.0.0.0/0            
      0.0.0.0/0           
       407K   50M ufw-after-input  all  --  *      *       0.0.0.0/0            
      0.0.0.0/0           
      39311 2154K ufw-after-logging-input  all  --  *      *       0.0.0.0/0            
      0.0.0.0/0           
      39311 2154K ufw-reject-input  all  --  *      *       0.0.0.0/0            
      0.0.0.0/0           
      39311 2154K ufw-track-input  all  --  *      *       0.0.0.0/0            
      0.0.0.0/0
      
  • 更新 UFW 规则以允许主机上的 Docker 网络流量:

    • 允许 Docker 网络接口上的流量:
      sudo ufw allow in on docker0
      sudo ufw allow out on docker0
      
    • 允许到注册表端口的流量:
      sudo ufw allow out from any to <registry-ip> port 5443 proto tcp
      sudo ufw allow out from any to <registry-ip> port 7443 proto tcp
      
  • 验证问题是否已解决:

    • 从 k0s 容器中重新运行连接测试(netcat、ctr images pull)。
    • 如果测试成功,则 Pod 映像提取现在应当按预期正常运行。

AppScan 360° 无法连接到数据库 - SCA部署失败

  • 由于 IP 不在网络策略范围内,数据库连接失败
  • 因此,SCA 部署也将失败,因为 ASCP 部署未成功完成
egress:
  - to:
    - namespaceSelector: {}
    - ipBlock:
        cidr: 10.0.0.0/8
    - ipBlock:
        cidr: 192.168.0.0/16
    - ipBlock:
        cidr: 172.16.0.0/12
    - ipBlock:
        cidr: fc00::/7

故障诊断步骤

  • 检查数据库连接字符串/ip

解决方法

  • 将数据库 ip cidr 添加到网络策略出口规则中

Coredns Pod 启动失败,发生 crashloopbackoff 错误

  • 在 k0s 集群设置过程中,coredns Pod 启动失败,发生 crashloopbackoff 错误
  • coredns Pod 日志中出现错误
maxprocs: Leaving GOMAXPROCS=28: CPU quota undefined 
plugin/forward: no nameservers found 
stream closed: EOF for kube-system/coredns-6946cc8786-q52sw (coredns)

解决方法

  • 在主机的 /etc/resolv.conf 文件中添加名称服务器条目(如果不存在)。
  • 随后删除 coredns Pod,以在重新创建它们。
  • 或者,可以在 coredns configmap 中设置名称服务器条目,前提是您希望该设置仅对集群生效,且不依赖主机的 resolv.conf
   kubectl -n kube-system edit configmap coredns

   # Replace forward . /etc/resolv.conf
   forward . 8.8.8.8 1.1.1.1 # Or specify any specific nameserver applicable for your environment

RHEL - 重新启动 VM 时无法访问应用程序

  • 在 RHEL VM 上安装 AppScan 360° 后,如果 VM 重启,则应用程序可能无法访问,并且系统会在您访问应用程序 URL 时显示“503 服务不可用”错误。
  • 这是因为 Podman 容器可能已停止,而 k0s 集群也可能随之停止。

解决方法

  • 以下路径中的单个 VM 安装工具包内提供了帮助程序脚本,用于启动所需组件。
    # Navigate to aioWorkspace directory
    cd <AS360_SETUP_DIRECTORY>/aioWorkspace
    # Navigate to utils scripts
    cd bin/utils
    
    # Execute script to start podman containers
    ./startPodmanContainers.sh
    
    # Check if k0s cluster is running, if not start the cluster using below script
    k0s status
    kubectl get pods -A
    
    # Execute script to start k0s cluster if it is not running
    ./startK0sOnHost.sh
    
    # Verify if all pods are running
    kubectl get pods -A

在单个 VM 安装中重新安装 AppScan 360° 时遇到问题,并且 Istio Pod 卡住

  • 在单个 VM 安装中重新安装 AppScan 360° 时,如果在卸载过程中未正确清理 Istio Pod,则它们可能会卡在待处理状态。

解决方法

  • 使用帮助程序脚本清理 Istio 资源,然后继续进行安装。
    # Navigate to aioWorkspace directory
    cd <AS360_SETUP_DIRECTORY>/aioWorkspace
    # Navigate to utils scripts
    cd bin/utils
    
    # Execute script to clean up istio resources
    ./cleanIstio.sh
  • 接下来,尝试使用安装命令再次安装 AppScan 360°。