Skip to content

Commit 4165222

Browse files
author
surbhi kanthed
committed
Installation script with updated README
1 parent 2269eb1 commit 4165222

File tree

6 files changed

+90
-89
lines changed

6 files changed

+90
-89
lines changed

Documentation/Installation-script.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Expected Output of following commands from Installation Script
2+
3+
Make sure you follow all the steps in Prerequisites here at [CRC for Openshift Reporting Backend](https://github.com/dburugupalli/SSMT/blob/feature-1/Documentation/Installing_crc.md). and go as per the instruction printed on terminal before and after every command is executed when you run the script.
4+
5+
6+
### Output after Metering Operator Installation for local OCP cluster.
7+
```bash
8+
$oc get pods
9+
NAME READY STATUS RESTARTS AGE
10+
11+
metering-operator-68dd64cfb6-pxh8v 2/2 Running 0 2m49s
12+
```
13+
14+
if the metering operator is still not up and running.
15+
Stop the script and do the process manually of installing the metering operator -
16+
17+
18+
```bash
19+
a. Run command "crc console" in terminal.
20+
b. Login using admin credentials for crc.
21+
c. Search Red Hat Metering under Operator Hub and Click Install.
22+
d. Wait until Metering Operator pods are up and Running successfully.
23+
```
24+
25+
Remove the steps that are done from the script. Rerun the script with the remaining steps.
26+
27+
28+
29+
### Output after Installing Metering Stack / Metering Configuration for local OCP cluser
30+
31+
Understanding [Metering Configuration](https://docs.openshift.com/container-platform/4.3/metering/configuring_metering/metering-about-configuring.html#metering-about-configuring)
32+
33+
At a minimum, you need to configure persistent storage and configure the Hive metastore.[Refer Samples](https://docs.openshift.com/container-platform/4.3/metering/configuring_metering/metering-about-configuring.html#metering-about-configuring)
34+
35+
```bash
36+
$ oc -n openshift-metering get pods
37+
NAME READY STATUS RESTARTS AGE
38+
hive-metastore-0 2/2 Running 14 7d15h
39+
hive-server-0 3/3 Running 21 7d15h
40+
metering-operator-86b95669bb-njp4q 2/2 Running 14 7d15h
41+
presto-coordinator-0 2/2 Running 8 7d2h
42+
reporting-operator-978687d9c-vkzrl 2/2 Running 27 7d15h
43+
44+
#if not, Wait few more mins until Componenets of metering stack are installed like hive metastore, presto database and reporting operator
45+
```
46+
47+
48+

Documentation/Installing_crc.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,15 @@ Use the [CRC](https://access.redhat.com/documentation/en-us/red_hat_codeready_co
1818

1919
Login using your redhat account and select OpenShift for Laptop & copy image pull Secret, this will be used later while installing CRC.
2020

21-
2221
Lets configure CRC cluster with 7+vcpus &16+GB
2322

24-
```bash
25-
crc config set cpus 7
26-
crc config set memory <memory-in-mb>
27-
# To view crc configuration
28-
crc config view
29-
crc setup
30-
crc start
31-
# Deleting the code ready container
32-
crc delete
33-
```
34-
3523
Note:
3624
To enable configuration changes, you must delete the existing CRC virtual machine and create a new one.
3725

3826
[CRC Version 1.6](https://github.com/code-ready/crc/releases/tag/1.6.0) download link
3927

40-
## Some Common issues
28+
29+
## Some Common Issues
4130

4231
#### Unable to login to crc cluster via web console.
4332

@@ -52,11 +41,4 @@ crc ip # This will give the Virtual Machine IP address
5241
<vm_ip> console-openshift-console.apps-crc.testing
5342

5443
```
55-
#### Error in starting Monitoring, Telemetry and Alerting
56-
```bash
57-
oc get clusterversion version -ojsonpath='{range .spec.overrides[*]}{.name}{"\n"}{end}' | nl -v 0
58-
# Replace the unmanged-operator-index to [0 cluster-monitoring-operator]
59-
oc patch clusterversion/version --type='json' -p '[{"op":"remove", "path":"/spec/overrides/<unmanaged-operator-index>"}]' -oyaml
60-
61-
```
6244

README.md

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ More Details about Metering Operator [Metering Operator](https://docs.openshift.
88

99
1. OpenShift Account as Cluster Administrator
1010

11-
2. Locally running OpenShift Cluster [CRC](https://developers.redhat.com/products/codeready-containers). Refer this [CRC for Openshift Reporting Backend](https://github.com/dburugupalli/SSMT/blob/feature-1/Documentation/Installing_crc.md).
11+
2. Locally downloaded OpenShift Cluster [CRC](https://developers.redhat.com/products/codeready-containers). Refer this [CRC for Openshift Reporting Backend](https://github.com/dburugupalli/SSMT/blob/feature-1/Documentation/Installing_crc.md).
1212

1313
3. Enable Alerting,monitoring, telemetry on CRC cluster using following commands
1414

@@ -21,60 +21,24 @@ Note: if the above commands donot work, Please refer [CRC for Openshift Reportin
2121

2222
### Installation
2323

24-
#### Metering Operator Installation for local OCP cluster.
24+
1. Clone the repository in your local machine.
2525

26-
``` bash
27-
# Login as the Cluster Administrator
28-
29-
a. Create a namespace openshift-metering
30-
b. Label the namespace with `openshift.io/cluster-monitoring=true`
31-
c. Search Red Hat Metering under Operator Hub and Click Install.
32-
d. Wait until Metering Operator pods are up and Running successfully.
33-
34-
# Output after these steps
35-
NAME READY STATUS RESTARTS AGE
26+
2. Make the installation.sh and report.sh file executable using -
3627

37-
metering-operator-68dd64cfb6-pxh8v 2/2 Running 0 2m49s
28+
``` bash
29+
chom +x <.sh file name>
3830
```
3931

40-
#### Installing Metering Stack / Metering Configuration for local OCP cluser
41-
42-
Understanding [Metering Configuration](https://docs.openshift.com/container-platform/4.3/metering/configuring_metering/metering-about-configuring.html#metering-about-configuring)
32+
3. Run the installation script file with command -
4333

44-
At a minimum, you need to configure persistent storage and configure the Hive metastore.[Refer Samples](https://docs.openshift.com/container-platform/4.3/metering/configuring_metering/metering-about-configuring.html#metering-about-configuring)
45-
46-
47-
```bash
48-
$ oc project openshift-metering
49-
$ oc create -f https://raw.githubusercontent.com/dburugupalli/SSMT/feature-1/openshift-metering-templates/configuration-templates/metering-configuration.yaml
50-
51-
# Wait until Componenets of metering stack are installed like hive metastore, presto database and
52-
# reporting operator
53-
54-
$ oc -n openshift-metering get pods
55-
NAME READY STATUS RESTARTS AGE
56-
hive-metastore-0 2/2 Running 14 7d15h
57-
hive-server-0 3/3 Running 21 7d15h
58-
metering-operator-86b95669bb-njp4q 2/2 Running 14 7d15h
59-
presto-coordinator-0 2/2 Running 8 7d2h
60-
reporting-operator-978687d9c-vkzrl 2/2 Running 27 7d15h
61-
# to view custom resource definations
62-
$ oc get crd | grep metering
63-
hivetables.metering.openshift.io 2020-05-19T04:34:42Z
64-
meteringconfigs.metering.openshift.io 2020-05-19T04:34:42Z
65-
prestotables.metering.openshift.io 2020-05-19T04:34:42Z
66-
reportdatasources.metering.openshift.io 2020-05-19T04:34:42Z
67-
reportqueries.metering.openshift.io 2020-05-19T04:34:42Z
68-
reports.metering.openshift.io 2020-05-19T04:34:42Z
69-
storagelocations.metering.openshift.io 2020-05-19T04:34:42Z
34+
``` bash
35+
./installation.sh
7036
```
7137

72-
#### Verify Metering Stack / Configuration for local OCP cluster
38+
Every steps tells you what it does and print the output of each command on terminal after it's executed.
39+
40+
Expected output of few commands is mentioned here [Script Details](https://github.com/skanthed/SSMT/blob/bash-script/Documentation/Installation-script.md)
7341

74-
```bash
75-
oc get reportdatasources -n openshift-metering | grep -v raw
76-
```
77-
Metering stack creates sample instances of reportdatasource and reportqueries custom resources.
7842

7943
### Creating Reports
8044

@@ -83,15 +47,14 @@ For Now, lets use the pre-defined reportdatasources and reportqueries to generat
8347
```bash
8448
$ oc project openshift-metering
8549
$ oc create -f https://raw.githubusercontent.com/dburugupalli/SSMT/feature-1/openshift-metering-templates/reports-templates/namespace-cpu-request-hourly.yaml
86-
$ meteringRoute="$(oc get routes metering -o jsonpath='{.spec.host}')"
87-
$ echo "$meteringRoute"
88-
$ token="$(oc whoami -t)"
89-
$ reportName=namespace-cpu-request-hourly
90-
$ reportFormat=json
91-
# Change reportForma=csv to get output in csv format
92-
$ curl --insecure -H "Authorization: Bearer ${token}" "https://${meteringRoute}/api/v1/reports/get?name=${reportName}&namespace=openshift-metering&format=$reportFormat"
50+
9351
```
9452
To view reports on the terminal.
53+
Run report.sh file.
54+
55+
``` bash
56+
./report.sh
57+
```
9558

9659
### Defining Report-Query and ReportDataSources to acheive specific functionality
9760

installation.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ sudo systemctl start NetworkManager
77
echo "Starting libvrtd service"
88
sudo systemctl start libvirtd
99

10+
echo "Lets configure CRC cluster with 7+vcpus &16+GB memory"
11+
1012
read -p "Enter memory in MB : " mem
1113
read -p "Enter number of cpus : " cpu
1214
echo "Entered memory size $mem "
@@ -19,52 +21,53 @@ crc config set memory $mem
1921
echo "View the CRC config"
2022
crc config view
2123
crc setup
22-
echo "Start the CRC"
24+
echo "Starting the CRC, make sure you have the right path to pull-secret.txt file"
2325
crc start -p pull-secret.txt
2426

2527

26-
echo "Openshift admin login"
28+
29+
echo "Openshift login - Take the credentials from the output of previous command. Use admin credentials to login, as you need to install operators"
2730
oc login
2831

2932

3033
echo "Create openshift-metering namespace"
31-
oc create -f metering-namespace.yaml
34+
oc create -f https://github.com/skanthed/SSMT/blob/bash-script/openshift-metering-templates/configuration-templates/metering-namespace.yaml
3235

3336

3437
oc project openshift-metering
3538

3639

37-
echo "Get cluster version"
40+
echo "Get the cluster versions"
3841
oc get clusterversion version -ojsonpath='{range .spec.overrides[*]}{.name}{"\n"}{end}' | nl -v 0
3942

4043

41-
echo "Patch the cluster version"
44+
echo "Patch the cluster versions and Replace the unmanged-operator-index to [0 cluster-monitoring-operator]"
4245
read -p "Enter un-managed operator index : " umidx
4346
oc patch clusterversion/version --type='json' -p '[{"op":"remove", "path":"/spec/overrides/' + $umidx + '"}]' -oyaml
4447
sleep 1m
4548

4649

47-
echo "Scales the Openshift Monitoring"
50+
echo "Scaling the Openshift Monitoring"
4851
oc scale --replicas=1 statefulset --all -n openshift-monitoring;
4952
oc scale --replicas=1 deployment --all -n openshift-monitoring
5053

5154

52-
echo "Create OperatorGroup object"
53-
oc create -f metering-og.yaml
55+
echo "Creating OperatorGroup object"
56+
oc create -f https://github.com/skanthed/SSMT/blob/bash-script/openshift-metering-templates/configuration-templates/metering-og.yaml
5457

5558

56-
echo "Install metering operator"
57-
oc create -f metering-sub.yaml
59+
echo "Installing metering operator"
60+
oc create -f https://github.com/skanthed/SSMT/blob/bash-script/openshift-metering-templates/configuration-templates/metering-sub.yaml
5861

5962

60-
echo "Waiting to complete the Metering Creation"
63+
echo "Waiting to complete the Metering Operator Creation"
6164
sleep 10m # 10 mins pause
6265

6366

6467
oc get pods
6568

6669

67-
echo "Project the openshift metering"
70+
echo "Now using project the openshift metering"
6871
oc project openshift-metering
6972

7073

@@ -73,9 +76,10 @@ oc create -f https://raw.githubusercontent.com/dburugupalli/SSMT/feature-1/opens
7376
sleep 25m
7477

7578

76-
echo "Get pods details"
79+
echo "See the status of all component of metering stack"
7780
oc -n openshift-metering get pods
7881

7982

80-
echo "See all the generated reports"
83+
echo "Verifying Metering Stack / Configuration for local OCP cluster "
84+
echo "Metering stack creates sample instances of reportdatasource and reportqueries custom resources. "
8185
oc get reportdatasources -n openshift-metering | grep -v raw

openshift-metering-templates/configuration-templates/metering-sub.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Make sure to change the channel version to the latest version of metering operator
12
apiVersion: operators.coreos.com/v1alpha1
23
kind: Subscription
34
metadata:

report.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#!/bin/bash
22

3+
#To view reports on the terminal.
4+
35
echo "Get into the openshift metering project"
46
oc project openshift-metering
57

6-
echo "Get the lis of pods"
8+
echo "Get the list of all pods"
79
oc -n openshift-metering get pods
810

911
echo "See all the generated reports"
1012
oc get reportdatasources -n openshift-metering | grep -v raw
1113

14+
1215
echo " Setting meteringRoute"
1316
meteringRoute="$(oc get routes metering -o jsonpath='{.spec.host}')"
1417
echo "$meteringRoute"

0 commit comments

Comments
 (0)