Pod 具有未绑定的 PersistentVolumeClaims,但卷声明是有界的
Pod has unbound PersistentVolumeClaims but volume claims is bounded
我想在 virtualbox 上的 kubernetes 中创建一个 statefulset elasticsearch。我没有使用云提供商,所以我在本地为我的 statefulset 的两个副本创建了两个持久卷:
pv0:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-elk-0
namespace: elk
labels:
type: local
spec:
storageClassName: gp2
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/pv0"
pv1:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-elk-1
namespace: elk
labels:
type: local
spec:
storageClassName: gp2
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/pv1"
状态集:
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: elasticsearch-logging
namespace: elk
labels:
k8s-app: elasticsearch-logging
version: v5.6.2
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
spec:
serviceName: elasticsearch-logging
replicas: 2
selector:
matchLabels:
k8s-app: elasticsearch-logging
version: v5.6.2
template:
metadata:
labels:
k8s-app: elasticsearch-logging
version: v5.6.2
kubernetes.io/cluster-service: "true"
spec:
serviceAccountName: elasticsearch-logging
containers:
- image: gcr.io/google-containers/elasticsearch:v5.6.2
name: elasticsearch-logging
ports:
- containerPort: 9200
name: db
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
resources:
limits:
cpu: 0.1
volumeMounts:
- name: elasticsearch-logging
mountPath: /data
env:
- name: "NAMESPACE"
valueFrom:
fieldRef:
fieldPath: metadata.namespace
initContainers:
- image: alpine:3.6
command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
name: elasticsearch-logging-init
securityContext:
privileged: true
volumeClaimTemplates:
- metadata:
name: elasticsearch-logging
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: gp2
resources:
requests:
storage: 5Gi
持久卷似乎已正确弹回,但 pod 始终处于崩溃循环并每次都重新启动。是因为使用了 initContainer 还是我的 yaml 有问题?
添加更多 Ram,扩展集群。
我想在 virtualbox 上的 kubernetes 中创建一个 statefulset elasticsearch。我没有使用云提供商,所以我在本地为我的 statefulset 的两个副本创建了两个持久卷:
pv0:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-elk-0
namespace: elk
labels:
type: local
spec:
storageClassName: gp2
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/pv0"
pv1:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-elk-1
namespace: elk
labels:
type: local
spec:
storageClassName: gp2
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/pv1"
状态集:
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: elasticsearch-logging
namespace: elk
labels:
k8s-app: elasticsearch-logging
version: v5.6.2
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
spec:
serviceName: elasticsearch-logging
replicas: 2
selector:
matchLabels:
k8s-app: elasticsearch-logging
version: v5.6.2
template:
metadata:
labels:
k8s-app: elasticsearch-logging
version: v5.6.2
kubernetes.io/cluster-service: "true"
spec:
serviceAccountName: elasticsearch-logging
containers:
- image: gcr.io/google-containers/elasticsearch:v5.6.2
name: elasticsearch-logging
ports:
- containerPort: 9200
name: db
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
resources:
limits:
cpu: 0.1
volumeMounts:
- name: elasticsearch-logging
mountPath: /data
env:
- name: "NAMESPACE"
valueFrom:
fieldRef:
fieldPath: metadata.namespace
initContainers:
- image: alpine:3.6
command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
name: elasticsearch-logging-init
securityContext:
privileged: true
volumeClaimTemplates:
- metadata:
name: elasticsearch-logging
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: gp2
resources:
requests:
storage: 5Gi
持久卷似乎已正确弹回,但 pod 始终处于崩溃循环并每次都重新启动。是因为使用了 initContainer 还是我的 yaml 有问题?
添加更多 Ram,扩展集群。