Skip to content

Commit

Permalink
feat: add basic support for nix flakes (#21)
Browse files Browse the repository at this point in the history
This adds a reproducible build environment for Argo Workflows. Argo
Workflows can now be run in a few simple steps documented in the
README.md.

Why are there some go files changed here?
This was the outcome of running gofmt on the sources, sources can be
reformatted by running "nix fmt".
Currently this only supports formatting golang and nix files but can be
extended to anything supported via clang-format, prettier and more. See
this for more info: https://numtide.github.io/treefmt/formatters/

The files.go stub was added, this is a bit more deterministic than
copying at build time. This will also make caching easier.

---------

Signed-off-by: Isitha Subasinghe <[email protected]>
  • Loading branch information
isubasinghe authored May 15, 2023
1 parent 327313b commit 924a8bc
Show file tree
Hide file tree
Showing 11 changed files with 3,037 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ sdks/python/client/dist/*
manifests/install.yaml
manifests/namespace-install.yaml
/logs
node_modules
result
.devenv
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ Argo is a [Cloud Native Computing Foundation (CNCF)](https://cncf.io/) hosted pr

![Screenshot](docs/assets/screenshot.png)

## Try Argo using Nix
Nix is a package manager / build tool which focusses on reproducible build environments.
Argo Workflows has some basic support for Nix which is enough to get Argo Workflows up and running with minimal effort.
Here are the steps to follow:
1. Modify the hosts file according to [this](https://argoproj.github.io/argo-workflows/running-locally/), don't worry about the other instructions.
2. Setup a k8s cluster, k3d is the recommended solution here.
3. Install [Nix](https://nixos.org/download.html).
4. Make a directory in the argo workflows folder called ".devenv".
5. Run "nix develop --extra-experimental-features nix-command --extra-experimental-features flakes" (you can add this as a default in your nix.conf file).
6. Run "devenv up".

As I said, this is still fairly barebones at the moment, any feature in the Makefile not mentioned here is excluded at the moment.
In practice this means only a "make start UI=true" equivalent is supported at the moment, there are no LDFlags set in the build, so the UI will show something similar to "0.0.0-unknown"
## Documentation

[View the docs](https://argoproj.github.io/argo-workflows/)
Expand Down
50 changes: 50 additions & 0 deletions conf.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
rec {
staticFiles = true;
version = "latest";
env = {
DEFAULT_REQUEUE_TIME = "1s";
SECURE = "false";
ALWAYS_OFFLOAD_NODE_STATUS = "false";
LOG_LEVEL = "debug";
UPPERIO_DB_DEBUG = "0";
IMAGE_NAMESPACE = "quay.io/pipekitdev";
VERSION = "${version}";
AUTH_MODE = "hybrid";
NAMESPACED = "true";
KUBE_NAMESPACE = "argo";
NAMESPACE = "${env.KUBE_NAMESPACE}";
MANAGED_NAMESPACE = "${env.KUBE_NAMESPACE}"; # same as kubeNamespace
CTRL = "true";
LOGS = "true"; # same as CTRL - not acted upon
UI = "true"; # same as CTRL
API = "true"; # same as CTRL
PLUGINS = "false";
};
controller = {
env = {
CTRL = "${env.CTRL}";
ARGO_EXECUTOR_PLUGINS = "${env.PLUGINS}";
ARGO_REMOVE_PVC_PROTECTION_FINALIZER = "true";
ARGO_PROGRESS_PATCH_TICK_DURATION = "7s";
DEFAULT_REQUEUE_TIME = "${env.DEFAULT_REQUEUE_TIME}";
LEADER_ELECTION_IDENTITY = "local";
ALWAYS_OFFLOAD_NODE_STATUS = "${env.ALWAYS_OFFLOAD_NODE_STATUS}";
OFFLOAD_NODE_STATUS_TTL = "30s";
WORKFLOW_GC_PERIOD = "30s";
UPPERIO_DB_DEBUG = "${env.UPPERIO_DB_DEBUG}";
ARCHIVED_WORKFLOW_GC_PERIOD = "30s";
};
args = "--executor-image ${env.IMAGE_NAMESPACE}/argoexec:${env.VERSION} --namespaced=${env.NAMESPACED} --managed-namespace=${env.MANAGED_NAMESPACE} --loglevel ${env.LOG_LEVEL}";
};

argoServer = {
env = {
UPPERIO_DB_DEBUG = "${env.UPPERIO_DB_DEBUG}";
};
args = "--loglevel ${env.LOG_LEVEL} server --namespaced=${env.NAMESPACED} --auth-mode ${env.AUTH_MODE} --secure=${env.SECURE} --x-frame-options=SAMEORIGIN";
};
ui = {
env = { };
args = "--cwd ui start";
};
}
4 changes: 2 additions & 2 deletions examples/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"path/filepath"
"strings"

"github.com/xeipuuv/gojsonschema"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -75,7 +75,7 @@ func ValidateArgoYamlRecursively(fromPath string, skipFileNames []string) (map[s
errorDescriptions = append(errorDescriptions, fmt.Sprintf("%s in %s", err.Description(), err.Context().String()))
}
}

if !(incorrectError && len(errorDescriptions) == 1) {
failed[path] = errorDescriptions
}
Expand Down
274 changes: 274 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 924a8bc

Please sign in to comment.