Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OCU-90] Dracon helm prod #158

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ bin
.custom_image
tests/output
.vscode/
charts/
53 changes: 21 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,37 +184,6 @@ deploy-elasticoperator: add-es-helm-repo
--create-namespace \
--version=$(ES_OPERATOR_VERSION)

deploy-elasticsearch: deploy-elasticoperator
@helm upgrade dracon-es deploy/elasticsearch/ \
--install \
--set version=$(ES_VERSION) \
--namespace $(DRACON_NS) \
--create-namespace

deploy-kibana: deploy-elasticsearch
@helm upgrade dracon-kb deploy/kibana/ \
--install \
--set version=$(ES_VERSION) \
--set es_name=dracon-es-elasticsearch \
--namespace $(DRACON_NS) \
--version $(ES_VERSION)

deploy-mongodb:
@helm upgrade consumer-mongodb https://charts.bitnami.com/bitnami/mongodb-$(MONGODB_VERSION).tgz \
--install \
--namespace $(DRACON_NS) \
--create-namespace \
--set "auth.usernames[0]=consumer-mongodb" \
--set "auth.passwords[0]=consumer-mongodb" \
--set "auth.databases[0]=consumer-mongodb"

deploy-pg:
@helm upgrade pg https://charts.bitnami.com/bitnami/postgresql-$(PG_VERSION).tgz \
--install \
--namespace $(DRACON_NS) \
--create-namespace \
--values=deploy/enrichment-db/values.yaml

deploy/tektoncd/pipeline/release-v$(TEKTON_VERSION).yaml:
@wget "https://storage.googleapis.com/tekton-releases/pipeline/previous/v$(TEKTON_VERSION)/release.yaml" -O $@

Expand All @@ -239,4 +208,24 @@ deploy-tektoncd-dashboard: tektoncd-dashboard-helm
--values ./deploy/tektoncd/dashboard/values.yaml \
--namespace $(TEKTON_NS)

dev-deploy: deploy-nginx deploy-arangodb deploy-kibana deploy-mongodb deploy-pg deploy-tektoncd-pipeline deploy-tektoncd-dashboard
deploy-dracon-dev: deploy-elasticoperator
make draconctl-image-publish CONTAINER_REPO=localhost:5000/ocurity/dracon
@helm upgrade dracon ./deploy/dracon/ \
--install \
--values ./deploy/dracon/values.dev.yaml \
--create-namespace \
--namespace $(DRACON_NS) \
--set "global.image.draconVersion=$(DRACON_VERSION)"
--wait

dev-deploy:
make deploy-nginx
make deploy-arangodb
make deploy-tektoncd-pipeline
make deploy-tektoncd-dashboard
make deploy-dracon-dev

dev-teardown:
kind delete clusters dracon-demo
dev:
./scripts/kind-with-registry.sh
23 changes: 23 additions & 0 deletions deploy/dracon/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
15 changes: 15 additions & 0 deletions deploy/dracon/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 15.2.5
- name: mongodb
repository: https://charts.bitnami.com/bitnami
version: 15.1.5
- name: elasticsearch
repository: file://../elasticsearch
version: 0.1.0
- name: kibana
repository: file://../kibana
version: 0.1.0
digest: sha256:a9bd592c24509f294eae3b9415f420b6ec7de9a141d2ba410b7eb7602e866961
generated: "2024-04-26T18:23:56.800279848+01:00"
23 changes: 23 additions & 0 deletions deploy/dracon/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: dracon
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "0.1.0"
dependencies:
- name: postgresql
version: 15.2.5
repository: https://charts.bitnami.com/bitnami
condition: postgres.enabled
- name: mongodb
version: 15.1.5
repository: https://charts.bitnami.com/bitnami
condition: mongodb.enabled
- name: elasticsearch
version: 0.1.0
repository: file://../elasticsearch
condition: elasticsearch.enabled
- name: kibana
version: 0.1.0
repository: file://../kibana
condition: kibana.enabled
62 changes: 62 additions & 0 deletions deploy/dracon/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "dracon-migrations.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "dracon-migrations.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "dracon-migrations.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "dracon-migrations.labels" -}}
helm.sh/chart: {{ include "dracon-migrations.chart" . }}
{{ include "dracon-migrations.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "dracon-migrations.selectorLabels" -}}
app.kubernetes.io/name: {{ include "dracon-migrations.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "dracon-migrations.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "dracon-migrations.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
29 changes: 29 additions & 0 deletions deploy/dracon/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "{{.Release.Name}}"
namespace: "{{.Values.namespace }}"
labels:
app.kubernetes.io/managed-by: {{.Release.Service | quote }}
app.kubernetes.io/instance: {{.Release.Name | quote }}
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: dracon-migrations
labels:
app.kubernetes.io/managed-by: {{.Release.Service | quote }}
app.kubernetes.io/instance: {{.Release.Name | quote }}
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
spec:
restartPolicy: Never
containers:
- name: dracon-migrations
image: {{.Values.global.image.registry}}/ocurity/dracon/draconctl:{{.Values.global.image.draconVersion|default "latest"}}
command: ["draconctl","migrations","apply","--url", {{.Values.global.enrichmentDB.connectionStr | quote}},"/etc/dracon/migrations/enrichment"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: dracon-migrations
namespace: "{{.Values.namespace }}"
rules:
- apiGroups:
- coordination.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: dracon-migrations
namespace: "{{.Values.namespace }}"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: dracon-migrations
namespace: "{{.Values.namespace }}"
38 changes: 38 additions & 0 deletions deploy/dracon/values.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

elasticsearch:
enabled: true
version: 8.3.2

kibana:
enabled: true
version: 8.3.2

mongodb:
enabled: true
# auth:
# enabled: true
# usernames: ["consumer-mongodb"]
# passwords: ["consumer-mongodb"]
# databases: ["consumer-mongodb"]
# rootUser: "consumer-mongodb"
# rootPassword: "consumer-mongodb"

postgresql:
enabled: true
auth:
username: dracon
password: dracon
database: dracon
postgresPassword: dracon
fullnameOverride: dracon-enrichment-db

tekton:
enabled: true

global:
namespace: dracon
image:
registry: kind-registry:5000
draconVersion: "0.1.0"
enrichmentDB:
connectionStr: postgresql://dracon:[email protected]?sslmode=disable
24 changes: 24 additions & 0 deletions deploy/dracon/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

elasticsearch:
enabled: false

kibana:
enabled: false

mongodb:
enabled: false


postgresql:
enabled: false

tekton:
enabled: false

global:
namespace: dracon
image:
registry: "ghcr.io"
draconVersion: "0.1.0"
enrichmentDB:
connectionStr: "the connection string to dracon enrichment db"
4 changes: 2 additions & 2 deletions deploy/elasticsearch/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
labels:
{{- include "elasticsearch.labels" . | nindent 4 }}
spec:
version: {{ .Values.version }}
image: docker.elastic.co/elasticsearch/elasticsearch:{{ .Values.version }}
version: {{.Values.version}}
image: docker.elastic.co/elasticsearch/elasticsearch:{{.Values.version}}
http:
tls:
selfSignedCertificate:
Expand Down
18 changes: 0 additions & 18 deletions deploy/kibana/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
apiVersion: v2
name: kibana
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
2 changes: 0 additions & 2 deletions deploy/kibana/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ spec:
count: 1
elasticsearchRef:
name: {{ .Values.es_name }}
# config:
# xpack.security.enabled: false
http:
tls:
selfSignedCertificate:
Expand Down
Loading