[Agent][Deploy] - cmii update accomplish
This commit is contained in:
22
agent-deploy/b_nfs/DeployNFS.go
Executable file
22
agent-deploy/b_nfs/DeployNFS.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package b_nfs
|
||||
|
||||
import (
|
||||
"wdd.io/agent-common/logger"
|
||||
"wdd.io/agent-deploy/z_dep"
|
||||
)
|
||||
|
||||
var (
|
||||
log = logger.Log
|
||||
)
|
||||
|
||||
type NfsDeployConfig struct {
|
||||
NfsLocalPath string
|
||||
}
|
||||
|
||||
func NFSDeploy(commonEnv *z_dep.CommonEnvironmentConfig) bool {
|
||||
return commonEnv.ParseCommonEnvToApplyFile(CmiiNfsTemplate, z_dep.NfsApplyFilePath)
|
||||
}
|
||||
|
||||
func NFSTestDeploy(commonEnv *z_dep.CommonEnvironmentConfig) bool {
|
||||
return commonEnv.ParseCommonEnvToApplyFile(CmiiNFSTestTemplate, z_dep.NfsTestApplyFilePath)
|
||||
}
|
||||
119
agent-deploy/b_nfs/TemplateNFS.go
Executable file
119
agent-deploy/b_nfs/TemplateNFS.go
Executable file
@@ -0,0 +1,119 @@
|
||||
package b_nfs
|
||||
|
||||
const CmiiNfsTemplate = `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: nfs-client-provisioner
|
||||
# replace with namespace where provisioner is deployed
|
||||
namespace: kube-system #根据实际环境设定namespace,下面类同
|
||||
---
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: nfs-client-provisioner-runner
|
||||
rules:
|
||||
- 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: kube-system
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
# name: nfs-client-provisioner-runner
|
||||
name: cluster-admin
|
||||
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: kube-system
|
||||
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
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: nfs-client-provisioner
|
||||
# replace with namespace where provisioner is deployed
|
||||
namespace: kube-system
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: leader-locking-nfs-client-provisioner
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
|
||||
---
|
||||
apiVersion: storage.k8s.io/v1
|
||||
kind: StorageClass
|
||||
metadata:
|
||||
name: nfs-prod-distribute
|
||||
provisioner: cmlc-nfs-storage #这里的名称要和provisioner配置文件中的环境变量PROVISIONER_NAME保持一致parameters: archiveOnDelete: "false"
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nfs-client-provisioner
|
||||
labels:
|
||||
app: nfs-client-provisioner
|
||||
# replace with namespace where provisioner is deployed
|
||||
namespace: kube-system #与RBAC文件中的namespace保持一致
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nfs-client-provisioner
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nfs-client-provisioner
|
||||
spec:
|
||||
serviceAccountName: nfs-client-provisioner
|
||||
containers:
|
||||
- name: nfs-client-provisioner
|
||||
{{- if .HarborPort }}
|
||||
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/nfs-subdir-external-provisioner:v4.0.2
|
||||
{{- else }}
|
||||
image: {{ .HarborIP }}nfs-subdir-external-provisioner:v4.0.2
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: nfs-client-root
|
||||
mountPath: /persistentvolumes
|
||||
env:
|
||||
- name: PROVISIONER_NAME
|
||||
value: cmlc-nfs-storage
|
||||
- name: NFS_SERVER
|
||||
value: {{ .NFSServerIP }}
|
||||
- name: NFS_PATH
|
||||
value: /var/lib/docker/nfs_data
|
||||
volumes:
|
||||
- name: nfs-client-root
|
||||
nfs:
|
||||
server: {{ .NFSServerIP }}
|
||||
path: /var/lib/docker/nfs_data
|
||||
`
|
||||
43
agent-deploy/b_nfs/TemplateNFSTest.go
Executable file
43
agent-deploy/b_nfs/TemplateNFSTest.go
Executable file
@@ -0,0 +1,43 @@
|
||||
package b_nfs
|
||||
|
||||
const CmiiNFSTestTemplate = `
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: test-claim
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: "nfs-prod-distribute" #与nfs-StorageClass.yaml metadata.name保持一致
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: nfs-prod-distribute
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Mi
|
||||
---
|
||||
kind: Pod
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: test-pod
|
||||
spec:
|
||||
containers:
|
||||
- name: test-pod
|
||||
{{- if .HarborPort }}
|
||||
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/busybox:latest
|
||||
{{- else }}
|
||||
image: {{ .HarborIP }}busybox:latest
|
||||
{{- end }}
|
||||
command:
|
||||
- "/bin/sh"
|
||||
args:
|
||||
- "-c"
|
||||
- "touch /mnt/NFS-CREATE-SUCCESS && exit 0 || exit 1" #创建一个SUCCESS文件后退出
|
||||
volumeMounts:
|
||||
- name: nfs-pvc
|
||||
mountPath: "/mnt"
|
||||
restartPolicy: "Never"
|
||||
volumes:
|
||||
- name: nfs-pvc
|
||||
persistentVolumeClaim:
|
||||
claimName: test-claim #与PVC名称保持一致
|
||||
`
|
||||
Reference in New Issue
Block a user