Skip to content

Commit b739586

Browse files
Merge pull request #926 from fmount/rook
Add rook_deploy target
2 parents 49703a0 + 45c124f commit b739586

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,7 @@ ceph_cleanup: ## deletes the ceph pod
21452145
${CLEANUP_DIR_CMD} ${DEPLOY_DIR}
21462146

21472147
##@ ROOK
2148+
21482149
.PHONY: rook_prep
21492150
rook_prep: ### deploy rook operator
21502151
$(eval $(call vars,$@,ceph))
@@ -2165,6 +2166,25 @@ rook: namespace rook_prep ## installs the CRDs and the operator, also runs the p
21652166
## Do not deploy NFS CEPH-CSI
21662167
oc -n rook-ceph patch configmap rook-ceph-operator-config --type='merge' -p '{"data": { "ROOK_CSI_ENABLE_CEPHFS": "false" }}'
21672168

2169+
.PHONY: rook_deploy_prep
2170+
rook_deploy_prep: export IMAGE=${CEPH_IMG}
2171+
rook_deploy_prep: # ceph_deploy_cleanup ## prepares the CR to install the service based on the service sample
2172+
$(eval $(call vars,$@,ceph))
2173+
# Patch the rook-ceph scc to allow using hostnetworking: this simulates an
2174+
# external ceph cluster
2175+
oc patch scc rook-ceph --type='merge' -p '{ "allowHostNetwork": true, "allowHostPID": true, "allowHostPorts": true}'
2176+
bash scripts/gen-rook-kustomize.sh
2177+
2178+
.PHONY: rook_deploy
2179+
rook_deploy: rook_deploy_prep ## installs the service instance using kustomize.
2180+
$(eval $(call vars,$@,ceph))
2181+
oc kustomize ${DEPLOY_DIR} | oc apply -f -
2182+
2183+
.PHONY: rook_crc_disk
2184+
rook_crc_disk: ## Create a disk and attach to CRC / SNO VM
2185+
$(eval $(call vars,$@,ceph))
2186+
bash scripts/disk-setup.sh
2187+
21682188
.PHONY: rook_cleanup
21692189
rook_cleanup: ## deletes rook resources
21702190
$(eval $(call vars,$@,ceph))

scripts/disk-setup.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
set -ex
18+
declare -a DISKS=("vdb")
19+
DISK_SIZE=${DISK_SIZE:-100}
20+
DISK_PATH=${DISK_PATH:-$HOME/.crc}
21+
DOMAIN=${DOMAIN:-crc}
22+
23+
mkdir -p "$DISK_PATH"
24+
25+
function create_disk {
26+
for disk in "${DISKS[@]}"; do
27+
qemu-img create -f raw "$DISK_PATH"/"$disk" "${DISK_SIZE}"G
28+
done
29+
}
30+
31+
function attach_disk {
32+
for disk in "${DISKS[@]}"; do
33+
sudo virsh attach-disk "$DOMAIN" "$DISK_PATH"/"$disk" "$disk" --targetbus virtio --persistent
34+
done
35+
}
36+
37+
create_disk
38+
attach_disk

scripts/gen-rook-kustomize.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
set -ex
17+
18+
# expect that the common.sh is in the same dir as the calling script
19+
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
20+
. ${SCRIPTPATH}/common.sh --source-only
21+
22+
if [ -z "$IMAGE" ]; then
23+
echo "Unable to determine ceph image."
24+
exit 1
25+
fi
26+
27+
if [ ! -d "${DEPLOY_DIR}" ]; then
28+
mkdir -p "${DEPLOY_DIR}"
29+
fi
30+
31+
pushd "${DEPLOY_DIR}"
32+
33+
cat <<EOF >kustomization.yaml
34+
apiVersion: kustomize.config.k8s.io/v1beta1
35+
kind: Kustomization
36+
resources:
37+
- ./cluster-test.yaml
38+
namespace: rook-ceph
39+
patches:
40+
- target:
41+
kind: CephCluster
42+
patch: |-
43+
- op: replace
44+
path: /spec/cephVersion/image
45+
value: $IMAGE
46+
EOF
47+
48+
kustomization_add_resources

0 commit comments

Comments
 (0)