k8s 1.20.x版本NFS动态存储配置
2022/6/16 23:20:07
本文主要是介绍k8s 1.20.x版本NFS动态存储配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、nfs服务器安装nfs与配置
yum -y install nfs-utils rpcbind systemctl start rpcbind.service systemctl start nfs #配置 mkdir /data/nfs -p chow nfsnobody.nfsnobody /data/nfs cat>>/etc/exports<<EOF /data/nfs 172.16.208.0/20(rw,sync,no_root_squash,no_all_squash) EOF exportfs -arv
二、其它客户端服务器安装nfs-utils
yum install -y nfs-utils
三、master导入相应的nfs的yaml配置
github地址: https://github.com/kubernetes-retired/external-storage
1、下载yaml配置
wget https://raw.githubusercontent.com/kubernetes-retired/external-storage/master/nfs-client/deploy/rbac.yaml wget https://raw.githubusercontent.com/kubernetes-retired/external-storage/master/nfs-client/deploy/class.yaml wget https://raw.githubusercontent.com/kubernetes-retired/external-storage/master/nfs-client/deploy/deployment.yaml
2、导入rbac与class
kubectl apply -f class.yaml kubectl apply -f rbac.yaml
3、修改deploymet文件
[root@master ~]# cat deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nfs-client-provisioner labels: app: nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: default spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: nfs-client-provisioner template: metadata: labels: app: nfs-client-provisioner spec: serviceAccountName: nfs-client-provisioner containers: - name: nfs-client-provisioner image: quay.io/external_storage/nfs-client-provisioner:latest volumeMounts: - name: nfs-client-root mountPath: /persistentvolumes env: - name: PROVISIONER_NAME value: fuseim.pri/ifs - name: NFS_SERVER value: 172.16.208.176 #nfs服务器ip - name: NFS_PATH value: /data/nfs #nfs服务器的挂载目录 volumes: - name: nfs-client-root nfs: server: 172.16.208.176 #nfs服务器ip path: /data/nfs #nfs服务器的挂载目录
4、导入deploy
kubectl apply -f deployment.yaml
5、查看
[root@master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE nfs-client-provisioner-dfb75c8bb-42p8l 1/1 Running 0 80s [root@master ~]# kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE managed-nfs-storage fuseim.pri/ifs Delete Immediate false 5m56s
四、k8s1.20.1版本修改api-server配置
修改/etc/kubernetes/manifests/kube-apiserver.yaml 文件
添加添加- --feature-gates=RemoveSelfLink=false
[root@master ~]# grep -B 5 'feature-gates' /etc/kubernetes/manifests/kube-apiserver.yaml - --service-account-key-file=/etc/kubernetes/pki/sa.pub - --service-account-signing-key-file=/etc/kubernetes/pki/sa.key - --service-cluster-ip-range=10.96.0.0/12 - --tls-cert-file=/etc/kubernetes/pki/apiserver.crt - --tls-private-key-file=/etc/kubernetes/pki/apiserver.key - --feature-gates=RemoveSelfLink=false #添加内容
五、测试
[root@master ~]# cat test-pvc.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: test-claim annotations: volume.beta.kubernetes.io/storage-class: "managed-nfs-storage" spec: accessModes: - ReadWriteMany resources: requests: storage: 1Mi [root@master ~]# kubectl apply -f test-pvc.yaml persistentvolumeclaim/test-claim created [root@master ~]# kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE test-claim Bound pvc-eeb6dd0b-feb8-4884-999a-a15bcd27d7ea 1Mi RWX managed-nfs-storage 9m18s
这篇关于k8s 1.20.x版本NFS动态存储配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-23云原生周刊:利用 eBPF 增强 K8s
- 2024-12-20/kubernetes 1.32版本更新解读:新特性和变化一目了然
- 2024-12-19拒绝 Helm? 如何在 K8s 上部署 KRaft 模式 Kafka 集群?
- 2024-12-16云原生周刊:Kubernetes v1.32 正式发布
- 2024-12-13Kubernetes上运行Minecraft:打造开发者平台的例子
- 2024-12-12深入 Kubernetes 的健康奥秘:探针(Probe)究竟有多强?
- 2024-12-10运维实战:K8s 上的 Doris 高可用集群最佳实践
- 2024-12-022024年最好用的十大Kubernetes工具
- 2024-12-02OPA守门人:Kubernetes集群策略编写指南
- 2024-11-26云原生周刊:K8s 严重漏洞