Installation
- Docker
- K8S
Before installing Lunar's Proxy, make sure that Docker is installed on your environment. If you haven't installed Docker yet, you can learn more about it and download it from the Docker website
Step 1: Run Lunar's Proxy Containerβ
Once the image download is complete, you can run the proxy container using the following command:
docker run -d --rm -p 8000:8000 -p 8081:8081 -p 8040:8040 -e TENANT_NAME="ORGANIZATION" -v $(pwd):/etc/lunar-proxy --name lunar-proxy lunarapi/lunar-proxy:latest
Note that the TENANT_NAME
environment variable is required. This variable should be set to the name of your organization.
-d: Start a container in detached mode.
--rm: Automatically remove the container when it exits.
-p: Publish all exposed ports to the host interfaces.
-e: Set environment variables. In this case, we set the TENANT_NAME
environment variable to ORGANIZATION
.
-v: Flag in your Docker run command to mount your local policies.yaml
file to the /etc/lunar-proxy
directory inside the Lunar Proxy container.
--name: The UUID identifiers come from the Docker daemon.
Step 2: Verify Installationβ
To ensure the successful installation of Lunar Proxy there are two options:
Option 1: Run the following command to make a request to the healthcheck endpoint which validates that Lunar Proxy is up.
curl http://localhost:8040/healthcheck
Option 2: Try to pass a request through the proxy by running the following command:
curl http://localhost:8000/fact -H "Host: catfact.ninja" -H "X-Lunar-Scheme: https"
This will make a request to Lunar Proxy on port 8000, which will forward the request to the upstream server catfact.ninja
on port 443, at the path /fact
(this is an API that returns the latest exchange rates).
The result should look something like this:
{"fact":"Among many other diseases, cats can suffer from anorexia, senility, feline AIDS and acne.","length":89}
Then, use the discover
command to validate that the requests were passed through Lunar Proxy.
docker exec lunar-proxy discover
The result should look something like this:
{
"interceptors": [
{
"type": "unknown",
"version": "unknown",
"last_transaction_date": "2023-07-10T08:56:12Z"
}
],
"endpoints": {
"GET:::catfact.ninja/fact": {
"min_time": "2023-02-05T17:07:42",
"max_time": "2023-02-05T17:09:14",
"count": 1,
"status_codes": {
"200": 1
},
"average_duration": 555
}
}
}
The interceptor type and version are unknown because we are using curl to make the request. Once an interceptor is used, its type and version will appear in the discover command output.
Before installing Lunar's Proxy, make sure that Helm is installed on your environment. If you haven't installed Helm yet, you can learn more about it and download it from the Helm website
Step 1: Add and update Lunar repositoryβ
To start the installation process, add and update our Lunar Proxy repository for helm charts. ΦΏOpen a terminal or command prompt and execute the following command:
helm repo add lunar https://thelunarcompany.github.io/proxy-helm-chart/
helm repo update
Step 2: Override Lunar Proxy configuration (Optional)β
if you need to override values in the Lunar Proxy chart, you can get the default values.
helm show values lunar/lunar-proxy | tee values.yaml
Step 3: Install Lunar Proxy helm chartβ
Once you have the updated values.yaml file, you can proceed to install the Lunar Proxy chart using the following command:
- In case of default installation
helm install lunar-proxy lunar/lunar-proxy --set tenantName=<name> --namespace lunar-proxy --create-namespace
Before installing Lunar's Proxy, ensure that the tenantName
is set to the name of your organization, for example: Acme
or Google
.
tenantName
- is a mandatory requirement, Lunar Proxy will not start if it is left unset.
This can also be set in the values.yaml
file.
- In case of changes in the
values.yaml
helm install lunar-proxy lunar/lunar-proxy -f values.yaml
Step 4: Verify Installationβ
To ensure the successful installation of Lunar Proxy there are two options:
Option 1: Run the following command to make a request to the healthcheck endpoint which validates that Lunar Proxy is up.
helm test lunar-proxy
Option 2: Try to pass a request through the proxy by running the following command:
curl http://localhost:8000/fact -H "Host: catfact.ninja" -H "X-Lunar-Scheme: https"
This will make a request to Lunar Proxy on port 8000, which will forward the request to the upstream server catfact.ninja
on port 443, at the path /fact
(this is an API that returns the latest exchange rates).
The result should look something like this:
{"fact":"Among many other diseases, cats can suffer from anorexia, senility, feline AIDS and acne.","length":89}
Then, use the discover
command to validate that the requests were passed through Lunar Proxy.
kubectl exec <lunar-proxy-pod-name> -- discover
The result should look something like this:
{
"interceptors": [
{
"type": "unknown",
"version": "unknown",
"last_transaction_date": "2023-07-10T08:56:12Z"
}
],
"endpoints": {
"GET:::catfact.ninja/fact": {
"min_time": "2023-02-05T17:07:42",
"max_time": "2023-02-05T17:09:14",
"count": 1,
"status_codes": {
"200": 1
},
"average_duration": 555
}
}
}
The interceptor type and version are unknown because we are using curl to make the request. Once an interceptor is used, its type and version will appear in the discover command output.