Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Last active June 8, 2017 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rafaeltuelho/c4566a1ede6db517fb50d4898fbd0793 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/c4566a1ede6db517fb50d4898fbd0793 to your computer and use it in GitHub Desktop.
Simple bash script to configure the Cluster Metrics components on OCP v3.3 (tested on CDK > 2.2)
#!/bin/bash
echo -e "\n --- \n Configuring Metrics Components \n --- \n"
echo -e "\t Service Accounts"
echo -e "\t\t Create a metrics-deployer service account:"
oc login --username=<admin_user> --password=<passwd> --namespace=openshift-infra
oc create -f - <<API
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-deployer
secrets:
- name: metrics-deployer
API
echo -e "\t\t grant the edit permission for the openshift-infra project:"
oadm policy add-role-to-user \
edit system:serviceaccount:openshift-infra:metrics-deployer
echo -e "\t\t grant the cluster-reader permission to heapster service account:"
oadm policy add-cluster-role-to-user \
cluster-reader system:serviceaccount:openshift-infra:heapster
echo -e "\tMetric deployer will generate a self-signed certificate to be used"
echo -e "\t\t create a dummy secret that does not specify a certificate value:"
oc secrets new metrics-deployer nothing=/dev/null
echo -e "\t\t Download metrics-deployer templates fro OCP Enterprise..."
curl -s -L -o metrics-deployer.yaml https://raw.githubusercontent.com/openshift/origin-metrics/enterprise/metrics.yaml
curl -s -L -o logging-deployer.yaml https://raw.githubusercontent.com/openshift/origin-aggregated-logging/master/deployer/deployer.yaml
echo -e "\t Deploying metric components using Default provided template (/usr/share/openshift/examples/infrastructure-templates/enterprise/metrics-deployer.yaml)"
echo -e "\t\t Deploying without Persistent Storage..."
oc new-app --as=system:serviceaccount:openshift-infra:metrics-deployer \
-f ./metrics-deployer.yaml \
-p HAWKULAR_METRICS_HOSTNAME=metrics.10.1.2.2.xip.io \
-p USE_PERSISTENT_STORAGE=false \
-p IMAGE_VERSION=latest
echo -e "\n validate metrics deployment"
oadm diagnostics MetricsApiProxy
echo -e "\t\t\t using 'metrics.10.1.2.2.xip.io' as hostname for Hawkular Metrics component"
echo -e "\t Configuring Openshift Master config file to access hawkular metrics"
cp /var/lib/openshift/openshift.local.config/master/master-config.yaml /var/lib/openshift/openshift.local.config/master/master-config.yaml.bkp_`date +"%d%m%Y_%H%M"`
sed -i "s|metricsPublicURL:.*|metricsPublicURL: \"https://metrics.10.1.2.2.xip.io/hawkular/metrics\"|" /var/lib/openshift/openshift.local.config/master/master-config.yaml
echo -e "\t IMPORTANT! \n\t\t>>> now access 'https://metrics.10.1.2.2.xip.io/hawkular/metrics' and accept the Self signed Certificate in your web browser! \n"
echo -e "\t restart your master/node services if necessary!"
echo -e "\n --- \n Finished \n --- \n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment