Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

Dev #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/vendor/
/bin/
/dist/
/deploy/gcsproxy
/gcs.json
*~
52 changes: 41 additions & 11 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This is a reverse proxy for Google Cloud Storage for performing limited disclosu
+------------+ +---------------+
```

## Useage
## Usage

```
Usage of gcsproxy:
Expand All @@ -39,6 +39,50 @@ bin/gcsproxy -c /etc/gcs.json -v
# docker run
docker run -ti -p 8080:8080 -v /etc/gcs.json:/etc/gcs.json gcsproxy /usr/bin/gcsproxy -c /etc/gcs.json -v
# test
curl -v wget http://127.0.0.1:8080/<bucket>/<object>
curl -v http://127.0.0.1:8080/<bucket>/<object>
```

## Deploy on Kubernetes

* Get a GCS key and create a configmap

```bash
kubectl create configmap gcs-key --from-file=gcs.json
```

* Create nginx config as a configmap

```bash
kubectl create configmap nginx-conf --from-file=deploy/kubernetes/nginx-gcs.conf

```

* Create nginx cache + gcsproxy deployment

```bash
kubectl apply -f deploy/kubernetes/nginx.yaml
```

* Check if the pod is running and service is created

```console
# kubectl get pod
NAME READY STATUS RESTARTS AGE
gcs-cache-6f6947b8cf-fdkf5 2/2 Running 0 9m31s

# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cache ClusterIP 10.102.88.144 <none> 80/TCP 9m10s
```

* Test it

Use the cache's cluster IP 10.102.88.144:

```console
# kubectl run --rm -i -t ephemeral --image=busybox -- /bin/sh -l
If you don't see a command prompt, try pressing enter.
/ # wget 10.102.88.144/xxxxxxxx > /dev/null
Connecting to 10.102.88.144 (10.102.88.144:80)
xxxxxx 100% |**********************************************************************************************************************************************| 979M 0:00:00 ETA
```
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
docker login -u "${DOCKER_IO_USERNAME}" -p "${DOCKER_IO_PASSWORD}" quay.io
docker login -u "${DOCKER_IO_USERNAME}" -p "${DOCKER_IO_PASSWORD}" docker.io
make push-image
fi
10 changes: 7 additions & 3 deletions nginx.conf → deploy/kubernetes/nginx-gcs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ user nginx;
worker_processes 1;
daemon off;
error_log /dev/stdout info;
pid /var/lib/nginx/nginx.pid;
# pid /var/lib/nginx/nginx.pid;


events {
Expand Down Expand Up @@ -45,7 +45,11 @@ http {
}

server {
listen 80;
listen 443;

ssl_certificate /etc/nginx/cert/cert.crt;
ssl_certificate_key /etc/nginx/cert/cert.key;
ssl on;

if ( $request_method !~ "GET|HEAD" ) {
return 405;
Expand All @@ -66,7 +70,7 @@ http {
proxy_cache_key "$host/$proxy_host$uri";
proxy_cache_valid 200 1d;
add_header X-Cache $upstream_cache_status;
proxy_pass http://google-cloud-storage$uri;
proxy_pass https://google-cloud-storage$uri;
}
}
}
Loading