Skip to content

Commit

Permalink
Basic Frinx Machine deployment structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Volak committed Aug 2, 2024
1 parent de6b849 commit e9fa08b
Show file tree
Hide file tree
Showing 13 changed files with 376 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.tgz
*.lock
**/temp/*
.idea
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,62 @@
# gitops-boilerplate
# gitops-boilerplate

This repository provides instructions for installing and managing Frinx Machine on Kubernetes.

Part of installation is also deploying custom worker from [frinx-workers-boilerplate](https://github.com/FRINXio/frinx-workers-boilerplate).

Follow the instructions below to get started.

### Prerequisities

Before you begin, ensure you have the following tools installed:

- [`docker`](https://docs.docker.com/engine/install/)
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/)
- [`minikube`](https://minikube.sigs.k8s.io/docs/start/)
- [`helm`](https://helm.sh/docs/intro/install/)
- [`just`](https://github.com/casey/just)


## Quick Start

### Docker login

Justfile uses `~/.docker/config.json` path for creating kubernetes docker registry secret.
For accessing private images, please contact `[email protected]`

### Install Frinx Machine locally

Frinx Machine is deployed to the `gitops-boilerplate` namespace.
The `justfile` provides commands to manage the local deployment process easily.

> [!NOTE]
> justfile uses local-values.yaml by default
> to override it, use just --set values "" deploy
```bash
just # print help

# start Minikube with required parameters
just minikube-start

# deploy FM with specific

just deploy

# exclude apps from deployment
just --set exclude "custom-worker" deploy

# include custom values
just --set values "local-values.yaml" deploy
just --set values "cluster-values.yaml" deploy

# uninstall deployment with specific stage
just uninstall
```

### Advanced deployment configuration

For detailed documentation and advanced configuration options,
please refer to the individual Chart.yaml and values.yaml files located in the apps directory.

More more info visit [Frinx Helm Charts](https://artifacthub.io/packages/search?org=frinx)
24 changes: 24 additions & 0 deletions apps/custom-worker/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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/

14 changes: 14 additions & 0 deletions apps/custom-worker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: frinx-workers-boilerplate
description: Kubernetes deployment of custom worker
icon: https://avatars.githubusercontent.com/u/23452093?s=200&v=4
type: application
version: 6.1.0
maintainers:
- name: FRINX
dependencies:
- condition: frinx-workers-boilerplate.enabled
name: worker
alias: frinx-workers-boilerplate
repository: https://FRINXio.github.io/helm-charts
version: 4.0.0
13 changes: 13 additions & 0 deletions apps/custom-worker/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
x-frinx-rbac-admin-role: &frinx-rbac-admin-role "FRINXio"

frinx-workers-boilerplate:
enabled: true

fullnameOverride: "frinx-workers-boilerplate"

image:
repository: frinx/frinx-workers-boilerplate
tag: "6.1.0"

env:
X_AUTH_USER_GROUP: *frinx-rbac-admin-role
24 changes: 24 additions & 0 deletions apps/frinx-machine-operators/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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/

12 changes: 12 additions & 0 deletions apps/frinx-machine-operators/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
name: frinx-machine-operators
description: Kubernetes deployment of FRINX-machine
icon: https://avatars.githubusercontent.com/u/23452093?s=200&v=4
type: application
version: 6.1.0
maintainers:
- name: FRINX
dependencies:
- name: frinx-machine-operators
repository: https://FRINXio.github.io/helm-charts
version: 0.2.0
8 changes: 8 additions & 0 deletions apps/frinx-machine-operators/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
frinx-machine-operators:
# CRDs

kube-arangodb:
enabled: true

cloudnative-pg:
enabled: true
24 changes: 24 additions & 0 deletions apps/frinx-machine/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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/

12 changes: 12 additions & 0 deletions apps/frinx-machine/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
name: frinx-machine
description: Kubernetes deployment of FRINX-machine
icon: https://avatars.githubusercontent.com/u/23452093?s=200&v=4
type: application
version: 6.1.0
maintainers:
- name: FRINX
dependencies:
- name: frinx-machine
repository: https://FRINXio.github.io/helm-charts
version: 9.0.1
31 changes: 31 additions & 0 deletions apps/frinx-machine/local-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
frinx-machine:
krakend:
ingress:
enabled: true
className: nginx
annotations:
# force-ssl-redirect must be disabled in case you are using a self-signed certificate
# nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
hosts:
- host: krakend.127.0.0.1.nip.io
paths:
- path: "/"
pathType: ImplementationSpecific

workflow-manager:
ingress:
enabled: true
hosts:
- host: workflow-manager.127.0.0.1.nip.io
paths:
- path: "/"
pathType: ImplementationSpecific
schellarHosts:
- host: workflow-manager-schellar.127.0.0.1.nip.io
paths:
- path: "/"
pathType: ImplementationSpecific
10 changes: 10 additions & 0 deletions apps/frinx-machine/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
frinx-machine:
uniconfig:
image:
# Use private regitry
repository: "frinxio/uniconfig"

performance-monitor:
image:
# Use private regitry
repository: "frinxio/performance-monitor"
138 changes: 138 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Define environment variables (if any)
set dotenv-load := true

# Global ENVs
justfileDir := justfile_directory()
namespace := shell('basename $1', justfileDir)
operatorChartName := "frinx-machine-operators"

# Execution ENVs. Can be overided on startup
values := "local-values.yaml"
exclude := ""

[private]
default:
@echo '{{ \
"\nJustfile for Frinx Machine execution: start Frinx Machine stage locally\n\n" + \
"Default env variables: \n\n" + \
"\tvalues: Add extra value files to helm command\n" + \
"\texclude: Exclude apps from installation process\n\n" + \
"Example of usage: \n\n" + \
"\t just deploy \n" + \
"\t just --set values \"local-values.yaml\" deploy \n" + \
"\t just --set exclude \"frinx-machine-monitoring,frinx-machine\" deploy" \
}}\n'

@just --list

[private]
create-namespace:
kubectl create namespace {{namespace}} || true

[private]
deploy-stage-operators values="":
#!/usr/bin/env bash
set -euo pipefail
VALUES={{values}}
pushd {{justfileDir}}/apps/{{operatorChartName}} > /dev/null
helm dependency update
helm upgrade --install --create-namespace -n {{namespace}} {{operatorChartName}} . --values values.yaml $(for val in {{values}}; do if [ -f $val ]; then echo --values $val; fi ; done)
popd > /dev/null

[private]
uninstall-stage-operators values="":
#!/usr/bin/env bash
set -euo pipefail
pushd {{justfileDir}}/apps/{{operatorChartName}} > /dev/null
helm dependency update
helm template -n {{namespace}} {{operatorChartName}} . ---values values.yaml $(for val in {{values}}; do if [ -f $val ]; then echo --values $val; fi ; done) | kubectl delete -f- || true
popd > /dev/null

# Function to deploy a stage with the ability to exclude apps and specify values files
[private]
deploy-stage exclude values:
#!/usr/bin/env bash
set -euo pipefail
SKIP_CHARTS={{exclude}}
IFS=',' read -r -a EXCLUDE <<< "{{operatorChartName}},${SKIP_CHARTS}"
pushd {{justfileDir}}/apps > /dev/null
APPS=($(ls -d */ | sed 's:/*$::'))

for dir in "${APPS[@]}"; do
if [ -d "$dir" ]; then
pushd "$dir" > /dev/null
BASENAME=$(basename "$PWD")

# Check if the directory name is in the ignore list
if [[ " ${EXCLUDE[@]} " =~ " ${BASENAME} " ]]; then
echo "Skipping directory: $BASENAME"
popd > /dev/null
continue
fi

echo "Processing directory: $BASENAME"
helm dependency update
helm upgrade --install --create-namespace -n {{namespace}} $(basename $PWD) . --values values.yaml $(for val in {{values}}; do if [ -f $val ]; then echo --values $val; fi ; done)

popd > /dev/null
fi
done
popd > /dev/null

# Function to deploy a stage with the ability to exclude apps and specify values files
[private]
uninstall-stage exclude:
#!/usr/bin/env bash
set -euo pipefail
SKIP_CHARTS={{exclude}}
IFS=',' read -r -a EXCLUDE <<< "{{operatorChartName}},${SKIP_CHARTS}"

pushd {{justfileDir}}/apps > /dev/null
APPS=($(ls -d */ | sed 's:/*$::'))

for dir in "${APPS[@]}"; do
if [ -d "$dir" ]; then
pushd "$dir" > /dev/null
BASENAME=$(basename "$PWD")

# Check if the directory name is in the ignore list
if [[ " ${EXCLUDE[@]} " =~ " ${BASENAME} " ]]; then
echo "Skipping directory: $BASENAME"
popd > /dev/null
continue
fi

echo "Processing directory: $BASENAME"
helm uninstall -n {{namespace}} $(basename $PWD) || true

popd > /dev/null
fi
done
popd > /dev/null

# Recipe to deploy apps with optional apps exclusion and values files
deploy:
just create-namespace
just docker-secret
just deploy-stage-operators {{values}}
just deploy-stage "{{exclude}}" "{{values}}"

# Recipe to uninstall apps with optional apps exclusion and values files
uninstall:
just uninstall-stage "{{exclude}}"
just uninstall-stage-operators "{{values}}"

# Recipe to start minikube with max CPUs and 24G memory, instess addon enabled
minikube-start:
minikube start --cpus=max --memory=24G --addons=ingress

# Create docker secret from $HOME/.docker/config.json
docker-secret:
kubectl create secret generic regcred \
--from-file=.dockerconfigjson=$HOME/.docker/config.json \
--type=kubernetes.io/dockerconfigjson \
--namespace={{namespace}} || true

0 comments on commit e9fa08b

Please sign in to comment.