0

这个存储库kubernetes-wordpress-with-nfs-volume-on-gke正在尝试实现一个 wordpress 应用程序,该应用程序在 mySQL 和 wordpress 之间共享一个 NFS 卷。在 Pod 之间共享 NFS 卷背后的想法是在下一步中为 mySQL 实现 StatefulSet。这个 StatefulSet 应用程序需要在 mySQL 的所有 pod 之间共享数据库(数据库的卷),以便创建一个多节点数据库,以确保所请求的高性能。

为此,有一个示例janakiramm/wp-statefulset。此示例使用etcd. 那么为什么不使用nfs代替etcd呢?

运行来创建这个在 MySQL 和 wordpress 之间共享 NFS 卷的 kubernetes wordpress 应用程序的命令是:

kubectl create -f 01-pv-gce.yml
kubectl create -f 02-dep-nfs.yml
kubectl create -f 03-srv-nfs.yml
kubectl get services # you have to update the file 04-pv-pvc with the new IP address of the service 
kubectl create -f 04-pv-pvc.yml
kubectl create -f 05-mysql.yml
kubectl create -f 06-wordpress.yml

这个实现没有成功。wordpress pod 未启动:

$ kubectl get pods
NAME                              READY     STATUS             RESTARTS   AGE
nfs-server-2899972627-jgjx0       1/1       Running            0          4m
wp01-mysql-1941769936-m9jjd       1/1       Running            0          3m
wp01-wordpress-2362719074-bv53t   0/1       CrashLoopBackOff   4          2m

似乎是访问NFS卷有问题,如下所述:

$ kubectl describe pods wp01-wordpress-2362719074-bv53t
Name:       wp01-wordpress-2362719074-bv53t
Namespace:  default
Node:       gke-mappedinn-cluster-default-pool-6264f94a-z0sh/10.240.0.4
Start Time: Thu, 04 May 2017 05:59:12 +0400
Labels:     app=wp01
        pod-template-hash=2362719074
        tier=frontend
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"wp01-wordpress-2362719074","uid":"44b91da0-306d-11e7-a0d1-42010a...
        kubernetes.io/limit-ranger=LimitRanger plugin set: cpu request for container wordpress
Status:     Running
IP:     10.244.0.4
Controllers:    ReplicaSet/wp01-wordpress-2362719074
Containers:
  wordpress:
    Container ID:   docker://658c7392c1b7a5033fe1a1b456a9653161003ee2878a4f02c6a12abb49241d47
    Image:      wordpress:4.6.1-apache
    Image ID:       docker://sha256:ee397259d4e59c65e2c1c5979a3634eb3ab106bba389acea8b21862053359134
    Port:       80/TCP
    State:      Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Thu, 04 May 2017 06:03:16 +0400
      Finished:     Thu, 04 May 2017 06:03:16 +0400
    Ready:      False
    Restart Count:  5
    Requests:
      cpu:  100m
    Environment:
      WORDPRESS_DB_HOST:    wp01-mysql
      WORDPRESS_DB_PASSWORD:    <set to the key 'password' in secret 'wp01-pwd-wordpress'>  Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-k650h (ro)
      /var/www/html from wordpress-persistent-storage (rw)
Conditions:
  Type      Status
  Initialized   True
  Ready     False
  PodScheduled  True
Volumes:
  wordpress-persistent-storage:
    Type:   PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  wp01-pvc-data
    ReadOnly:   false
  default-token-k650h:
    Type:   Secret (a volume populated by a Secret)
    SecretName: default-token-k650h
    Optional:   false
QoS Class:  Burstable
Node-Selectors: <none>
Tolerations:    <none>
Events:
  FirstSeen LastSeen    Count   From                                SubObjectPath           Type        Reason      Message
  --------- --------    -----   ----                                -------------           --------    ------      -------
  5m        5m      1   default-scheduler                                       Normal      Scheduled   Successfully assigned wp01-wordpress-2362719074-bv53t to gke-mappedinn-cluster-default-pool-6264f94a-z0sh
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal      Pulling     pulling image "wordpress:4.6.1-apache"
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal      Pulled      Successfully pulled image "wordpress:4.6.1-apache"
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal      Created     Created container with docker id 8647e997d6f4; Security:[seccomp=unconfined]
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal      Started     Started container with docker id 8647e997d6f4
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal      Created     Created container with docker id 37f4f0fd392d; Security:[seccomp=unconfined]
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal      Started     Started container with docker id 37f4f0fd392d
  4m        4m      1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh                   Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "wordpress" with CrashLoopBackOff: "Back-off 10s restarting failed container=wordpress pod=wp01-wordpress-2362719074-bv53t_default(44ba1226-306d-11e7-a0d1-42010a8e0084)"

  3m    3m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Created     Created container with docker id b78a661388a2; Security:[seccomp=unconfined]
  3m    3m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Started     Started container with docker id b78a661388a2
  3m    3m  2   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "wordpress" with CrashLoopBackOff: "Back-off 20s restarting failed container=wordpress pod=wp01-wordpress-2362719074-bv53t_default(44ba1226-306d-11e7-a0d1-42010a8e0084)"

  3m    3m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Created     Created container with docker id 2b6384407678; Security:[seccomp=unconfined]
  3m    3m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Started     Started container with docker id 2b6384407678
  3m    2m  4   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "wordpress" with CrashLoopBackOff: "Back-off 40s restarting failed container=wordpress pod=wp01-wordpress-2362719074-bv53t_default(44ba1226-306d-11e7-a0d1-42010a8e0084)"

  2m    2m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Created     Created container with docker id 930a3410b213; Security:[seccomp=unconfined]
  2m    2m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Started     Started container with docker id 930a3410b213
  2m    1m  7   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh                   Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "wordpress" with CrashLoopBackOff: "Back-off 1m20s restarting failed container=wordpress pod=wp01-wordpress-2362719074-bv53t_default(44ba1226-306d-11e7-a0d1-42010a8e0084)"

  4m    1m  5   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Pulled      Container image "wordpress:4.6.1-apache" already present on machine
  1m    1m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Created     Created container with docker id 658c7392c1b7; Security:[seccomp=unconfined]
  1m    1m  1   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Normal  Started     Started container with docker id 658c7392c1b7
  4m    10s 19  kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh   spec.containers{wordpress}  Warning BackOff     Back-off restarting failed docker container
  1m    10s 5   kubelet, gke-mappedinn-cluster-default-pool-6264f94a-z0sh               

你能帮忙解决这个问题吗?

4

0 回答 0