forked from rook/kubectl-rook-ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rook#4 from subhamkrai/initial-code
core: add initial code
- Loading branch information
Showing
5 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: kubectl plugin test | ||
on: | ||
pull_request: | ||
|
||
defaults: | ||
run: | ||
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell | ||
shell: bash --noprofile --norc -eo pipefail -x {0} | ||
|
||
jobs: | ||
Plugin-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: setup minikube | ||
uses: manusa/actions-setup-minikube@v2.4.2 | ||
with: | ||
minikube version: 'v1.23.2' | ||
kubernetes version: 'v1.22.2' | ||
start args: --memory 6g --cpus=2 | ||
github token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: print k8s cluster status | ||
run: | | ||
minikube status | ||
kubectl get nodes | ||
- name: use local disk | ||
run: tests/github-action-helper.sh use_local_disk | ||
|
||
- name: deploy rook cluster | ||
run: tests/github-action-helper.sh deploy_rook | ||
|
||
- name: wait for operator pod to be ready | ||
run: tests/github-action-helper.sh wait_for_pod_to_be_ready_state | ||
|
||
- name: Test pluging with ceph commands | ||
run: | | ||
# when we have the kubectl krew plugin available we can use like `kubectl rook-ceph` but for now in local deployment we have to use `kubectl rook_ceph` as kubectl plugin has this limitation. | ||
# Doc link to clear the comment above: | ||
# https://krew.sigs.k8s.io/docs/developer-guide/develop/naming-guide/ | ||
# https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/#naming-a-plugin | ||
# https://krew.sigs.k8s.io/docs/developer-guide/distributing-with-krew/ | ||
sudo install kubectl-rook-ceph.sh /usr/local/bin/kubectl-rook_ceph | ||
# run ceph commands with the plugin | ||
kubectl rook_ceph ceph status | ||
kubectl rook_ceph ceph status -f json | ||
kubectl rook_ceph ceph status --format json-pretty | ||
kubectl rook_ceph ceph mon dump | ||
kubectl rook_ceph ceph mon stat | ||
kubectl rook_ceph ceph osd tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: ShellCheck | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
shellcheck: | ||
name: Shellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run ShellCheck | ||
uses: ludeeus/action-shellcheck@master | ||
with: | ||
severity: warning | ||
check_together: 'yes' | ||
disable_matcher: false | ||
format: gcc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2021 The Rook Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eEuo pipefail | ||
|
||
usages() { | ||
cat <<EOF | ||
Description: | ||
'kubectl rook-ceph ceph' provides common management and troubleshooting tools for Ceph. | ||
Commands: | ||
ceph - run any 'ceph' CLI command as given | ||
args - any 'ceph' CLI argument or flag | ||
Usage: | ||
kubectl rook-ceph ceph [command] [args...] | ||
EOF | ||
} | ||
|
||
ceph_command() { | ||
kubectl --namespace rook-ceph exec deploy/rook-ceph-operator -- /bin/bash -c "${*} --conf=/var/lib/rook/rook-ceph/rook-ceph.config" | ||
} | ||
|
||
main() { | ||
if [ $# -ge 2 ]; then | ||
if [ "$1" = "ceph" ]; then | ||
ceph_command "$@" | ||
fi | ||
else | ||
usages | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eEuo pipefail | ||
|
||
# source https://github.com/rook/rook | ||
use_local_disk() { | ||
sudo swapoff --all --verbose | ||
sudo umount /mnt | ||
# search for the device since it keeps changing between sda and sdb | ||
sudo wipefs --all --force /dev/$(lsblk|awk '/14G/ {print $1}'| head -1)1 | ||
sudo lsblk | ||
} | ||
|
||
deploy_rook() { | ||
kubectl create -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/common.yaml | ||
kubectl create -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/crds.yaml | ||
kubectl create -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/operator.yaml | ||
curl https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/cluster-test.yaml -o cluster-test.yaml | ||
sed -i "s|#deviceFilter:|deviceFilter: $(lsblk|awk '/14G/ {print $1}'| head -1)|g" cluster-test.yaml | ||
kubectl create -f cluster-test.yaml | ||
} | ||
|
||
# wait_for_pod_to_be_ready_state check for operator pod to in ready state | ||
wait_for_pod_to_be_ready_state() { | ||
timeout 20 bash <<-'EOF' | ||
until [ $(kubectl get pod -l app=rook-ceph-operator -n rook-ceph -o jsonpath='{.items[*].metadata.name}' -o custom-columns=READY:status.containerStatuses[*].ready | grep -c true) -eq 1 ]; do | ||
echo "waiting for the pods to be in ready state" | ||
sleep 1 | ||
done | ||
EOF | ||
|
||
} |