Kubernetes

Kubernetes 錯誤“無法附加或掛載卷”

  • September 9, 2021

我使用 nginx ingress 作為負載均衡器部署了 bitnami/wordpress helm,就像這裡一樣。一切正常,但問題出在一些 pod 是手動創建或通過自動縮放自動創建時。其中一些(不是全部)一直處於“ContainerCreating”狀態,日誌如下所示:

 Normal   Scheduled    33m                  default-scheduler  Successfully assigned default/wordpress-69c8f65d96-wnkfv to main-node-d29388
 Warning  FailedMount  4m28s (x6 over 29m)  kubelet            Unable to attach or mount volumes: unmounted volumes=[wordpress-data], unattached volumes=[default-token-s4gdj wordpress-data]: timed out waiting for the condition
 Warning  FailedMount  0s (x9 over 31m)     kubelet            Unable to attach or mount volumes: unmounted volumes=[wordpress-data], unattached volumes=[wordpress-data default-token-s4gdj]: timed out waiting for the condition

我部署了 bitnami/wordpress,然後使用以下設置進行了升級:

helm install wordpress bitnami/wordpress --set service.type=ClusterIP --set ingress.enabled=true --set ingress.certManager=true --set ingress.annotations."kubernetes\.io/ingress\.class"=nginx --set ingress.annotations."cert-manager\.io/cluster-issuer"=letsencrypt-prod --set ingress.hostname=DOMAIN.com --set ingress.extraTls[0].hosts[0]=DOMAIN.com --set ingress.extraTls[0].secretName=wordpress.local-tls --set wordpressPassword=PASSWORD --set autoscaling.enabled=true --set autoscaling.minReplicas=1 autoscaling.maxReplicas=30

kubectl get pods 看起來像這樣

ingress-nginx-ingress-controller-84bff86888-f4tpb                 1/1     Running             0          2d3h
ingress-nginx-ingress-controller-default-backend-c5b786dbbqw5xz   1/1     Running             0          2d3h
load-generator                                                    1/1     Running             0          71s
wordpress-69c8f65d96-48jd9                                        0/1     ContainerCreating   0          18m
wordpress-69c8f65d96-66ftt                                        0/1     ContainerCreating   0          56m
wordpress-69c8f65d96-dq7xq                                        1/1     Running             0          100m
wordpress-69c8f65d96-fbnt6                                        1/1     Running             0          101m
wordpress-69c8f65d96-wnkfv                                        0/1     ContainerCreating   0          56m
wordpress-mariadb-0                                               1/1     Running             0          8h

怎樣做才能使新 pod 沒有這個問題並讓它們啟動?

使用者@Juan 是對的。我做了類似的方法,我使用 helm 創建了其他 POD,它正在創建儲存,並在 wordpress 部署中將其設置為持久性。這裡描述:https ://docs.bitnami.com/tutorials/deploy-applications-nfs-kubernetes/

引用自:https://serverfault.com/questions/1077062