@@ -13,40 +13,58 @@ You have access to Elasticsearch using your {product-title} token, and
13
13
you can provide the external Elasticsearch and Elasticsearch Ops
14
14
hostnames when creating the server certificate (similar to Kibana).
15
15
16
+ .Prerequisite
17
+
18
+ Set cluster logging to the unmanaged state.
19
+
16
20
.Procedure
17
21
18
- . To access Elasticsearch as a reencrypt route, define the following variables :
22
+ . Use the following command to get name of the ElasticSearch pod :
19
23
+
20
24
----
21
- openshift_logging_es_allow_external=True
22
- // openshift_logging_es_hostname=elasticsearch.example.com
25
+ ESPOD=$( oc get pods -l component=elasticsearch -o name | sed -e "s/pod\///" )
23
26
----
24
27
25
- . To log in to Elasticsearch remotely, the request must contain three HTTP headers :
28
+ . Use the following command to extract CA certificate to a file :
26
29
+
27
30
----
28
- Authorization: Bearer $token
29
- X-Proxy-Remote-User: $username
30
- X-Forwarded-For: $ip_address
31
+ oc exec $ESPOD -- cat /etc/openshift/elasticsearch/secret/admin-ca > ./admin-ca
31
32
----
32
33
33
- . You must have access to the project in order to be able to access to the logs. For example :
34
+ . Create the route object for the ElasticSearch service as an yaml file :
34
35
+
35
36
----
36
- $ oc login <user1>
37
- $ oc new-project <user1project>
38
- $ oc new-app <httpd-example>
37
+ apiVersion: route.openshift.io/v1
38
+ kind: Route
39
+ metadata:
40
+ name: elasticsearch
41
+ namespace: openshift-logging
42
+ spec:
43
+ host:
44
+ to:
45
+ kind: Service
46
+ name: elasticsearch
47
+ tls:
48
+ termination: reencrypt
49
+ caCertificate: |-
39
50
----
40
51
41
- . You need to get the token of this ServiceAccount to be used in the request :
52
+ . Use the following commands to add the CA certificate to the object YAML file :
42
53
+
43
54
----
44
- $ token=$(oc whoami -t)
55
+ cat ./admin-ca | sed -e "s/^/ /" >> my_es_route.yaml
56
+ echo " destinationCACertificate: |-" >> my_es_route.yaml
57
+ cat ./admin-ca | sed -e "s/^/ /" >> my_es_route.yaml
45
58
----
46
59
47
- . Using the token previously configured, you should be able access Elasticsearch through the exposed route :
60
+ . Use the following command to create the service :
48
61
+
49
62
----
50
- $ curl -k -H "Authorization: Bearer $token" -H "X-Proxy-Remote-User: $( oc whoami)" -H "X-Forwarded-For: 127.0.0.1" https://es.example.test/project.my-project.*/_search?q=level:err | python -mjson.tool
63
+ oc create -f my_es_route.yaml
51
64
----
52
65
66
+ . Check the ElasticSearch service is exposed:
67
+ +
68
+ ----
69
+ curl --silent --insecure -H "Authorization: Bearer $( oc whoami -t )" "https://$( oc get route elasticsearch -o jsonpath='{.spec.host}' ):443/.operations.*/_search" | jq
70
+ ----
0 commit comments