Skip to content

Commit

Permalink
Added CI/CD instructions for Kubernetes deployment and Smoke Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Potisk committed Jun 22, 2020
1 parent 2898058 commit 1ce97f1
Show file tree
Hide file tree
Showing 22 changed files with 1,239 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/universal-resolver-ws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Docker Build and Push
uses: danubetech/github-action-docker-build-push@master
uses: ./ci/docker-build-push
env:
MAVEN_SETTINGS: ${{secrets.MAVEN_SETTINGS}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
DOCKER_FILE: resolver/java/uni-resolver-web/docker/Dockerfile
CONTAINER_TAG: universalresolver/uni-resolver-web:latest
CONTAINER_TAG: universalresolver/uni-resolver-web:latest
- name: Deploy to AWS
uses: ./ci/deploy-k8s-aws
env:
KUBE_CONFIG_DATA: ${{secrets.KUBE_CONFIG_DATA}}
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
- name: Smoke Test
uses: ./ci/smoke-test
25 changes: 25 additions & 0 deletions ci/deploy-k8s-aws/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.8.0-slim

LABEL "name"="Deployment of the Universal Resolver to a Kubernetes Cluster"
LABEL "maintainer"="Phil <philipp.potisk@danubetech.com>"
LABEL "version"="1.0.0"

LABEL "com.github.actions.name"="GitHub Action for deploying the Universal Resolver"
LABEL "com.github.actions.description"="Deployes the Universal Resolver to a Kubernetes cluster."
LABEL "com.github.actions.icon"="package"
LABEL "com.github.actions.color"="blue"

RUN apt-get update -y && \
apt-get install -y curl gnupg openssh-client git && \
curl -Lso /bin/aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.11.5/2018-12-06/bin/linux/amd64/aws-iam-authenticator && \
chmod +x /bin/aws-iam-authenticator && \
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin/kubectl && \
apt-get -y clean && apt-get -y autoclean && apt-get -y autoremove && \
pip install setuptools awscli

COPY deploy/ /deploy/
COPY scripts/* /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
54 changes: 54 additions & 0 deletions ci/deploy-k8s-aws/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Kubernetes Deployment of the Universal Resolver

## Usage with Docker
Setting the environment:

export KUBE_CONFIG_DATA=$(cat /home/pp/dev/devops/universal-resolver-kubernetes/aws/danubetech-dev-cluster10/danubetech-dev-cluster10-KUBE_CONFIG_DATA.txt)

Build:

docker build -t ur-deployer .

Run:

docker run -t ur-deployer


## Usage via script
Setting the environment:

export KUBECONFIG=/home/pp/dev/devops/universal-resolver-kubernetes/aws/danubetech-dev-cluster10/kubeconfig-danubetech-dev-cluster10.yaml

Run:

cd scripts
./entrypoint.sh


## Usage as GitHub Action

Github Action workflow-file:

```
name: CI/CD Workflow for universal-resolver
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Deploy to AWS
uses: philpotisk/universal-resolver-k8s-deployment@master
env:
KUBE_CONFIG_DATA: ${{secrets.KUBE_CONFIG_DATA}}
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
```
24 changes: 24 additions & 0 deletions ci/deploy-k8s-aws/deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
kubectl delete all --all -n uni-resolver
kubectl -n uni-resolver apply -f deployment-driver-did-btcr.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-sov.yaml
kubectl -n uni-resolver apply -f deployment-uni-resolver-driver-did-uport.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-stack.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-erc725.yaml
kubectl -n uni-resolver apply -f deployment-driver-dns.yaml
kubectl -n uni-resolver apply -f deployment-jolocom-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-hacera-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-seraph-id-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-ccp.yaml
kubectl -n uni-resolver apply -f deployment-work-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-ontid-driver.yaml
kubectl -n uni-resolver apply -f deployment-kilt-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-evan-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-uni-resolver-driver-did-echo.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-factom.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-key.yaml
kubectl -n uni-resolver apply -f deployment-dock-did-driver.yaml
kubectl -n uni-resolver apply -f deployment-uni-resolver-did-v1-driver.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-abt.yaml
kubectl -n uni-resolver apply -f deployment-driver-did-trustbloc.yaml
kubectl -n uni-resolver apply -f deployment-uni-resolver-web.yaml
kubectl -n uni-resolver apply -f deployment-uni-resolver-frontend.yaml
45 changes: 45 additions & 0 deletions ci/deploy-k8s-aws/deploy/deployment-driver-did-trustbloc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "driver-did-trustbloc"
namespace: "uni-resolver"
labels:
app: "driver-did-trustbloc"
spec:
replicas: 1
selector:
matchLabels:
app: "driver-did-trustbloc"
template:
metadata:
labels:
app: "driver-did-trustbloc"
spec:
containers:
- name: "driver-did-trustbloc"
image: trustbloc/driver-did-trustbloc:0.1.3
imagePullPolicy: Always
ports:
- containerPort: 8102
command: ['sh', '-c', 'did-method start']
env:
- name: DID_METHOD_HOST_URL
value: "0.0.0.0:8102"
- name: DID_METHOD_TLS_SYSTEMCERTPOOL
value: "true"
- name: DID_METHOD_MODE
value: "resolver"
---
apiVersion: v1
kind: Service
metadata:
name: "driver-did-trustbloc"
namespace: "uni-resolver"
spec:
type: NodePort
selector:
app: "driver-did-trustbloc"
ports:
- protocol: TCP
port: 8102
targetPort: 8102
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "uni-resolver-driver-did-echo"
namespace: "uni-resolver"
labels:
app: "uni-resolver-driver-did-echo"
spec:
replicas: 1
selector:
matchLabels:
app: "uni-resolver-driver-did-echo"
template:
metadata:
labels:
app: "uni-resolver-driver-did-echo"
spec:
containers:
- name: "uni-resolver-driver-did-echo"
image: echoprotocol/uni-resolver-driver-did-echo:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
env:
- name: uniresolver_driver_did_echo_mainnet_rpc_url
value: "http://127.0.0.1:8090/rpc"
- name: uniresolver_driver_did_echo_testnet_rpc_url
value: "http://testnet.echo-dev.io"
- name: uniresolver_driver_did_echo_devnet_rpc_url
value: "http://127.0.0.1:8090/rpc"
---
apiVersion: v1
kind: Service
metadata:
name: "uni-resolver-driver-did-echo"
namespace: "uni-resolver"
spec:
type: NodePort
selector:
app: "uni-resolver-driver-did-echo"
ports:
- protocol: TCP
port: 8080
targetPort: 8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "uni-resolver-driver-did-uport"
namespace: "uni-resolver"
labels:
app: "uni-resolver-driver-did-uport"
spec:
replicas: 1
selector:
matchLabels:
app: "uni-resolver-driver-did-uport"
template:
metadata:
labels:
app: "uni-resolver-driver-did-uport"
spec:
containers:
- name: "uni-resolver-driver-did-uport"
image: uport/uni-resolver-driver-did-uport:1.3.1
imagePullPolicy: Always
ports:
- containerPort: 8081
---
apiVersion: v1
kind: Service
metadata:
name: "uni-resolver-driver-did-uport"
namespace: "uni-resolver"
spec:
type: NodePort
selector:
app: "uni-resolver-driver-did-uport"
ports:
- protocol: TCP
port: 8081
targetPort: 8081
38 changes: 38 additions & 0 deletions ci/deploy-k8s-aws/deploy/deployment-uni-resolver-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: uni-resolver-frontend
namespace: uni-resolver
labels:
app: uni-resolver-frontend
type: driver
spec:
replicas: 1
selector:
matchLabels:
app: uni-resolver-frontend
template:
metadata:
labels:
app: uni-resolver-frontend
spec:
containers:
- name: uni-resolver-frontend
image: universalresolver/uni-resolver-frontend:latest
imagePullPolicy: Always
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: uni-resolver-frontend
namespace: uni-resolver
spec:
type: NodePort
selector:
app: uni-resolver-frontend
ports:
- protocol: TCP
port: 80
targetPort: 80
Loading

0 comments on commit 1ce97f1

Please sign in to comment.