简体   繁体   English

使用Pod自动缩放的AWS中的Kubernetes PersistentVolumeClaim问题

[英]Kubernetes PersistentVolumeClaim issues in AWS using Pod Autoscaling

We have success creating the pods, services and replication controllers according to our project requirements. 我们已经根据项目要求成功创建了Pod,服务和复制控制器。 Now we are planning to setup persistence storage in AWS using Kubernetes. 现在,我们计划使用Kubernetes在AWS中设置持久性存储。 I have created the YAML file to create an EBS volume in AWS, it's working fine as expected. 我已经创建了YAML文件以在AWS中创建EBS卷,它按预期工作正常。 I am able to claim volume and successfully mount to my pod (this is for single replica only). 我可以声明其容量并成功安装到我的Pod(仅适用于单个副本)。

I am able to successfully create the file.Volume also creating but my Pods is going to pending state, volume still shows available state in aws. 我能够成功创建文件。也可以创建卷,但是我的Pod即将进入待处理状态,卷仍显示可用状态(aws)。 I am not able to see any error logs over there. 我看不到那里的任何错误日志。

Storage file: 存储文件:

kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  name: mongo-ssd
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2

Main file: 主文件:

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
    name: web2
spec:
  selector:
    matchLabels:
      app: mongodb
  serviceName: "mongodb"
  replicas: 2
  template:
    metadata:
      labels:
        app: mongodb
      annotations:
         pod.alpha.kubernetes.io/initialized: "true"
    spec:
      containers:
      - image: mongo
        name: mongodb
        ports:
        - name: web2
          containerPort: 27017
          hostPort: 27017
        volumeMounts:
        - mountPath: "/opt/couchbase/var"
          name: mypd1
  volumeClaimTemplates:
  - metadata:
      name: mypd1
      annotations:
        volume.alpha.kubernetes.io/storage-class: mongo-ssd
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi

Now I am planning to set up a pod Autoscaling. 现在,我计划设置一个Pod Autoscaling。 I have seen pod autoscaling for deployment and ReplicationContoller. 我已经看到用于部署和ReplicationContoller的pod自动伸缩。 May I know can we implement pod auto-scaling for Stateful set also? 我可以知道我们也可以为有状态集实现pod自动缩放吗?

Horizontal Pod Autoscaler can scale only Deployment, Replica Set or Replication Controller. Horizo​​ntal Pod Autoscaler只能缩放Deployment,Replica Set或Replication Controller。 You cannot scale Stateful Sets. 您无法缩放状态集。 (see Kubernetes Docu for more details ) 有关更多详细信息,请参阅Kubernetes Docu

The main reason is that most of the stateful applications running in Stateful Sets (such as your MongoDB) are usually not as easy to scale up / down as the stateless applications running as Deployments. 主要原因是,在有状态集中运行的大多数有状态应用程序(例如MongoDB)通常不像在部署中运行那样容易伸缩。 Scaling up and down is usually quite complicated process for stateful apps which you do not want to do only based on the autoscaler. 对于有状态的应用程序,放大和缩小通常是非常复杂的过程,您不希望仅基于自动缩放器来进行缩放。 It usually requires some additional support logic in the application it self. 它本身在应用程序中通常需要一些其他支持逻辑。 And especially with scale down it could also mean risk for your data. 特别是缩小比例,这也可能意味着数据风险。 The autoscaling is more useful for short term changes in the load. 自动缩放对负载的短期变化更有用。 Scaling of Stateful Sets requires more long term thinking. 有状态集的扩展需要更多的长期思考。 Because of the complexity you do not want your database to be scaling up and down every minute. 由于复杂性,您不希望数据库每分钟进行扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM