我家里有两台PC,我想为K8S制作测试实验室。
一台PC有很大的驱动器,所以我想把这个存储作为两个节点的avaliable。我发现的大部分信息都是关于本地存储或完全外部存储的。
理想情况下,我希望拥有完整的k8s解决方案,它可以通过部署进行自动标度(只需要多一个具有所需关联的节点,并且它也将被扩展到那里)。
那么,这是可能的吗?有导游怎么做吗?
发布于 2020-05-14 13:54:24
正如@David Maze已经提到的,在Kubernetes中没有共享节点存储的原生方式。
您可以做的是在具有最高存储空间的节点上设置NFS存储,并在pod中共享它。可以使用k8s将NFS设置为pod。NFS pod可能如下所示:
kind: Pod
apiVersion: v1
metadata:
name: nfs-server-pod
labels:
role: nfs
spec:
containers:
- name: nfs-server-container
image: cpuguy83/nfs-server
securityContext:
privileged: true
args:
# Pass the paths to share to the Docker image
- /exports您还必须使用一个pod来公开service
kind: Service
apiVersion: v1
metadata:
name: nfs-service
spec:
selector:
role: nfs
ports:
# Open the ports required by the NFS server
# Port 2049 for TCP
- name: tcp-2049
port: 2049
protocol: TCP
# Port 111 for UDP
- name: udp-111
port: 111
protocol: UDP一旦完成,您将能够将其用于集群中的任何pod:
kind: Pod
apiVersion: v1
metadata:
name: pod-using-nfs
spec:
# Add the server as an NFS volume for the pod
volumes:
- name: nfs-volume
nfs:
# URL for the NFS server
server: 10.108.211.244 # Change this!
path: /
# In this container, we'll mount the NFS volume
# and write the date to a file inside it.
containers:
- name: app
image: alpine
# Mount the NFS volume in the container
volumeMounts:
- name: nfs-volume
mountPath: /var/nfs
# Write to a file inside our NFS
command: ["/bin/sh"]
args: ["-c", "while true; do date >> /var/nfs/dates.txt; sleep 5; done"] 这是在库伯奈特卷指南上由马修·帕尔默完全描述的,您也应该阅读在Kubernetes中部署动态NFS配置。
https://stackoverflow.com/questions/61773762
复制相似问题