Skip to content

Commit 8ef6231

Browse files
authored
Merge pull request #801 from oracle/rest-doc-update
update rest doc
2 parents 1196d8c + fdb544d commit 8ef6231

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

site/rest.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,41 @@ curl ... -H X-RequestedBy:MyClient ... -X POST .../scaling
1818
If you do not pass in the X-Requested-By header, then you'll get a 400 (bad request) response without any details explaining why the request is bad.
1919
The X-Requested-By header is not needed for requests that only read, for example when you GET any of the Operator's REST endpoints.
2020

21-
If using `curl`, you can use the `-k` option to bypass the check to verify that the operator's certificate is trusted (instead of `curl --cacert`).
21+
Before using the sample script below, you must:
2222

23-
Here is a small sample BASH script that may help to prepare the necessary token, certificates, and such, to call the operator's REST services:
23+
* Update it to ensure it has the correct service account, namespaces, etc., and it points to the `values.yaml`
24+
that you used to install the operator (so that it can get the certificates),
25+
* Add your operator's certificate to your operating system's trust store (see below), and
26+
* If you are using a self-signed certificate and your client is macOS, you may need to update the version of `curl`
27+
you have installed. The version of CURL that ships with macOS High Sierra (`curl 7.54.0 (x86_64-apple-darwin17.0)
28+
libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0`) has known issues with self-signed certificates. Oracle
29+
recommends `curl 7.63.0 (x86_64-apple-darwin17.7.0) libcurl/7.63.0 SecureTransport zlib/1.2.11` which can be installed
30+
with `brew install curl`.
2431

25-
Before using this script it would be necessary to update it to ensure it has the correct
26-
service account, namespaces, etc., and it points to your `values.yaml` that you used to install
27-
the operator (so that it can get the certificates).
32+
### How to add your certificate to your operating system trust store
33+
34+
For macOS, find the certificate in Finder, and double-click on it. This will add it to your keystore and open Keychain
35+
Access. Find the certificate in Keychain Access and double-click on it to open the details. Open the "Trust" pull-down
36+
and set the value of "When using this certificate" to "Always Trust", then close the detail window and enter your
37+
password when prompted.
38+
39+
For Oracle Linux, run the script below once to copy the certificate into `/tmp/operator.cert.pem` then run these
40+
commands to add the certificate to the trust store:
41+
42+
```
43+
$ sudo cp /tmp/operator.cert.pem /etc/pki/ca-trust/source/anchors/
44+
$ sudo update-ca-trust enable; sudo update-ca-trust extract
45+
$ openssl x509 -noout -hash -in /tmp/operator.cert.pem
46+
$ sudo ln -s /etc/pki/ca-trust/source/anchors/operator.cert.pem /etc/pki/tls/certs/e242d2da.0
47+
```
48+
In the final command, the filename `e242d2da.0` should be the output of the previous command plus the suffix `.0`.
49+
50+
Please consult your operating system's documentation (or Google) for other operating systems.
51+
52+
### Sample operator REST client script
53+
54+
Here is a small sample BASH script that may help to prepare the necessary token, certificates, and such, to call the
55+
operator's REST services. Please read the important caveats above before using this script:
2856

2957
```
3058
#!/bin/bash
@@ -44,7 +72,7 @@ cat ${OPERATOR_CERT_FILE}
4472
echo "Ready to call operator REST APIs"
4573
4674
STATUS_CODE=`curl \
47-
-v -k \
75+
-v \
4876
--cacert ${OPERATOR_CERT_FILE} \
4977
-H "Authorization: Bearer ${TOKEN}" \
5078
-H Accept:application/json \
@@ -57,6 +85,8 @@ cat curl.err
5785
cat curl.out | jq .
5886
```
5987

88+
**Note**: you can use the `-k` option to bypass the check to verify that the operator's certificate is trusted (instead of `curl --cacert`), but this is insecure.
89+
6090
To use this script, pass in the Kubernetes server address and then the URL you want to call. The script assumes `jq` is installed and uses it to format the response. This can be removed if desired. The script also prints out quite a bit of useful debugging information in addition to the response. Here is an example of the output of this script:
6191

6292
```

0 commit comments

Comments
 (0)