進行單一 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 環境中使用本端 Docker 登錄部署 AppScan 360° 時,可能會遇到因為登錄連線錯誤而導致 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 不在網絡原則範圍內,導致資料庫連線失敗
  • 因此,由於 ASCP 部署未順利完成,SCA 部署也隨之失敗
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 檔案中不存在 nameserver 項目,請手動進行新增。
  • 完成後,刪除 Coredns Pod 以便重新建立它們。
  • 或者,如果您想讓將此設定僅限於叢集內部,而不依賴主機的 resolv.conf,也可以在 CoreDNS ConfigMap 中設定 nameserver 項目。
   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 Service Unavailable」錯誤。
  • 這是由於 Podman 儲存器可能已停止,k0s 叢集也可能隨之停止所致。

解決方案

  • 單一 VM 設定套件中的以下路徑提供了 Helper Script,可用於啓動所需的元件。
    # 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

在 Istio Pod 卡住的情況下,在單一 VM 設定上重新安裝 AppScan 360° 時出現問題

  • 在單一 VM 設定上重新安裝 AppScan 360° 期間,如果解除安裝過程中未清理乾淨,Istio Pod 可能會卡在擱置狀態。

解決方案

  • 使用 Helper Script 來清理 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°。