diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a433e3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.tgz +*.lock +**/temp/* +.idea diff --git a/README.md b/README.md index 1787b1f..e2dd491 100644 --- a/README.md +++ b/README.md @@ -1 +1,62 @@ -# gitops-boilerplate \ No newline at end of file +# 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 `marketing@elisapolystar.com` + +### 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) diff --git a/apps/custom-worker/.helmignore b/apps/custom-worker/.helmignore new file mode 100644 index 0000000..898df48 --- /dev/null +++ b/apps/custom-worker/.helmignore @@ -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/ + diff --git a/apps/custom-worker/Chart.yaml b/apps/custom-worker/Chart.yaml new file mode 100644 index 0000000..00ecb7d --- /dev/null +++ b/apps/custom-worker/Chart.yaml @@ -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 diff --git a/apps/custom-worker/values.yaml b/apps/custom-worker/values.yaml new file mode 100644 index 0000000..9341b57 --- /dev/null +++ b/apps/custom-worker/values.yaml @@ -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 diff --git a/apps/frinx-machine-operators/.helmignore b/apps/frinx-machine-operators/.helmignore new file mode 100644 index 0000000..898df48 --- /dev/null +++ b/apps/frinx-machine-operators/.helmignore @@ -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/ + diff --git a/apps/frinx-machine-operators/Chart.yaml b/apps/frinx-machine-operators/Chart.yaml new file mode 100644 index 0000000..081ab3f --- /dev/null +++ b/apps/frinx-machine-operators/Chart.yaml @@ -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 diff --git a/apps/frinx-machine-operators/values.yaml b/apps/frinx-machine-operators/values.yaml new file mode 100644 index 0000000..73b3cf1 --- /dev/null +++ b/apps/frinx-machine-operators/values.yaml @@ -0,0 +1,8 @@ +frinx-machine-operators: + # CRDs + + kube-arangodb: + enabled: true + + cloudnative-pg: + enabled: true diff --git a/apps/frinx-machine/.helmignore b/apps/frinx-machine/.helmignore new file mode 100644 index 0000000..898df48 --- /dev/null +++ b/apps/frinx-machine/.helmignore @@ -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/ + diff --git a/apps/frinx-machine/Chart.yaml b/apps/frinx-machine/Chart.yaml new file mode 100644 index 0000000..d9862b0 --- /dev/null +++ b/apps/frinx-machine/Chart.yaml @@ -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 diff --git a/apps/frinx-machine/local-values.yaml b/apps/frinx-machine/local-values.yaml new file mode 100644 index 0000000..80ec25e --- /dev/null +++ b/apps/frinx-machine/local-values.yaml @@ -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 diff --git a/apps/frinx-machine/values.yaml b/apps/frinx-machine/values.yaml new file mode 100644 index 0000000..78286d2 --- /dev/null +++ b/apps/frinx-machine/values.yaml @@ -0,0 +1,10 @@ +frinx-machine: + uniconfig: + image: + # Use private regitry + repository: "frinxio/uniconfig" + + performance-monitor: + image: + # Use private regitry + repository: "frinxio/performance-monitor" diff --git a/justfile b/justfile new file mode 100644 index 0000000..a41240b --- /dev/null +++ b/justfile @@ -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