redis-ha:无法在群集中创建指定数量的主服务器

时间:2017-11-02 07:40:20

标签: docker redis boot2docker kubernetes-helm

我正在尝试使用以下命令创建一个由3个主设备,3个从设备和3个标记组成的集群。

helm install --set replicas.master=3 --set replicas.slave=3 stable/redis-ha

但是我看到只有1个主人被创造了。 Helm --version 0.2.3 GIT回购:https://github.com/kubernetes/charts/tree/master/stable/redis-ha

以下是来自helm的日志。

=>     NAME                         DESIRED  CURRENT  AGE
=>    eloping-fox-redis-ha-master  3        1        9s

我错过了什么或有问题吗? 我尝试了这多个项目,每次只创建一个主人。

我在使用VM / Minikube / Docker的Windows机器上尝试这个。

PS C:\Users\rootus> helm install --set replicas.master=3 --set replicas.slave=3  stable/redis-ha
NAME:   eloping-fox
LAST DEPLOYED: Wed Nov  1 16:34:58 2017
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1beta1/Deployment
NAME                           DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
eloping-fox-redis-ha           3        3        3           0          9s
eloping-fox-redis-ha-sentinel  3        3        3           0          9s

==> v1beta1/StatefulSet
NAME                         DESIRED  CURRENT  AGE
eloping-fox-redis-ha-master  3        1        9s

==> v1/Pod(related)
NAME                                            READY  STATUS             RESTARTS  AGE
eloping-fox-redis-ha-167683871-2rhn8            0/1    ContainerCreating  0         9s
eloping-fox-redis-ha-167683871-cmjjk            0/1    ContainerCreating  0         9s
eloping-fox-redis-ha-167683871-jf4sn            0/1    ContainerCreating  0         9s
eloping-fox-redis-ha-sentinel-2596454939-9qq06  0/1    ContainerCreating  0         9s
eloping-fox-redis-ha-sentinel-2596454939-ngwcf  0/1    ContainerCreating  0         9s
eloping-fox-redis-ha-sentinel-2596454939-pwkbx  0/1    ContainerCreating  0         9s

==> v1/Service
NAME                  TYPE       CLUSTER-IP  EXTERNAL-IP  PORT(S)    AGE
redis-sentinel        ClusterIP  10.0.0.122  <none>       26379/TCP  9s
eloping-fox-redis-ha  ClusterIP  10.0.0.149  <none>       6379/TCP   9s


NOTES:
Redis cluster can be accessed via port 6379 on the following DNS name from within your cluster:
eloping-fox-redis-ha.default.svc.cluster.local

To connect to your Redis server:

1. Run a Redis pod that you can use as a client:

   kubectl exec -it eloping-fox-redis-ha-master-0 bash

2. Connect using the Redis CLI:

  redis-cli -h eloping-fox-redis-ha.default.svc.cluster.local

=============================================== ==

1 个答案:

答案 0 :(得分:0)

使用stable/redis-ha舵图,一切都按预期工作。

您的minikube环境似乎存在问题。

默认minikube使用2 CPU2048M RAM启动VM。

stable/redis-ha舵图中的默认CPU和内存资源如下:

resources:
  master:
    requests:
      memory: 200Mi
      cpu: 100m
    limits:
      memory: 700Mi
  slave:
    requests:
      memory: 200Mi
      cpu: 100m
    limits:
      memory: 200Mi
  sentinel:
    requests:
      memory: 200Mi
      cpu: 100m
    limits:
      memory: 200Mi

当您使用stable/redis-ha3 masters部署3 slaves头盔图时,由于您的虚拟机使用minikube缺少资源,因此仅创建1 master

$ kubectl get pod
NAME                                                   READY     STATUS    RESTARTS   AGE
melting-armadillo-redis-ha-2438719374-8ghdn            1/1       Running   0          2m
melting-armadillo-redis-ha-2438719374-rlq24            1/1       Running   0          2m
melting-armadillo-redis-ha-2438719374-zlg4p            1/1       Running   0          2m
melting-armadillo-redis-ha-master-0                    2/2       Running   0          2m
melting-armadillo-redis-ha-master-1                    0/2       Pending   0          4s
melting-armadillo-redis-ha-sentinel-1377673986-004m8   1/1       Running   0          2m
melting-armadillo-redis-ha-sentinel-1377673986-gcpj2   1/1       Running   0          2m
melting-armadillo-redis-ha-sentinel-1377673986-jh73w   1/1       Running   0          2m

第二个redis master的Pod由于以下原因而处于Pending状态:

  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----            -------------   --------    ------          -------
  16s       1s      6   default-scheduler           Warning     FailedScheduling    No nodes are available that match all of the following predicates:: Insufficient memory (1).

所以你有两种方法来解决你的问题:

  1. 创建至少minikube。{/ li>的4096M RAM环境
  2. 使用stable/redis-ha3 masters部署3 slaves头盔图,减少内存资源。
  3. 第一种方式是:

    使用minikube开始4096M RAM

    $ minikube start --memory 4096
    Starting local Kubernetes v1.7.5 cluster...
    Starting VM...
    Getting VM IP address...
    Moving files into cluster...
    Setting up certs...
    Connecting to cluster...
    Setting up kubeconfig...
    Starting cluster components...
    Kubectl is now configured to use the cluster.
    

    使用stable/redis-ha3 masters部署3 slaves掌舵图:

    $ helm install --set replicas.master=3 --set replicas.slave=3 stable/redis-ha 
    

    最后我们得到:

    $ kubectl get pod
    NAME                                                 READY     STATUS    RESTARTS   AGE
    maudlin-ladybug-redis-ha-1801622981-brmqp            1/1       Running   0          3m
    maudlin-ladybug-redis-ha-1801622981-klhr1            1/1       Running   0          3m
    maudlin-ladybug-redis-ha-1801622981-mpf3j            1/1       Running   0          3m
    maudlin-ladybug-redis-ha-master-0                    2/2       Running   0          3m
    maudlin-ladybug-redis-ha-master-1                    2/2       Running   0          1m
    maudlin-ladybug-redis-ha-master-2                    2/2       Running   0          1m
    maudlin-ladybug-redis-ha-sentinel-3633913943-f8x2c   1/1       Running   0          3m
    maudlin-ladybug-redis-ha-sentinel-3633913943-ltvk4   1/1       Running   0          3m
    maudlin-ladybug-redis-ha-sentinel-3633913943-xwclg   1/1       Running   0          3m
    

    第二种方式是:

    使用stable/redis-ha3 masters部署3 slaves头盔图并减少内存资源:

    helm install --set replicas.master=3 --set replicas.slave=3 --set resources.master.requests.memory=100Mi --set resources.slave.requests.memory=100Mi --set resources.sentinel.requests.memory=100Mi stable/redis-ha
    

    最后我们得到:

    $ kubectl get pod
    NAME                                                       READY     STATUS    RESTARTS   AGE
    exacerbated-jellyfish-redis-ha-3444643229-085f4            1/1       Running   0          43s
    exacerbated-jellyfish-redis-ha-3444643229-bl221            1/1       Running   0          43s
    exacerbated-jellyfish-redis-ha-3444643229-qx62b            1/1       Running   0          43s
    exacerbated-jellyfish-redis-ha-master-0                    2/2       Running   0          43s
    exacerbated-jellyfish-redis-ha-master-1                    2/2       Running   0          36s
    exacerbated-jellyfish-redis-ha-master-2                    2/2       Running   0          29s
    exacerbated-jellyfish-redis-ha-sentinel-1441222589-czsvx   1/1       Running   0          43s
    exacerbated-jellyfish-redis-ha-sentinel-1441222589-ql6n6   1/1       Running   0          43s
    exacerbated-jellyfish-redis-ha-sentinel-1441222589-qql1f   1/1       Running   0          43s