Skip to content

Commit f4a52a3

Browse files
committed
chore: First chart draft
1 parent 68e4769 commit f4a52a3

File tree

16 files changed

+505
-0
lines changed

16 files changed

+505
-0
lines changed

.ct.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
chart-dirs:
2+
- chart/
3+
debug: true
4+
target-branch: main
5+
check-version-increment: false
6+
validate-maintainers: false

.github/workflows/pipeline.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build
2+
3+
4+
on: [push]
5+
6+
jobs:
7+
lint-test:
8+
name: Lint and Test
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up Helm
17+
uses: azure/setup-helm@v3
18+
with:
19+
version: v3.11.2
20+
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.9'
24+
check-latest: true
25+
26+
- name: Install dependencies
27+
id: install-dependencies
28+
run: |
29+
helm repo add my-repo https://charts.bitnami.com/bitnami
30+
helm dependency update chart/metasploit/
31+
32+
- name: Set up chart-testing
33+
uses: helm/[email protected]
34+
35+
- name: Run chart-testing (list-changed)
36+
id: list-changed
37+
run: |
38+
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
39+
if [[ -n "$changed" ]]; then
40+
echo "changed=true" >> "$GITHUB_OUTPUT"
41+
fi
42+
43+
- name: Run chart-testing (lint)
44+
if: steps.list-changed.outputs.changed == 'true'
45+
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
46+
47+
- name: Create kind cluster
48+
if: steps.list-changed.outputs.changed == 'true'
49+
uses: helm/[email protected]
50+
51+
- name: Run chart-testing (install)
52+
if: steps.list-changed.outputs.changed == 'true'
53+
run: ct install --target-branch ${{ github.event.repository.default_branch }}

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OS stuff
2+
*.icloud
3+
._*
4+
.DS_Store
5+
Thumbs.db
6+
Desktop.ini
7+
.Spotlight-V100
8+
.Trashes
9+
10+
11+
# Helm
12+
chart/metasploit/charts/
13+
chart/metasploit/values.*.yaml

chart/metasploit/.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/

chart/metasploit/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: postgresql
3+
repository: https://charts.bitnami.com/bitnami
4+
version: 12.2.6
5+
digest: sha256:9d825e4b75ffe02863908df9989aa33cdd1690b894a56194676ec31a0cc82528
6+
generated: "2023-03-29T06:53:50.150868+02:00"

chart/metasploit/Chart.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: v2
2+
name: metasploit
3+
description: A Helm chart for running metasploit in Kubernetes
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: "6.3.9"
25+
dependencies:
26+
- name: postgresql
27+
version: "12.2.6"
28+
repository: https://charts.bitnami.com/bitnami
29+
condition: postgresql.enabled
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "metasploit.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "metasploit.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "metasploit.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "metasploit.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "metasploit.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 "metasploit.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "metasploit.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "metasploit.labels" -}}
37+
helm.sh/chart: {{ include "metasploit.chart" . }}
38+
{{ include "metasploit.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "metasploit.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "metasploit.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "metasploit.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "metasploit.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- 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 "metasploit.fullname" . }}
5+
labels:
6+
{{- include "metasploit.labels" . | nindent 4 }}
7+
data:
8+
database.yml: |-
9+
production: &production
10+
adapter: postgresql
11+
database: {{ .Values.postgresql.global.postgresql.auth.database }}
12+
username: {{ .Values.postgresql.global.postgresql.auth.username }}
13+
password: {{ .Values.postgresql.global.postgresql.auth.password }}
14+
host: {{ .Release.Name}}-postgresql
15+
port: {{ .Values.postgresql.global.postgresql.servicePort }}
16+
pool: 200
17+
timeout: 5
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "metasploit.fullname" . }}
5+
labels:
6+
{{- include "metasploit.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "metasploit.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "metasploit.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
serviceAccountName: {{ include "metasploit.serviceAccountName" . }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
containers:
31+
- name: {{ .Chart.Name }}
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 12 }}
34+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
volumeMounts:
37+
- name: config-volume
38+
mountPath: /var/lib/postgresql/.msf4/database.yml
39+
subPath: database.yml
40+
readOnly: false
41+
- name: tmp-app-volume
42+
mountPath: /tmp/msf
43+
ports:
44+
- name: http
45+
containerPort: {{ .Values.service.port }}
46+
protocol: TCP
47+
livenessProbe:
48+
httpGet:
49+
path: /
50+
port: http
51+
readinessProbe:
52+
httpGet:
53+
path: /
54+
port: http
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
volumes:
58+
- name: config-volume
59+
configMap:
60+
name: {{ include "metasploit.fullname" . }}
61+
defaultMode: 0777
62+
- name: tmp-app-volume
63+
emptyDir:
64+
sizeLimit: 500Mi
65+
{{- with .Values.nodeSelector }}
66+
nodeSelector:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- with .Values.affinity }}
70+
affinity:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- with .Values.tolerations }}
74+
tolerations:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}

0 commit comments

Comments
 (0)