Skip to content

Instantly share code, notes, and snippets.

@No9
Last active March 31, 2020 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save No9/dac13bd05912cd2165301c678d20209e to your computer and use it in GitHub Desktop.
Save No9/dac13bd05912cd2165301c678d20209e to your computer and use it in GitHub Desktop.
install-cos-openshift.sh
#/bin/sh
# Default script for provisining a core dump handler environment.
# See: https://github.com/No9/ibm-core-dump-handler
# Assumes login of ibmcloud is already performed and helm v3 is installed on the local machine
# Change this clustername to install on the specific cluster or pass it with -c
# e.g. ./install-cos.sh -c kcdt-test-002
CLUSTER_NAME='kcdt-test-002'
for i in "$@"
do
case $i in
-c=*|--CLUSTER_NAME=*)
CLUSTER_NAME="${i#*=}"; shift
esac
done
# Using awk as the --json option is broken as it only returns one cluster
CLUSTER_ID=$(ibmcloud ks clusters ls | awk -v pat=$CLUSTER_NAME '{ if ( $1~pat) { print( $2 ) } }')
CLUSTER_INFO=$(ibmcloud ks cluster get -c $CLUSTER_ID --json)
RES_GRP=$(echo $CLUSTER_INFO | jq -r '.resourceGroup')
RES_GRP_NAME=$(echo $CLUSTER_INFO | jq -r '.resourceGroupName')
SERVICE_INSTANCE_NAME=$CLUSTER_NAME-cos-kcdt
SERVICE_INSTANCE_KEY=$CLUSTER_NAME-key-kcdt
ibmcloud resource service-instance-create $SERVICE_INSTANCE_NAME cloud-object-storage Standard global -g $RES_GRP_NAME
ibmcloud resource service-key-create $SERVICE_INSTANCE_KEY 'Manager' --instance-name $SERVICE_INSTANCE_NAME -p "{\"HMAC\":true}"
SERVICE_CRED=$(ibmcloud resource service-key $SERVICE_INSTANCE_KEY --output json)
#cos_hmac_keys section, note the access_key_id and the secret_access_key.
ACCESS_KEY_ID=$(echo $SERVICE_CRED | jq -r '.[0].credentials.cos_hmac_keys.access_key_id')
SECRET_ACCESS_KEY=$(echo $SERVICE_CRED | jq -r '.[0].credentials.cos_hmac_keys.secret_access_key')
SERVICE_INSTANCE_ID=$(ibmcloud resource service-instance $SERVICE_INSTANCE_NAME | grep GUID)
oc new-project ibm-observe
oc create secret generic cos-write-access --type=ibm/ibmc-s3fs --from-literal=access-key=$ACCESS_KEY_ID \ --from-literal=secret-key=$SECRET_ACCESS_KEY -n ibm-observe
oc adm policy add-scc-to-user privileged -z coredump-admin
helm repo add ibm-charts https://icr.io/helm/ibm-charts
helm repo update
helm fetch --untar ibm-charts/ibm-object-storage-plugin
helm plugin install ./ibm-object-storage-plugin/helm-ibmc
HELM_PLUGINS=$(helm env | grep HELM_PLUGINS | sed -e 's/HELM_PLUGINS=//g' | sed -e 's/"//g')
chmod 755 $HELM_PLUGINS/helm-ibmc/ibmc.sh
helm ibmc install ibm-object-storage-plugin ibm-charts/ibm-object-storage-plugin --verbos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment