Kops在AWS上使用Kubernetes-动态配置gp2对于单节点集群失败; PVC未决;

时间:2019-03-05 12:18:35

标签: kubernetes kops kubernetes-pvc

我的PVC一直处于enter the first number: 5 enter the second number: 0 Traceback (most recent call last): File "py113.py", line 4, in <module> p=n/m ZeroDivisionError: division by zero 状态。

Pending给出:

kubectl describe pvc project-s3-pvc

Name: project-s3-pvc Namespace: default StorageClass: gp2 Status: Pending Volume: Labels: <none> Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"project-s3-pvc","namespace":"default"},"spec":{"ac... volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/aws-ebs Finalizers: [kubernetes.io/pvc-protection] Capacity: Access Modes: Events: <none> Mounted By: project-s3-86ccd56868-skvv5 ✔ /data/project [kubernetes-aws L|✚ 10⚑ 66 给出:

kubectl get storageclass

我正在运行由Kops启动的1个节点集群:

NAME            PROVISIONER             AGE
default         kubernetes.io/aws-ebs   1h
gp2 (default)   kubernetes.io/aws-ebs   1h

然后我添加PVC,例如:

kops create cluster --node-count 0 --zones eu-west-1a ${NAME} --master-size t2.large

# Change size from 2 to 0, since above node-count does seem to be ignored
kops edit ig --name=${NAME} nodes

kops edit cluster ${NAME}

# Add this to cluster specification
iam:
  allowContainerRegistry: true
  legacy: false

kops update cluster ${NAME} --yes

kubectl taint nodes --all node-role.kubernetes.io/master-node

Kops版本:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: bomcheck-s3-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 30Gi

编辑: 当我尝试手动创建PV时:

Version 1.11.0 (git-2c2042465)

我得到了:apiVersion: v1 kind: PersistentVolume metadata: name: pv-manual spec: accessModes: - ReadWriteOnce awsElasticBlockStore: fsType: ext4 persistentVolumeReclaimPolicy: Delete storageClassName: gp2 capacity: storage: 30Gi

这是否意味着我需要在AWS中手动创建卷?我希望通过动态配置来实现音量。

有什么主意如何调试为什么不能代表我的AWS供应PVC / PV?

2 个答案:

答案 0 :(得分:0)

如您所见,PVC上没有绑定Volume:,这意味着自动卷配置失败,并且未创建PV,应该使用您的Dynamic Provisioning配置来创建。您需要在describe命令的Volume:部分中查看创建的PV名称。 不幸的是,没有日志或事件显示该问题。

enter image description here

我建议您进行故障排除,以使用gp2手动创建storageclass,以查看它是否可以在以下yaml中使用,然后在您的PVC yaml文件上定义storageClassName,如下所示:

storageclass-manual-gp2.yaml:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: gp2-manual
parameters:
  type: gp2
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Delete
volumeBindingMode: Immediate

应用:

kubectl apply -f storageclass-manual-gp2.yaml

pv-manual.yaml:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-manual
spec:
  accessModes:
  - ReadWriteOnce
  awsElasticBlockStore:
    fsType: ext4
  capacity:
    storage: 30Gi
  persistentVolumeReclaimPolicy: Delete
  storageClassName: gp2-manual #your new storageclass name

应用:

kubectl apply -f pv-manual.yaml

描述PVC:

kubectl describe pvc pvc-gp2-manual

enter image description here

如果没有成功,我也建议您尝试使用其他storage type for AWS EBS

答案 1 :(得分:0)

问题似乎与我只运行一个主节点有关。 当我使用kops启动集群时,它将启动1个主节点和2个节点。问题没有出现。

我不确定直接导致问题的根本原因是什么,因为没有任何因素可以阻止一个节点具有外部EBS卷。这可能是CREATE TABLE dbo.StringDates (NotDate varchar(12), FormatString varchar(12)); GO INSERT INTO dbo.StringDates (NotDate, FormatString) VALUES('01122018','ddmmyyyy'), ('01132018','mmddyyyy'), ('20181802','yyyyddmm'), ('20180214','yyyymmdd'), ('2018-01-02','yyyy-mm-dd'), ('01/02/2018','dd-mm-yyyy'), ('010218','ddmmyy'); GO SELECT CASE FormatString WHEN 'ddmmyyyy' THEN TRY_CONVERT(date, STUFF(STUFF(NotDate,5,0,'/'),3,0,'/'),103) WHEN 'mmddyyyy' THEN TRY_CONVERT(date, STUFF(STUFF(NotDate,5,0,'/'),3,0,'/'),101) WHEN 'yyyyddmm' THEN TRY_CONVERT(date,CONCAT(LEFT(NotDate,4), RIGHT(NotDate,2),SUBSTRING(NotDate, 5,2)),112) WHEN 'yyyymmdd' THEN TRY_CONVERT(date,NotDate,120) WHEN 'yyyy-mm-dd' THEN TRY_CONVERT(date,NotDate,121) WHEN 'dd-mm-yyyy' THEN TRY_CONVERT(date,REPLACE(NotDate,'-','/'),103) WHEN 'ddmmyy' THEN TRY_CONVERT(date, STUFF(STUFF(NotDate,5,0,'/'),3,0,'/'),3) END, FormatString FROM dbo.StringDates 本身的错误,因为只有一个主节点才是例外而不是规则。