-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·94 lines (63 loc) · 3.06 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin developer
oc login -u developer
oc new-project demo-monitoring
read -n1 -r -p "Let's create Prometheus operator. Press any key to continue..." key
oc apply -f 1-cluster-role-binding.yaml
oc apply -f 2-cluster-role.yaml
oc apply -f 3-prometheus-operator-deployment.yaml
oc apply -f 4-service-account.yaml
# Set permissions for prometheus and its operator
oc adm policy add-scc-to-user privileged -ndemo-monitoring -z prometheus-operator
oc adm policy add-scc-to-user privileged -ndemo-monitoring -z prometheus
read -n1 -r -p "Please wait for Prometheus operator to be deployed. Confirm deployment using 'oc get pods' from another terminal window. Once confirmed press any key to proceed with installation..." key
echo "Setting RBAC"
oc apply -f 5-rbac-service-account.yaml
oc apply -f 6-rbac-cluster-roles.yaml
oc apply -f 7-rbac-cluster-role-binding.yaml
echo "Creating service monitors and exposing Prometheus web console..."
oc apply -f 8-service-monitors.yaml
oc apply -f 9-expose-prometheus.yaml
oc create route edge --service=prometheus
read -n1 -r -p "Now we'll deploy Infinispan cluster and connect it to Prometheus for monitoring. Press any key to continue...." key
echo "Installing Infinispan"
oc create -f infinispan-ephemeral-modified.yaml
INFINISPAN_USER=developer
INFINISPAN_PASSWORD=developer
oc new-app infinispan-ephemeral \
-p APPLICATION_USER=$INFINISPAN_USER \
-p APPLICATION_PASSWORD=$INFINISPAN_PASSWORD \
-p MANAGEMENT_USER=$INFINISPAN_USER \
-p MANAGEMENT_PASSWORD=$INFINISPAN_PASSWORD \
-p NAMESPACE=demo-monitoring \
-p NUMBER_OF_INSTANCES=1
oc expose svc/infinispan-app-http
read -n1 -r -p "Now that Infinispan cluster is booting we'll expose Infinispan metrics to Prometheus. Press any key to continue..." key
oc apply -f 10-service-metrics.yaml
oc expose svc/infinispan-app-metrics
oc apply -f 11-infinispan-service-monitor.yaml
read -n1 -r -p "Infinispan installation done! Not let's install Grafana. Press any key to continue..." key
oc new-app grafana/grafana:5.3.4
oc expose svc/grafana
read -n1 -r -p "Let's install Prometheus data source and Infinispan dashboard to Grafana. Press any key to continue..." key
protocol="http://"
payload="$( mktemp )"
cat <<EOF >"${payload}"
{
"name": "Promethus",
"type": "prometheus",
"access": "Browser",
"url": "https://$( oc get route prometheus -n demo-monitoring -o jsonpath='{.spec.host}' )",
"basicAuth": false,
"withCredentials": false
}
EOF
# setup grafana data source
grafana_host="${protocol}$( oc get route grafana -o jsonpath='{.spec.host}' )"
dashboard_file="./infinispan-grafana-dashboard.json"
curl --insecure -H "Content-Type: application/json" -u admin:admin "${grafana_host}/api/datasources" -X POST -d "@${payload}"
# this does not work for some reason, import manualy
#curl --insecure -H "Content-Type: application/json" -u admin:admin "${grafana_host}/api/dashboards/import" -X POST -d "@${dashboard_file}"
echo "All done! Let's log into grafana (username/password is admin/admin) at: "
oc get route grafana