Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Update Docker and Kubernetes scripts #861

Merged
merged 14 commits into from Nov 24, 2017
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -49,15 +49,14 @@ before_deploy:
- tar -xzf travis_secrets.tar.gz
- gcloud auth activate-service-account --key-file service_key.json
- rm -f service_key.json
- gcloud --quiet version
- gcloud --quiet components update kubectl
- gcloud --quiet version
- gcloud config set project key-transparency
- gcloud config set compute/zone us-central1-a
- gcloud container clusters get-credentials ci-cluster
- go get github.com/google/trillian/server/trillian_log_server
- go get github.com/google/trillian/server/trillian_log_signer
- go get github.com/google/trillian/server/trillian_map_server
- go get github.com/google/trillian/cmd/createtree

deploy:
skip_cleanup: true
Expand Down
31 changes: 16 additions & 15 deletions README.md
Expand Up @@ -31,7 +31,7 @@ development.
## Key Transparency Client

### Setup
1. Install [Go 1.7](https://golang.org/doc/install).
1. Install [Go 1.9](https://golang.org/doc/install).
2. `go get -u github.com/google/keytransparency/cmd/keytransparency-client `
3. Get an [OAuth client ID](https://console.developers.google.com/apis/credentials) and download the generated JSON file to `client_secret.json`.

Expand Down Expand Up @@ -81,25 +81,26 @@ development.
1. `./scripts/prepare_server.sh -f`

### Run
1. Start Trillian
1. Run Key Transparency

```sh
$ docker-compose up -d trillian-map trillian-log
Creating keytransparency_db_1
Creating keytransparency_trillian-map_1
Creating keytransparency_trillian-log_1
$ docker-compose up -d
Creating keytransparency_db_1 ... done
Creating keytransparency_map_server_1 ... done
Creating keytransparency_log_server_1 ... done
Creating keytransparency_log_server_1 ... done
Creating keytransparency_server_1 ... done
Creating keytransparency_sequencer_1 ... done
Creating keytransparency_monitor_1 ... done
Creating keytransparency_init_1 ... done
Creating keytransparency_prometheus_1 ... done
Creating keytransparency_monitor_1 ... done
```

2. Provision a log and a map
```sh
source scripts/configure_trillian.sh && createLog && createMap
```

3. Run Key Transparency
- `docker-compose up -d`
2. Watch it Run
- `docker-compose logs --tail=0 --follow`
- [https://localhost:8080/v1/users/foo@bar.com?app_id=app1](https://localhost:8080/v1/users/foo@bar.com?app_id=app1)
- [https://localhost:8080/v1/domain/info](https://localhost:8080/v1/domain/info)
- [Proof for app1/foo@bar.com](https://localhost:8080/v1/domains/default/users/foo@bar.com?app_id=app1)
- [Server configuration info](https://localhost:8080/v1/domains/default/info)
- [Prometheus graphs](http://localhost:9090/graph)

## Development and Testing
Expand Down
2 changes: 1 addition & 1 deletion cmd/keytransparency-monitor/Dockerfile
@@ -1,4 +1,4 @@
FROM golang
FROM golang:1.9

ADD keytransparency/genfiles/* /kt/
ADD ./keytransparency /go/src/github.com/google/keytransparency
Expand Down
2 changes: 1 addition & 1 deletion cmd/keytransparency-sequencer/Dockerfile
@@ -1,4 +1,4 @@
FROM golang
FROM golang:1.9

ADD ./keytransparency /go/src/github.com/google/keytransparency
ADD ./trillian /go/src/github.com/google/trillian
Expand Down
4 changes: 2 additions & 2 deletions cmd/keytransparency-server/Dockerfile
@@ -1,4 +1,4 @@
FROM golang
FROM golang:1.9

ADD keytransparency/genfiles/* /kt/
ADD ./keytransparency /go/src/github.com/google/keytransparency
Expand All @@ -11,4 +11,4 @@ RUN go get -tags="mysql" ./cmd/keytransparency-server
# See the README.md file on how to use docker-compose.
ENTRYPOINT ["/go/bin/keytransparency-server"]

EXPOSE 8080
EXPOSE 8080
9 changes: 9 additions & 0 deletions deploy/docker/init/Dockerfile
@@ -0,0 +1,9 @@
FROM alpine:3.4

RUN apk add --update curl && \
rm -rf /var/cache/apk/*

ADD ./scripts/ /scripts

ENTRYPOINT ["/scripts/wait-for.sh"]
CMD ["--help"]
4 changes: 2 additions & 2 deletions deploy/kubernetes/README.md
Expand Up @@ -15,10 +15,10 @@ After that you should be able to visit http://localhost:8080/ui .
## Delete mysql DB
To delete all data written to the DB you can run:
```
kubectl delete -f deploy/kubernetes/db-deployment.yml
kubectl delete -f deploy/kubernetes/db-deployment.yaml
```
Alternatively, you use the kubernetes HTTP user interface:
1) Start a proxy to the kubernetes api by running `kubectl proxy --port=8080`.
2) Find and delete the mysql pod/deployment on the
[user interface](http://localhost:8080/ui).

36 changes: 36 additions & 0 deletions deploy/kubernetes/db-deployment.yaml
@@ -0,0 +1,36 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert --file ../../docker-compose.yml
kompose.version: 1.4.0 (HEAD)
creationTimestamp: null
labels:
io.kompose.service: db
name: db
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: db
spec:
containers:
- env:
- name: MYSQL_DATABASE
value: test
- name: MYSQL_PASSWORD
value: zaphod
- name: MYSQL_RANDOM_ROOT_PASSWORD
value: "yes"
- name: MYSQL_USER
value: test
image: us.gcr.io/key-transparency/db
name: db
ports:
- containerPort: 3306
resources: {}
restartPolicy: Always
status: {}
44 changes: 0 additions & 44 deletions deploy/kubernetes/db-deployment.yml

This file was deleted.

19 changes: 19 additions & 0 deletions deploy/kubernetes/db-service.yaml
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert --file ../../docker-compose.yml
kompose.version: 1.4.0 (HEAD)
creationTimestamp: null
labels:
io.kompose.service: db
name: db
spec:
ports:
- name: "3306"
port: 3306
targetPort: 3306
selector:
io.kompose.service: db
status:
loadBalancer: {}
17 changes: 17 additions & 0 deletions deploy/kubernetes/gen.go
@@ -0,0 +1,17 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package kubernetes

//go:generate kompose convert --file ../../docker-compose.yml
21 changes: 21 additions & 0 deletions deploy/kubernetes/init-pod.yaml
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
io.kompose.service: init
name: init
spec:
containers:
- args:
- sequencer:8080
- --
- curl
- -k
- https://sequencer:8080/v1/domains
- -d{"domain_id":"default","min_interval":"1s","max_interval":"60s"}
image: us.gcr.io/key-transparency/init:latest
name: init
resources: {}
restartPolicy: OnFailure
status: {}