【发布时间】:2020-02-25 03:23:25
【问题描述】:
使用 MicroK8s 的存储附加组件,持久卷声明默认在主机系统上的 /var/snap/microk8s/common/default-storage 下提供存储。怎么改?
查看hostpath-provisioner pod 的声明,显示有一个名为PV_DIR 的环境设置指向/var/snap/microk8s/common/default-storage - 似乎是我想要更改的内容,但怎么做?
不确定我是在问 MicroK8s 的具体问题,还是一般来说这是否适用于 Kubernetes?
$ microk8s.kubectl describe -n kube-system pod/hostpath-provisioner-7b9cb5cdb4-q5jh9
Name: hostpath-provisioner-7b9cb5cdb4-q5jh9
Namespace: kube-system
Priority: 0
Node: ...
Start Time: ...
Labels: k8s-app=hostpath-provisioner
pod-template-hash=7b9cb5cdb4
Annotations: <none>
Status: Running
IP: ...
IPs:
IP: ...
Controlled By: ReplicaSet/hostpath-provisioner-7b9cb5cdb4
Containers:
hostpath-provisioner:
Container ID: containerd://0b74a5aa06bfed0a66dbbead6306a0bc0fd7e46ec312befb3d97da32ff50968a
Image: cdkbot/hostpath-provisioner-amd64:1.0.0
Image ID: docker.io/cdkbot/hostpath-provisioner-amd64@sha256:339f78eabc68ffb1656d584e41f121cb4d2b667565428c8dde836caf5b8a0228
Port: <none>
Host Port: <none>
State: Running
Started: ...
Last State: Terminated
Reason: Unknown
Exit Code: 255
Started: ...
Finished: ...
Ready: True
Restart Count: 3
Environment:
NODE_NAME: (v1:spec.nodeName)
PV_DIR: /var/snap/microk8s/common/default-storage
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from microk8s-hostpath-token-nsxbp (ro)
/var/snap/microk8s/common/default-storage from pv-volume (rw)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
pv-volume:
Type: HostPath (bare host directory volume)
Path: /var/snap/microk8s/common/default-storage
HostPathType:
microk8s-hostpath-token-nsxbp:
Type: Secret (a volume populated by a Secret)
SecretName: microk8s-hostpath-token-nsxbp
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events: <none>
【问题讨论】:
-
您能告诉我您是如何安装主机路径的吗?根据文档您可以使用hostPath 为您自己的光伏路径。
-
对于 MicroK8s,它通过命令
microk8s.enable storage与存储插件一起安装。感谢您的链接,我会尝试hostPath.path声明。 -
嗨@Bjorn Thor Jonsson,它有效还是您仍然有这个问题?
-
我能够应用具有自定义 spec.hostPath.path 值的持久卷声明和引用 PV 声明的 storageClassName 的持久卷声明。但是当我尝试应用另一个引用相同 PV 名称的 PVC 时,它只是挂在 MicroK8s 中。我猜我可以为每个 PVC 设置一个 PV,但这似乎很奇怪。
标签: kubernetes microk8s