Skip to content

Commit d4a0190

Browse files
authored
Merge pull request #531 from willcl-ark/caddy-proxy
unified HTML landing page (NOT a dashboard!)
2 parents b439ad2 + e75cace commit d4a0190

File tree

25 files changed

+513
-100
lines changed

25 files changed

+513
-100
lines changed

docs/quickstart.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Quick run
2+
3+
## Installation
4+
5+
Either install warnet via pip, or clone the source and install:
6+
7+
### via pip
8+
9+
You can install warnet via `pip` into a virtual environment with
10+
11+
```bash
12+
python3 -m venv .venv
13+
source .venv/bin/activate
14+
pip install warnet
15+
```
16+
17+
### via cloned source
18+
19+
You can install warnet from source into a virtual environment with
20+
21+
```bash
22+
git clone https://github.com/bitcoin-dev-project/warnet.git
23+
cd warnet
24+
python3 -m venv .venv
25+
source .venv/bin/activate
26+
pip install -e .
27+
```
28+
29+
## Running
30+
31+
To get started first check you have all the necessary requirements:
32+
33+
```bash
34+
warnet setup
35+
```
36+
37+
Then create your first network:
38+
39+
```bash
40+
# Create a new network in the current directory
41+
warnet init
42+
43+
# Or in a directory of choice
44+
warnet new <directory>
45+
```
46+
47+
Follow the guide to configure network variables.
48+
49+
## fork-observer
50+
51+
If you enabled [fork-observer](https://github.com/0xB10C/fork-observer), it will be available from the landing page at `localhost:2019`.

resources/charts/caddy/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

resources/charts/caddy/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: caddy-server
3+
description: A Helm chart for Caddy
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: 0.1.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Caddy is serving your every need.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "caddy.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "caddy.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- end }}
19+
{{- end }}
20+
21+
{{/*
22+
Create chart name and version as used by the chart label.
23+
*/}}
24+
{{- define "caddy.chart" -}}
25+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
26+
{{- end }}
27+
28+
{{/*
29+
Common labels
30+
*/}}
31+
{{- define "caddy.labels" -}}
32+
helm.sh/chart: {{ include "caddy.chart" . }}
33+
{{ include "caddy.selectorLabels" . }}
34+
{{- if .Chart.AppVersion }}
35+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
36+
{{- end }}
37+
app.kubernetes.io/managed-by: {{ .Release.Service }}
38+
{{- end }}
39+
40+
{{/*
41+
Selector labels
42+
*/}}
43+
{{- define "caddy.selectorLabels" -}}
44+
app.kubernetes.io/name: {{ include "caddy.name" . }}
45+
app.kubernetes.io/instance: {{ .Release.Name }}
46+
{{- end }}
47+
48+
{{/*
49+
Create the name of the service account to use
50+
*/}}
51+
{{- define "caddy.serviceAccountName" -}}
52+
{{- if .Values.serviceAccount.create }}
53+
{{- default (include "caddy.fullname" .) .Values.serviceAccount.name }}
54+
{{- else }}
55+
{{- default "default" .Values.serviceAccount.name }}
56+
{{- end }}
57+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "caddy.fullname" . }}
5+
labels:
6+
{{- include "caddy.labels" . | nindent 4 }}
7+
data:
8+
Caddyfile: |
9+
{{- .Values.caddyConfig | nindent 4 }}
10+
index: |
11+
{{- .Values.htmlConfig | nindent 4 }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: {{ include "caddy.fullname" . }}
5+
labels:
6+
{{- include "caddy.labels" . | nindent 4 }}
7+
{{- with .Values.podLabels }}
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
10+
app: {{ include "caddy.fullname" . }}
11+
spec:
12+
restartPolicy: "{{ .Values.restartPolicy }}"
13+
{{- with .Values.imagePullSecrets }}
14+
imagePullSecrets:
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
securityContext:
18+
{{- toYaml .Values.podSecurityContext | nindent 4 }}
19+
containers:
20+
- name: {{ .Chart.Name }}
21+
securityContext:
22+
{{- toYaml .Values.securityContext | nindent 8 }}
23+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
24+
imagePullPolicy: {{ .Values.image.pullPolicy }}
25+
ports:
26+
- name: web
27+
containerPort: {{ .Values.port }}
28+
protocol: TCP
29+
livenessProbe:
30+
{{- toYaml .Values.livenessProbe | nindent 8 }}
31+
readinessProbe:
32+
{{- toYaml .Values.readinessProbe | nindent 8 }}
33+
resources:
34+
{{- toYaml .Values.resources | nindent 8 }}
35+
volumeMounts:
36+
{{- toYaml .Values.volumeMounts | nindent 8 }}
37+
volumes:
38+
{{- toYaml .Values.volumes | nindent 4 }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "caddy.fullname" . }}
5+
labels:
6+
{{- include "caddy.labels" . | nindent 4 }}
7+
app: {{ include "caddy.fullname" . }}
8+
spec:
9+
type: {{ .Values.service.type }}
10+
ports:
11+
- port: {{ .Values.port }}
12+
targetPort: web
13+
protocol: TCP
14+
name: http
15+
selector:
16+
{{- include "caddy.selectorLabels" . | nindent 4 }}

resources/charts/caddy/values.yaml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Default values for caddy.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
namespace: warnet
5+
6+
restartPolicy: Always
7+
8+
image:
9+
repository: caddy
10+
pullPolicy: IfNotPresent
11+
# Overrides the image tag whose default is the chart appVersion.
12+
tag: "2.8.4"
13+
14+
imagePullSecrets: []
15+
16+
nameOverride: ""
17+
18+
fullnameOverride: ""
19+
20+
podLabels:
21+
app: "warnet"
22+
mission: "proxy"
23+
24+
podSecurityContext: {}
25+
# fsGroup: 2000
26+
27+
securityContext: {}
28+
# capabilities:
29+
# drop:
30+
# - ALL
31+
# readOnlyRootFilesystem: true
32+
# runAsNonRoot: true
33+
# runAsUser: 1000
34+
35+
service:
36+
type: ClusterIP
37+
38+
resources: {}
39+
# We usually recommend not to specify default resources and to leave this as a conscious
40+
# choice for the user. This also increases chances charts run on environments with little
41+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
42+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
43+
# limits:
44+
# cpu: 100m
45+
# memory: 128Mi
46+
# requests:
47+
# cpu: 100m
48+
# memory: 128Mi
49+
50+
livenessProbe:
51+
httpGet:
52+
path: /live
53+
port: 80
54+
failureThreshold: 3
55+
initialDelaySeconds: 5
56+
periodSeconds: 5
57+
successThreshold: 1
58+
timeoutSeconds: 1
59+
60+
readinessProbe:
61+
httpGet:
62+
path: /ready
63+
port: 80
64+
failureThreshold: 1
65+
periodSeconds: 1
66+
successThreshold: 1
67+
timeoutSeconds: 1
68+
69+
volumes:
70+
- name: caddy-config
71+
configMap:
72+
name: caddy
73+
items:
74+
- key: Caddyfile
75+
path: Caddyfile
76+
- key: index
77+
path: index
78+
79+
volumeMounts:
80+
- name: caddy-config
81+
mountPath: /etc/caddy/Caddyfile
82+
subPath: Caddyfile
83+
- name: caddy-config
84+
mountPath: /usr/share/caddy/index.html
85+
subPath: index
86+
87+
port: 80
88+
89+
caddyConfig: |
90+
:80 {
91+
respond /live 200
92+
respond /ready 200
93+
94+
root * /usr/share/caddy
95+
file_server
96+
97+
handle_path /fork-observer/* {
98+
reverse_proxy fork-observer:2323
99+
}
100+
101+
handle_path /grafana/* {
102+
reverse_proxy loki-grafana:80
103+
}
104+
105+
}
106+
107+
htmlConfig: |
108+
<!DOCTYPE html>
109+
<html lang="en">
110+
<head>
111+
<meta charset="UTF-8">
112+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
113+
<title>Welcome</title>
114+
</head>
115+
<body>
116+
<h1>Welcome to the Warnet dashboard</h1>
117+
<p>You can access the following services:</p>
118+
<ul>
119+
<li><a href="/grafana/">Grafana</a></li>
120+
<li><a href="/fork-observer/">Fork Observer</a></li>
121+
</ul>
122+
</body>
123+
</html>
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
To view forkobserver you must forward the port from the cluster to your local machine
2-
3-
kubectl port-forward fork-observer 2323
4-
5-
fork-observer will then be available at web address: http://localhost:2323
1+
Fork observer enabled.

resources/manifests/grafana_values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ grafana.ini:
1616
auth:
1717
disable_login_form: true
1818
disable_signout_menu: true
19+
server:
20+
# this is required to use Grafana behind a reverse proxy (caddy)
21+
root_url: "%(protocol)s://%(domain)s:%(http_port)s/grafana/"
1922
auth.anonymous:
2023
enabled: true
2124
org_name: Main Org.

resources/networks/6_node_bitcoin/network.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ nodes:
2929
- tank-0006
3030
- name: tank-0006
3131
fork_observer:
32-
enabled: false
32+
enabled: true
33+
caddy:
34+
enabled: true

src/warnet/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
]
1313

1414
DEFAULT_NAMESPACE = "warnet"
15+
LOGGING_NAMESPACE = "warnet-logging"
1516
HELM_COMMAND = "helm upgrade --install --create-namespace"
1617

1718
# Directories and files for non-python assets, e.g., helm charts, example scenarios, default configs
@@ -32,6 +33,9 @@
3233
FORK_OBSERVER_CHART = str(CHARTS_DIR.joinpath("fork-observer"))
3334
COMMANDER_CHART = str(CHARTS_DIR.joinpath("commander"))
3435
NAMESPACES_CHART_LOCATION = CHARTS_DIR.joinpath("namespaces")
36+
FORK_OBSERVER_CHART = str(files("resources.charts").joinpath("fork-observer"))
37+
CADDY_CHART = str(files("resources.charts").joinpath("caddy"))
38+
3539
DEFAULT_NETWORK = Path("6_node_bitcoin")
3640
DEFAULT_NAMESPACES = Path("two_namespaces_two_users")
3741

0 commit comments

Comments
 (0)