我的rancher部署好了跑了不少测试应用,
现在是要部署一套rabbitmq集群,用到了storageclass。我们使用nfs-client-provisioner提供相关服务;
相关yaml如下:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: managed-nfs-storage
provisioner: kyle-nfs-client-provisioner # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
archiveOnDelete: "false"
pathPattern: "\${.PVC.namespace}/${.PVC.annotations.nfs.io/storage-path}"
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-client-provisioner
labels:
app: nfs-client-provisioner
namespace: sp-poc
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
imagePullPolicy: IfNotPresent
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: kyle-nfs-storageclass
- name: NFS_SERVER
value: 10.230.3.7
- name: NFS_PATH
value: /sp-poc-share-files
volumes:
- name: nfs-client-root
nfs:
server: 10.230.3.7
path: /sp-poc-share-files
\# replace with namespace where provisioner is deployed
namespace: sp-poc
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-client-provisioner-runner
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: run-nfs-client-provisioner
subjects:
- kind: ServiceAccount
name: nfs-client-provisioner
\# replace with namespace where provisioner is deployed
namespace: sp-poc
roleRef:
kind: ClusterRole
name: nfs-client-provisioner-runner
apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: leader-locking-nfs-client-provisioner
\# replace with namespace where provisioner is deployed
namespace: sp-poc
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: leader-locking-nfs-client-provisioner
# replace with namespace where provisioner is deployed
namespace: sp-poc
subjects:
- kind: ServiceAccount
name: nfs-client-provisioner
# replace with namespace where provisioner is deployed
namespace: sp-poc
roleRef:
kind: Role
name: leader-locking-nfs-client-provisioner
apiGroup: rbac.authorization.k8s.io
上面的yaml执行完了,也没有报错
kubectl get pod -n sp-poc检车也没有问题
创建的test-pvc如下:
apiVersion: v1
metadata:
name: test-claim
namespace: sp-poc
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi
执行以后,这个Pvc一直处于pending状态。
网络的解决方案,添加SelfLink也加过,修改集群的yaml
kube-api:
always_pull_images: false
extra_args:
feature-gates: RemoveSelfLink=false
接下来实在不知道要怎么弄了。 因为我们的服务器是离线的,不可出网。所以在线的解决方案就不能用了。