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

chore: add resources to deploy with helm and terraform connection-str… #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
55 changes: 55 additions & 0 deletions .github/workflows/pull-request-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docker images validation
on:
- pull_request

jobs:
validate-dockerfile-order-processor:
name: Validate dockerfile order processor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dockerfile:
- 'src/Keda.Samples.Dotnet.OrderProcessor/**'

- name: Build images
if: steps.filter.outputs.dockerfile == 'true'
run: docker build ./src/ --file ./src/Keda.Samples.Dotnet.OrderProcessor/Dockerfile --tag ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest

validate-dockerfile-portal:
name: Validate dockerfile portal
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dockerfile:
- 'src/Keda.Samples.DotNet.Web/**'

- name: Build tools
if: steps.filter.outputs.dockerfile == 'true'
run: docker build ./src/ --file ./src/Keda.Samples.DotNet.Web/Dockerfile --tag ghcr.io/kedacore/sample-dotnet-worker-servicebus-portal:latest

validate-order-generator:
name: Validate dockerfile order-generator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dockerfile:
- 'src/Keda.Samples.Dotnet.OrderGenerator/**'

- name: Build the Docker image
if: steps.filter.outputs.dockerfile == 'true'
run: docker build ./src/ --file ./src/Keda.Samples.Dotnet.OrderGenerator/Dockerfile --tag ghcr.io/kedacore/sample-dotnet-order-generator-servicebus:latest
28 changes: 28 additions & 0 deletions .github/workflows/pull-request-terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Terraform validation
on:
- pull_request

jobs:
validate-infra-as-code-connection-string:
name: Validate infra-as-code for connection-string scenario
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
infra-as-code:
- 'infra-as-code/connection-string/**'

- uses: hashicorp/setup-terraform@v2
if: steps.filter.outputs.infra-as-code == 'true'
with:
terraform_version: 1.3.2

- name: Terraform validate
if: steps.filter.outputs.infra-as-code == 'true'
run: |
terraform -chdir=infra-as-code/connection-string init
terraform -chdir=infra-as-code/connection-string validate
15 changes: 15 additions & 0 deletions .github/workflows/push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,18 @@ jobs:
run: docker build ./src/ --file ./src/Keda.Samples.DotNet.Web/Dockerfile --tag ghcr.io/kedacore/sample-dotnet-worker-servicebus-portal:latest
- name: Push the Docker image
run: docker push ghcr.io/kedacore/sample-dotnet-worker-servicebus-portal:latest
order_generator:
runs-on: ubuntu-latest
name: Order Generator
steps:
- uses: actions/checkout@v2
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: kedacore
password: ${{ secrets.CONTAINER_REGISTRY_KEY }}
- name: Build the Docker image
run: docker build ./src/ --file ./src/Keda.Samples.Dotnet.OrderGenerator/Dockerfile --tag ghcr.io/kedacore/sample-dotnet-order-generator-servicebus:latest
- name: Push the Docker image
run: docker push ghcr.io/kedacore/sample-dotnet-order-generator-servicebus:latest
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,13 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
/src/docker-compose.override.yml
/src/docker-compose.override.yml

# Terraform related files
*.tfstate
*.tfstate.backup
.terraform.tfstate.lock.info
.terraform
.terraform.lock.hcl
terraform.plan
terraform.destroy
194 changes: 186 additions & 8 deletions connection-string-scenario.md

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions deploy/helm/keda-servicebus-connection-string/.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/
24 changes: 24 additions & 0 deletions deploy/helm/keda-servicebus-connection-string/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: keda-servicebus-connection-string
description: A Helm chart to deploy KEDA service bus sample connection string scenario

# 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.3

# 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"
29 changes: 29 additions & 0 deletions deploy/helm/keda-servicebus-connection-string/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# keda-servicebus-connection-string

![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square)

A Helm chart to deploy KEDA service bus sample connection string scenario

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| fullnameOverride | string | `""` | |
| imagePullSecrets | list | `[]` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| orderConsumer | object | `{"servicebusConnectionString":""}` | Order consumer configuration |
| orderConsumer.servicebusConnectionString | string | `""` | Service bus connection string with manage permission |
| orderGenerator | object | `{"image":"ghcr.io/kedacore/sample-dotnet-order-generator-servicebus:latest","orderAmount":100,"queueName":"orders"}` | Order generator configuration |
| orderGenerator.image | string | `"ghcr.io/kedacore/sample-dotnet-order-generator-servicebus:latest"` | Image used by Job order-generator |
| orderGenerator.orderAmount | int | `100` | Number of orders that is going to be created in service bus for orders queue |
| orderGenerator.queueName | string | `"orders"` | Queue where the orders are going to be generated |
| orderProcessor | object | `{"image":"ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest","servicebusConnectionString":""}` | Order process configuration |
| orderProcessor.image | string | `"ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest"` | Image used by Deployment order-processor |
| orderProcessor.servicebusConnectionString | string | `""` | Service bus connection string with listen and send permissions |
| resources | object | `{}` | Resources configuration |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1. Keda test sample deployed
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "keda-servicebus-connection-string.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 "keda-servicebus-connection-string.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 "keda-servicebus-connection-string.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "keda-servicebus-connection-string.selectorLabels" -}}
app.kubernetes.io/name: {{ include "keda-servicebus-connection-string.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "keda-servicebus-connection-string.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "keda-servicebus-connection-string.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: batch/v1
kind: Job
metadata:
name: order-generator-{{ randAlphaNum 8 | lower }}
namespace: {{ .Release.Namespace }}
labels:
app: order-processor
{{- include "keda-servicebus-connection-string.labels" . | nindent 4 }}
spec:
template:
spec:
containers:
- name: order-generator
image: {{ .Values.orderGenerator.image }}
imagePullPolicy: Never
env:
- name: KEDA_SERVICEBUS_AUTH_MODE
value: ConnectionString
- name: KEDA_SERVICEBUS_QUEUE_NAME
value: "{{ .Values.orderGenerator.queueName }}"
- name: ORDER_AMOUNT
value: "{{ .Values.orderGenerator.orderAmount }}"
- name: KEDA_SERVICEBUS_QUEUE_CONNECTIONSTRING
valueFrom:
secretKeyRef:
name: secrets-order-consumer
key: servicebus-connectionstring
restartPolicy: Never
backoffLimit: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-processor
namespace: {{ .Release.Namespace }}
labels:
app: order-processor
{{- include "keda-servicebus-connection-string.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: order-processor
{{- include "keda-servicebus-connection-string.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: order-processor
{{- include "keda-servicebus-connection-string.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: order-processor
image: {{ .Values.orderProcessor.image }}
env:
- name: KEDA_SERVICEBUS_AUTH_MODE
value: ConnectionString
- name: KEDA_SERVICEBUS_QUEUE_CONNECTIONSTRING
valueFrom:
secretKeyRef:
name: secrets-order-consumer
key: servicebus-connectionstring
- name: KEDA_SERVICEBUS_QUEUE_NAME
value: orders
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: order-processor-scaler
namespace: {{ .Release.Namespace }}
spec:
scaleTargetRef:
name: order-processor
minReplicaCount: 0 # Change to define how many minimum replicas you want
maxReplicaCount: 50
# The period to wait after the last trigger reported active before scaling the resource back to 0.
# By default it’s 5 minutes (300 seconds).
cooldownPeriod: 5
triggers:
- type: azure-servicebus
metadata:
queueName: orders
messageCount: '50'
authenticationRef:
name: trigger-auth-service-bus-orders
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Secret
metadata:
name: secrets-order-consumer
namespace: {{ .Release.Namespace }}
labels:
app: order-processor
{{- include "keda-servicebus-connection-string.labels" . | nindent 4 }}
data:
servicebus-connectionstring: "{{ .Values.orderProcessor.servicebusConnectionString | b64enc }}"
---
apiVersion: v1
kind: Secret
metadata:
name: secrets-order-management
namespace: {{ .Release.Namespace }}
labels:
app: order-processor
{{- include "keda-servicebus-connection-string.labels" . | nindent 4 }}
data:
servicebus-order-management-connectionstring: "{{ .Values.orderConsumer.servicebusConnectionString | b64enc }}"
Loading