This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding support for cakeshop. * Can now run cakeshop as a k8s deployment, by adding ``` cakeshop: version: latest ``` to the config file when generating the quorum K8s resources. * Add docs and screen shots `docs/reouces/cakeshop.md`. * Add example config `examples/config/cakeshop.yaml`. * Note: kind does not easily support connecting to NodePorts, so minikube/docker desktop or a more complete K8s runtime is required.
- Loading branch information
Showing
6 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## Cakeshop Running In K8s | ||
|
||
### Example Config | ||
[cakeshop.yaml](../examples/config/cakeshop.yaml) | ||
|
||
```yaml | ||
# number of nodes to deploy | ||
nodes: | ||
number: 4 | ||
quorum: | ||
quorum: | ||
# supported: (raft | istanbul) | ||
consensus: istanbul | ||
Quorum_Version: 2.6.0 | ||
tm: | ||
# (tessera|constellation) | ||
Name: tessera | ||
Tm_Version: 0.10.4 | ||
cakeshop: | ||
version: latest | ||
service: | ||
type: NodePort | ||
nodePort: 30108 | ||
``` | ||
## Generate The K8s Resources | ||
```bash | ||
$> docker run --rm -it -v $(pwd)/cakeshop.yaml:/qubernetes/cakeshop.yaml -v $(pwd)/out:/qubernetes/out quorumengineering/qubernetes ./qube-init cakeshop.yaml | ||
``` | ||
|
||
## Deploy To K8s (Minikube or Other K8s runtime - not kind as kind does not support connecting to NodePorts easily) | ||
```bash | ||
$> kubectl apply -f out -f out/deployments | ||
``` | ||
|
||
## Get The URL For The Cakeshop Deployment | ||
|
||
```bash | ||
$> kc get services | ||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
cakeshop-service NodePort 10.110.202.50 <none> 8999:30108/TCP | ||
``` | ||
## If Running minikube | ||
* use `$(minikube ip):NodePort`, e.g. NodePort from above is `30108` | ||
```bash | ||
$> echo $(minikube ip):30108 | ||
192.168.64.25:30108 | ||
``` | ||
|
||
## If Running Docker Desktop K8s | ||
* Your URL will be `localhost:NodePort`, e.g. `localhost:30108` | ||
|
||
## Open In Browser And Select "Manage Nodes" (upper right corner) | ||
![cakeshop-manage-nodes](resources/cakeshop-managed-node-ui.png) | ||
|
||
## Get The Quorum Node URLs | ||
```bash | ||
$> kubectl get service | ||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
cakeshop-service NodePort 10.110.202.50 <none> 8999:30108/TCP 9m9s | ||
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 10h | ||
quorum-node1 NodePort 10.101.38.95 <none> 9001:30239/TCP,9080:31461/TCP,8545:32321/TCP,8546:32293/TCP,30303:32559/TCP 9m9s | ||
quorum-node2 NodePort 10.98.143.110 <none> 9001:31373/TCP,9080:30073/TCP,8545:30972/TCP,8546:30713/TCP,30303:32095/TCP 9m9s | ||
quorum-node3 NodePort 10.99.63.70 <none> 9001:32161/TCP,9080:31576/TCP,8545:30497/TCP,8546:31440/TCP,30303:30180/TCP 9m9s | ||
quorum-node4 NodePort 10.97.128.158 <none> 9001:31188/TCP,9080:30530/TCP,8545:30235/TCP,8546:31332/TCP,30303:31820/TCP 9m9s | ||
``` | ||
![cakeshop-get-node-urls](resources/cake-k8s-get-node-urls.png) | ||
|
||
## Add Nodes To Cakeshop | ||
* Use the `CLUSTER-IP` and the cluster ports for geth (default `8545`) and tessera (default `9080`) | ||
![cakeshop-add-node1](resources/cakeshop-add-node1.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<%- | ||
@Cakeshop_Version = @config["cakeshop"]["version"] | ||
|
||
# default quorumengineering/quorum | ||
if @config["cakeshop"]["Docker_Repo"] | ||
@Cakeshop_Docker_Repo = @config["cakeshop"]["Docker_Repo"] | ||
else | ||
@Cakeshop_Docker_Repo = "quorumengineering" | ||
end | ||
# NodePort | ClusterIP | Loadbalancer | ||
# default to NodePort if not set | ||
@Service_Type = "LoadBalancer" | ||
if @config["cakeshop"] and @config["cakeshop"]["service"] and @config["cakeshop"]["service"]["type"] | ||
@Service_Type = @config["cakeshop"]["service"]["type"] | ||
end | ||
-%> | ||
|
||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: cakeshop-service | ||
labels: | ||
app: cakeshop | ||
spec: | ||
# LoadBalancer is the default: Create an HA proxy in the cloud provider | ||
# with an External IP address - *Only supported by some cloud providers* | ||
# loadbalancer access via externalIp:port (8999) | ||
# NodePort | ClusterIP | Loadbalancer | ||
type: <%= @Service_Type %> | ||
ports: | ||
# Accept traffic sent to port 8080 | ||
- name: http | ||
protocol: TCP | ||
port: 8999 | ||
targetPort: 8080 | ||
<%- if @config["cakeshop"] and @config["cakeshop"] and @config["cakeshop"]["service"]["nodePort"] -%> | ||
nodePort: <%= @config["cakeshop"]["service"]["nodePort"] %> | ||
<%- end -%> | ||
selector: | ||
# Loadbalance traffic across Pods matching | ||
# this label selector | ||
app: cakeshop | ||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
# Unique key of the Deployment instance | ||
name: cakeshop-deployment | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: cakeshop | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
# Apply this label to pods and default | ||
# the Deployment label selector to this value | ||
app: cakeshop | ||
spec: | ||
containers: | ||
- name: cakeshop | ||
image: <%= @Cakeshop_Docker_Repo %>/cakeshop:<%= @Cakeshop_Version %> | ||
imagePullPolicy: Always | ||
env: | ||
- name: JAVA_OPTS | ||
value: "-Dgeth.auto.start=false -Dgeth.auto.stop=false" | ||
ports: | ||
- containerPort: 8999 | ||
|
||
<%- | ||
|
||
if @config["cakeshop"] and @config["cakeshop"]["service"] and @config["cakeshop"]["service"]["Ingress"] then | ||
@Ingress = true | ||
|
||
if @config["cakeshop"]["service"]["Ingress"]["Host"] then | ||
@Ingress_Host = @config["cakeshop"]["service"]["Ingress"]["Host"] | ||
end | ||
|
||
end | ||
|
||
-%> | ||
|
||
<%- if @Ingress -%> | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
<%= @Namespace %> | ||
name: cakeshop-ingress | ||
spec: | ||
rules: | ||
<%- if @Ingress_Host -%> | ||
- host: "<%= @Ingress_Host %>" | ||
http: | ||
paths: | ||
- path: /cakeshop | ||
backend: | ||
serviceName: cakeshop-service | ||
servicePort: 8080 | ||
<%- else -%> | ||
- http: | ||
paths: | ||
- path: /cakeshop | ||
backend: | ||
serviceName: cakeshop-service | ||
servicePort: 8080 | ||
<%- end -%> | ||
<%- if @Ingress_Host -%> | ||
tls: | ||
- hosts: | ||
- "<%= @Ingress_Host %>" | ||
<%- end -%> | ||
<%- end -%> |