企业项目实战k8s篇(十七)Helm部署nfs-client-provisioner
Helm部署nfs-client-provisioner预先配置好外部的NFS服务器共享目录路径 /mnt/nfs拉取nfs-provisioner-v4.0.2镜像,上传至harbor[root@server3 ~]# docker load-i nfs-provisioner-v4.0.2.tar1a5ede0c966b: Loading layer [====================
·
Helm部署nfs-client-provisioner
预先配置好外部的NFS服务器
共享目录路径 /mnt/nfs
拉取nfs-provisioner-v4.0.2
镜像,上传至harbor
[root@server3 ~]# docker load -i nfs-provisioner-v4.0.2.tar
1a5ede0c966b: Loading layer [==================================================>] 3.052MB/3.052MB
ad321585b8f5: Loading layer [==================================================>] 42.02MB/42.02MB
Loaded image: reg.westos.org/sig-storage/nfs-subdir-external-provisioner:v4.0.2
[root@server3 ~]# docker push reg.westos.org/sig-storage/nfs-subdir-external-provisioner:v4.0.2
The push refers to repository [reg.westos.org/sig-storage/nfs-subdir-external-provisioner]
ad321585b8f5: Pushed
1a5ede0c966b: Pushed
v4.0.2: digest: sha256:f741e403b3ca161e784163de3ebde9190905fdbf7dfaa463620ab8f16c0f6423 size: 739
删除之前在集群手动
部署的nfs-client-provisioner
[root@server1 volumes]# cd nfs-client/
[root@server1 nfs-client]# ls
claim.yaml nfs-client-provisioner.yaml pod.yml test-pod.yaml
[root@server1 nfs-client]# kubectl delete -f nfs-client-provisioner.yaml
serviceaccount "nfs-client-provisioner" deleted
clusterrole.rbac.authorization.k8s.io "nfs-client-provisioner-runner" deleted
clusterrolebinding.rbac.authorization.k8s.io "run-nfs-client-provisioner" deleted
role.rbac.authorization.k8s.io "leader-locking-nfs-client-provisioner" deleted
rolebinding.rbac.authorization.k8s.io "leader-locking-nfs-client-provisioner" deleted
deployment.apps "nfs-client-provisioner" deleted
storageclass.storage.k8s.io "managed-nfs-storage" deleted
[root@server1 nfs-client]# kubectl get ns
NAME STATUS AGE
default Active 10d
ingress-nginx Active 6d23h
kube-node-lease Active 10d
kube-public Active 10d
kube-system Active 10d
kubernetes-dashboard Active 6h47m
metallb-system Active 7d5h
nfs-client-provisioner Active 4d6h
[root@server1 nfs-client]# kubectl -n nfs-client-provisioner get all
No resources found in nfs-client-provisioner namespace.
删除之前实验多余的pvc,纯净环境,避免影响实验
[root@server1 nfs-client]# kubectl delete pvc --all
persistentvolumeclaim "redis-data-redis-cluster-0" deleted
persistentvolumeclaim "redis-data-redis-cluster-1" deleted
persistentvolumeclaim "redis-data-redis-cluster-2" deleted
persistentvolumeclaim "redis-data-redis-cluster-3" deleted
persistentvolumeclaim "redis-data-redis-cluster-4" deleted
persistentvolumeclaim "redis-data-redis-cluster-5" deleted
[root@server1 nfs-client]# kubectl get pvc
No resources found in default namespace.
查找nfs-subdir-external-provisioner
仓库
[root@server1 nfs-client]# helm search hub nfs-subdir-external-provisioner
URL CHART VERSION APP VERSION DESCRIPTION
https://hub.helm.sh/charts/nfs-subdir-external-... 4.0.12 4.0.2 nfs-subdir-external-provisioner is an automatic...
https://hub.helm.sh/charts/wenerme/nfs-subdir-e... 4.0.12 4.0.2 nfs-subdir-external-provisioner is an automatic...
https://hub.helm.sh/charts/k8s-edu/nfs-subdir-e... 4.0.12 4.0.2 nfs-subdir-external-provisioner is an automatic...
添加nfs-subdir-external-provisioner
到repo
[root@server1 nfs-client]# helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
[root@server1 helm]# helm repo list
NAME URL
bitnami https://charts.bitnami.com/bitnami
westos https://reg.westos.org/chartrepo/charts
nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
拉取nfs-subdir-external-provisioner-4.0.12.tgz
helm pull nfs-subdir-external-provisioner/nfs-subdir-external-provisioner
解压压缩包
[root@server1 nfs-subdir-external-provisioner]# tar zxf nfs-subdir-external-provisioner-4.0.12.tgz
[root@server1 nfs-subdir-external-provisioner]# ls
nfs-subdir-external-provisioner nfs-subdir-external-provisioner-4.0.12.tgz
[root@server1 nfs-subdir-external-provisioner]# cd nfs-subdir-external-provisioner/
[root@server1 nfs-subdir-external-provisioner]# ls
Chart.yaml ci README.md templates values.yaml
修改values.yaml内容
[root@server1 nfs-subdir-external-provisioner]# cat values.yaml
replicaCount: 1
strategyType: Recreate
image:
repository: sig-storage/nfs-subdir-external-provisioner
tag: v4.0.2
pullPolicy: IfNotPresent
imagePullSecrets: []
nfs:
server: 172.25.3.1
path: /mnt/nfs
mountOptions:
volumeName: nfs-subdir-external-provisioner-root
# For creating the StorageClass automatically:
storageClass:
create: true
# Set a provisioner name. If unset, a name will be generated.
# provisionerName:
# Set StorageClass as the default StorageClass
# Ignored if storageClass.create is false
defaultClass: true
# Set a StorageClass name
# Ignored if storageClass.create is false
name: nfs-client
# Allow volume to be expanded dynamically
allowVolumeExpansion: true
# Method used to reclaim an obsoleted volume
reclaimPolicy: Delete
# When set to false your PVs will not be archived by the provisioner upon deletion of the PVC.
archiveOnDelete: false
# If it exists and has 'delete' value, delete the directory. If it exists and has 'retain' value, save the directory.
# Overrides archiveOnDelete.
# Ignored if value not set.
onDelete:
# Specifies a template for creating a directory path via PVC metadata's such as labels, annotations, name or namespace.
# Ignored if value not set.
pathPattern:
# Set access mode - ReadWriteOnce, ReadOnlyMany or ReadWriteMany
accessModes: ReadWriteOnce
# Storage class annotations
annotations: {}
leaderElection:
# When set to false leader election will be disabled
enabled: true
## For RBAC support:
rbac:
# Specifies whether RBAC resources should be created
create: true
# If true, create & use Pod Security Policy resources
# https://kubernetes.io/docs/concepts/policy/pod-security-policy/
podSecurityPolicy:
enabled: false
# Deployment pod annotations
podAnnotations: {}
## Set pod priorityClassName
# priorityClassName: ""
serviceAccount:
# Specifies whether a ServiceAccount should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name:
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
# Additional labels for any resource created
labels: {}
部署nfs-client-provisioner
,指定NAMESPACE: nfs-client-provisioner
[root@server1 nfs-subdir-external-provisioner]# helm install nfs-client-provisioner . -n nfs-client-provisioner
NAME: nfs-client-provisioner
LAST DEPLOYED: Wed Aug 4 05:24:00 2021
NAMESPACE: nfs-client-provisioner
STATUS: deployed
REVISION: 1
TEST SUITE: None
查看部署信息,部署成功
[root@server1 nfs-subdir-external-provisioner]# helm list -n nfs-client-provisioner
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nfs-client-provisioner nfs-client-provisioner 1 2021-08-04 05:24:00.052383862 -0400 EDT deployed nfs-subdir-external-provisioner-4.0.12 4.0.2
测试脚本,创建pvc,用于查看nfs功能是否能正常使用
[root@server1 nfs-client]# cat claim.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nfs-pv1
annotations:
#volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
执行脚本,可以查看到pvc信息,说明nfs正常使用
[root@server1 nfs-client]# kubectl apply -f claim.yaml
persistentvolumeclaim/nfs-pv1 created
[root@server1 nfs-client]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
nfs-pv1 Bound pvc-1adddf7b-0a76-45da-a020-2d49178807ea 100Mi RWX nfs-client 3s
撤销部署,pvc自动回收
[root@server1 nfs-client]# kubectl delete -f claim.yaml
persistentvolumeclaim "nfs-pv1" deleted
[root@server1 nfs-client]# kubectl get pvc
No resources found in default namespace.
更多推荐
已为社区贡献14条内容
所有评论(0)