-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to enable local storage #1313
Open
hardys
wants to merge
2
commits into
openshift-metal3:master
Choose a base branch
from
hardys:local_storage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,114 @@ | ||
#!/usr/bin/env bash | ||
set -eux -o pipefail | ||
|
||
source logging.sh | ||
source common.sh | ||
source utils.sh | ||
|
||
ASSETS_DIR=${ASSETS_DIR:-"${OCP_DIR}/enable-local-storage"} | ||
STORAGE_CLASS_NAME=${STORAGE_CLASS_NAME:-local-storage} | ||
|
||
|
||
function generate_subscription() { | ||
mkdir -p "${ASSETS_DIR}" | ||
|
||
cat >"${ASSETS_DIR}/01-local-storage-operator.yaml" <<EOF | ||
apiVersion: operators.coreos.com/v1alpha2 | ||
kind: OperatorGroup | ||
metadata: | ||
name: local-operator-group | ||
namespace: openshift-local-storage | ||
spec: | ||
targetNamespaces: | ||
- openshift-local-storage | ||
--- | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: Subscription | ||
metadata: | ||
name: local-storage-operator | ||
namespace: openshift-local-storage | ||
spec: | ||
installPlanApproval: Automatic | ||
name: local-storage-operator | ||
source: redhat-operators | ||
sourceNamespace: openshift-marketplace | ||
EOF | ||
} | ||
|
||
function generate_local_volume() { | ||
mkdir -p "${ASSETS_DIR}" | ||
|
||
cat >"${ASSETS_DIR}/02-local-volume.yaml" <<EOCR | ||
apiVersion: local.storage.openshift.io/v1 | ||
kind: LocalVolume | ||
metadata: | ||
name: ${STORAGE_CLASS_NAME} | ||
namespace: openshift-local-storage | ||
spec: | ||
logLevel: Normal | ||
managementState: Managed | ||
storageClassDevices: | ||
$(fill_local_storage) | ||
storageClassName: ${STORAGE_CLASS_NAME} | ||
volumeMode: Filesystem | ||
EOCR | ||
} | ||
|
||
|
||
function fill_local_storage() { | ||
if [ ! -z "${VM_EXTRADISKS_LIST}" ]; then | ||
cat <<EOF | ||
- devicePaths: | ||
EOF | ||
fi | ||
|
||
for disk in ${VM_EXTRADISKS_LIST}; do | ||
cat <<EOF | ||
- /dev/$disk | ||
EOF | ||
done | ||
} | ||
|
||
|
||
function deploy_local_storage() { | ||
oc adm new-project openshift-local-storage || true | ||
|
||
oc annotate --overwrite project openshift-local-storage openshift.io/node-selector='' | ||
|
||
if [[ "$OPENSHIFT_RELEASE_TYPE" == "ga" ]]; then | ||
generate_subscription | ||
echo "Creating local storage operator group and subscription..." | ||
oc apply -f "${ASSETS_DIR}/01-local-storage-operator.yaml" | ||
else | ||
oc project openshift-local-storage | ||
LSO_PATH=${LOCAL_STORAGE_OPERATOR_PATH:-$GOPATH/src/github.com/openshift/local-storage-operator} | ||
if [ ! -d $LSO_PATH ]; then | ||
echo "Did not find $LSO_PATH" 1>&2 | ||
exit 1 | ||
fi | ||
pushd ${LSO_PATH} | ||
make build | ||
# Run make deploy steps manually so we can override the default namespace | ||
pushd config/manager | ||
kustomize edit set image controller=controller:latest | ||
popd | ||
pushd config/default | ||
kustomize edit set namespace openshift-local-storage | ||
popd | ||
kustomize build config/default | oc apply -f - | ||
popd | ||
fi | ||
wait_for_crd "localvolumes.local.storage.openshift.io" | ||
|
||
generate_local_volume | ||
echo "Creating local volume and storage class..." | ||
oc apply -f "${ASSETS_DIR}/02-local-volume.yaml" | ||
} | ||
|
||
|
||
if [ "${VM_EXTRADISKS}" != "false" ]; then | ||
deploy_local_storage | ||
else | ||
echo "Cannot deploy local storage unless VM_EXTRADISKS is enabled" | ||
hardys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit 1 | ||
fi |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up idea: just clone or
go get
it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good idea, cloning when not present similar to other repos seems like the most consistent option