-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-ceph-csi-from-vstart-cluster
executable file
·155 lines (137 loc) · 3.82 KB
/
init-ceph-csi-from-vstart-cluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
set -x
ceph () {
"$HOME/WORKSPACE/ceph/build/bin/ceph" \
-c "$HOME/WORKSPACE/ceph/build/ceph.conf" \
"$@" 2>/dev/null
}
KEY="$(ceph auth get-key client.admin)"
kubectl create secret generic csi-cephfs-secret \
--from-literal=userID=admin \
--from-literal=userKey="$KEY" \
--from-literal=adminID=admin \
--from-literal=adminKey="$KEY"
FSID="$(ceph fsid)"
# Node: format must be <hostname/ip>:port. Checking done by
# mount.cephfs error 'failed to resolve source
MON="$(ceph mon dump --format json | jq -r '.mons[] | .addr' | sed -e 's/\/0//')"
MON2="$(ceph mon dump --format json | jq -r '.mons[] | .public_addrs[] | map(select(.type == "v2")) |.[].addr')"
MON_ADDR="${MON2%:*}"
MON_PORT="${MON2#*:}"
# rook {{{
kubectl create namespace rook-ceph
kubectl delete --namespace rook-ceph secret rook-ceph-mon
kubectl create --namespace rook-ceph secret generic rook-ceph-mon \
--from-literal=ceph-username=client.admin \
--from-literal=ceph-secret="$KEY"
kubectl apply --namespace rook-ceph -f- <<EOF
apiVersion: v1
kind: ConfigMap
data:
csi-cluster-config-json: '[{"clusterID":"$FSID","monitors":["$MON2"]}]'
data: 'a=$MON2'
metadata:
name: rook-ceph-mon-endpoints
EOF
kubectl apply --namespace rook-ceph -f- <<EOF
apiVersion: v1
kind: Endpoints
metadata:
name: rook-ceph-mon
subsets:
- addresses:
- ip: $MON_ADDR
ports:
- port: $MON_PORT
EOF
kubectl apply --namespace rook-ceph -f- <<EOF
apiVersion: v1
kind: Service
metadata:
name: rook-ceph-mon
spec:
clusterIP: None
ports:
- protocol: TCP
port: $MON_PORT
targetPort: $MON_PORT
EOF
# }}}
kubectl create -f- <<EOF
apiVersion: v1
kind: ConfigMap
data:
config.json: |-
[
{
"clusterID": "$FSID",
"monitors": [
"$MON", "$MON2"
]
}
]
metadata:
name: ceph-csi-config
EOF
kubectl create -f- <<EOF
---
apiVersion: v1
kind: ConfigMap
data:
ceph.conf: |
$(ceph config generate-minimal-conf | awk '/^[^#]/ { print " ", $0 }')
# Workaround for http://tracker.ceph.com/issues/23446
fuse_set_user_groups = false
# ceph-fuse which uses libfuse2 by default has write buffer size of 2KiB
# adding 'fuse_big_writes = true' option by default to override this limit
# see https://github.com/ceph/ceph-csi/issues/1928
fuse_big_writes = true
keyring: |
$(ceph auth get client.admin | awk '{ print " ", $0 }')
metadata:
name: ceph-config
EOF
kubectl create -f- <<EOF
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: csi-cephfs-sc
provisioner: cephfs.csi.ceph.com
parameters:
clusterID: $FSID
fsName: $(ceph fs ls --format=json | jq -r '.[0]["name"]')
csi.storage.k8s.io/provisioner-secret-name: csi-cephfs-secret
csi.storage.k8s.io/provisioner-secret-namespace: default
csi.storage.k8s.io/controller-expand-secret-name: csi-cephfs-secret
csi.storage.k8s.io/controller-expand-secret-namespace: default
csi.storage.k8s.io/node-stage-secret-name: csi-cephfs-secret
csi.storage.k8s.io/node-stage-secret-namespace: default
reclaimPolicy: Delete
allowVolumeExpansion: true
mountOptions:
- debug
EOF
kubectl create -f- <<EOF
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: csi-cephfs-sc-fscrypt-dummy
provisioner: cephfs.csi.ceph.com
parameters:
clusterID: $FSID
fsName: $(ceph fs ls --format=json | jq -r '.[0]["name"]')
csi.storage.k8s.io/provisioner-secret-name: csi-cephfs-secret
csi.storage.k8s.io/provisioner-secret-namespace: default
csi.storage.k8s.io/controller-expand-secret-name: csi-cephfs-secret
csi.storage.k8s.io/controller-expand-secret-namespace: default
csi.storage.k8s.io/node-stage-secret-name: csi-cephfs-secret
csi.storage.k8s.io/node-stage-secret-namespace: default
kernelMountOptions: test_dummy_encryption
mounter: kernel
reclaimPolicy: Delete
allowVolumeExpansion: true
mountOptions:
- debug
EOF