Skip to content

Commit 65fa357

Browse files
authored
deploy commander using helm (#550)
* deploy commander using helm * teardown commanders using helm, fix status * stop scenario faster * stop warnet faster * fix scenarios_test User proper scenarios delete function
1 parent 4fff537 commit 65fa357

File tree

10 files changed

+339
-109
lines changed

10 files changed

+339
-109
lines changed
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/commander/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: commander
3+
description: A Helm chart for a commander
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+
Commander beginning their mission.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "commander.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 "commander.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 "commander.chart" -}}
25+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
26+
{{- end }}
27+
28+
{{/*
29+
Common labels
30+
*/}}
31+
{{- define "commander.labels" -}}
32+
helm.sh/chart: {{ include "commander.chart" . }}
33+
{{ include "commander.selectorLabels" . }}
34+
{{- if .Chart.AppVersion }}
35+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
36+
{{- end }}
37+
app.kubernetes.io/managed-by: {{ .Release.Service }}
38+
{{- with .Values.podLabels }}
39+
{{ toYaml . }}
40+
{{- end }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels
45+
*/}}
46+
{{- define "commander.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "commander.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
50+
51+
{{/*
52+
Create the name of the service account to use
53+
*/}}
54+
{{- define "commander.serviceAccountName" -}}
55+
{{- if .Values.serviceAccount.create }}
56+
{{- default (include "commander.fullname" .) .Values.serviceAccount.name }}
57+
{{- else }}
58+
{{- default "default" .Values.serviceAccount.name }}
59+
{{- end }}
60+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "commander.fullname" . }}-scenario
5+
labels:
6+
{{- include "commander.labels" . | nindent 4 }}
7+
binaryData:
8+
scenario.py: {{ .Values.scenario }}
9+
---
10+
apiVersion: v1
11+
kind: ConfigMap
12+
metadata:
13+
name: {{ include "commander.fullname" . }}-warnet
14+
labels:
15+
{{- include "commander.labels" . | nindent 4 }}
16+
binaryData:
17+
warnet.json: {{ .Values.warnet }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: {{ include "commander.fullname" . }}
5+
labels:
6+
{{- include "commander.labels" . | nindent 4 }}
7+
app: {{ include "commander.name" . }}
8+
mission: commander
9+
spec:
10+
restartPolicy: {{ .Values.restartPolicy }}
11+
containers:
12+
- name: {{ .Chart.Name }}
13+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
14+
imagePullPolicy: {{ .Values.image.pullPolicy }}
15+
command: ["/bin/sh", "-c"]
16+
args:
17+
- |
18+
python3 /scenario.py {{ .Values.args }}
19+
volumeMounts:
20+
- name: scenario
21+
mountPath: /scenario.py
22+
subPath: scenario.py
23+
- name: warnet
24+
mountPath: /warnet.json
25+
subPath: warnet.json
26+
volumes:
27+
- name: scenario
28+
configMap:
29+
name: {{ include "commander.fullname" . }}-scenario
30+
- name: warnet
31+
configMap:
32+
name: {{ include "commander.fullname" . }}-warnet
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Default values for commander.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
namespace: warnet
5+
6+
restartPolicy: Never
7+
8+
image:
9+
repository: bitcoindevproject/warnet-commander
10+
pullPolicy: IfNotPresent
11+
# Overrides the image tag whose default is the chart appVersion.
12+
tag: "latest"
13+
14+
imagePullSecrets: []
15+
nameOverride: ""
16+
fullnameOverride: ""
17+
18+
podLabels:
19+
app: "warnet"
20+
mission: "commander"
21+
22+
podSecurityContext: {}
23+
24+
securityContext: {}
25+
26+
service:
27+
type: ClusterIP
28+
29+
resources: {}
30+
# We usually recommend not to specify default resources and to leave this as a conscious
31+
# choice for the user. This also increases chances charts run on environments with little
32+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
33+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
34+
# limits:
35+
# cpu: 100m
36+
# memory: 128Mi
37+
# requests:
38+
# cpu: 100m
39+
# memory: 128Mi
40+
41+
# livenessProbe:
42+
# exec:
43+
# command:
44+
# - pidof
45+
# - commander
46+
# failureThreshold: 3
47+
# initialDelaySeconds: 5
48+
# periodSeconds: 5
49+
# successThreshold: 1
50+
# timeoutSeconds: 1
51+
# readinessProbe:
52+
# failureThreshold: 1
53+
# periodSeconds: 1
54+
# successThreshold: 1
55+
# tcpSocket:
56+
# port: 2323
57+
# timeoutSeconds: 1
58+
59+
# Additional volumes on the output Deployment definition.
60+
volumes: []
61+
# - name: foo
62+
# secret:
63+
# secretName: mysecret
64+
# optional: false
65+
66+
# Additional volumeMounts on the output Deployment definition.
67+
volumeMounts: []
68+
# - name: foo
69+
# mountPath: "/etc/foo"
70+
# readOnly: true
71+
72+
port:
73+
74+
scenario: ""
75+
76+
warnet: ""
77+
78+
args: ""

src/warnet/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# Helm charts
3131
BITCOIN_CHART_LOCATION = str(CHARTS_DIR.joinpath("bitcoincore"))
3232
FORK_OBSERVER_CHART = str(CHARTS_DIR.joinpath("fork-observer"))
33+
COMMANDER_CHART = str(CHARTS_DIR.joinpath("commander"))
3334
NAMESPACES_CHART_LOCATION = CHARTS_DIR.joinpath("namespaces")
3435
DEFAULT_NETWORK = Path("6_node_bitcoin")
3536
DEFAULT_NAMESPACES = Path("two_namespaces_two_users")

0 commit comments

Comments
 (0)