Skip to content

Commit

Permalink
Merge pull request Alethio#69 from marlowl/master
Browse files Browse the repository at this point in the history
Kubernetes manifest files for ethereum-lite-explorer
  • Loading branch information
use-strict authored Mar 11, 2020
2 parents e5a3a37 + dc48448 commit e2c617c
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .kubernetes/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: lite-explorer
data:
config.json: |-
CONFIG_JSON
16 changes: 16 additions & 0 deletions .kubernetes/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

# Get config.json contents based on first program arg or default then escape special chars for sed replacements string then indent all lines with 4 spaces to align with output yaml
config_json=$(cat ${1:-"../config.default.json"} | sed 's:[\/&]:\\&:g;$!s/$/\\/' | sed 's/^/ /')

# Replace the placeholder from input yaml file and write a new one
cat configmap.yaml | sed "s/ CONFIG_JSON/$config_json/" > configmap.generated.yaml

kubectl apply -f configmap.generated.yaml
kubectl apply -f explorer-deployment.yaml
kubectl apply -f explorer-service.yaml

# Clean up
rm configmap.generated.*
35 changes: 35 additions & 0 deletions .kubernetes/explorer-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: lite-explorer
labels:
app: lite-explorer
spec:
replicas: 1
selector:
matchLabels:
app: lite-explorer
template:
metadata:
# Optional, if this'd be wrapped in a helm chart it can be generated as the SHA256 of the configmap
# to pod rolling updates reloads on configmap change
annotations:
checksum/config: 6733181240aa3db87503350771fb19fcaef0707e209928165a9cc7e3e3050781
labels:
app: lite-explorer
spec:
containers:
- image: alethio/ethereum-lite-explorer
imagePullPolicy: Always
name: app
ports:
- containerPort: 80
name: http
volumeMounts:
- mountPath: /usr/share/nginx/html/config.json
name: config
subPath: config.json
volumes:
- configMap:
name: lite-explorer
name: config
13 changes: 13 additions & 0 deletions .kubernetes/explorer-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: lite-explorer
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: lite-explorer
3 changes: 3 additions & 0 deletions .kubernetes/remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kubectl delete configmap lite-explorer
kubectl delete -f explorer-deployment.yaml
kubectl delete -f explorer-service.yaml
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ No need for servers, hosting or trusting any third parties to display chain data
- [Prerequisites](#prerequisites)
- [Configuration](#configuration)
- [Running in Docker](#running-in-docker)
- [Running in Kubernetes](#running-in-kubernetes)
- [Building from source](#building-from-source)
- [Deploying the built assets to production](#deploying-the-built-assets-to-production)
- [Custom build arguments](#custom-build-arguments)
Expand Down Expand Up @@ -128,6 +129,13 @@ If more customization is needed, a full configuration file can be mounted in the
```sh
$ docker run -p 80:80 -v /your-config-dir/config.json:/usr/share/nginx/html/config.json alethio/ethereum-lite-explorer
```
### Running in Kubernetes
You can deploy the Lite Explorer in Kubernetes using the following steps:
- `cd .kubernetes`
- Run `./deploy.sh` to deploy, uses `config.default.json` as config.
- Use for example `./deploy.sh ../config.memento.json` to select other config files.
- Run `./remove.sh` to remove


### Building from source
Clone the explorer in a folder of your choosing
Expand Down

0 comments on commit e2c617c

Please sign in to comment.