CLI tool for deploying Cortex assets in an automated CI/CD pipeline. Cortex assets need to be snapshot & export using cortex-cli. This will generate Cortex assets export and manifest file to drive deployment.
- Download SSL cert from Cortex DCI to add as trusted:
fabric fetchCert <Cortex DCI URL> </path/to/save/cert.pem> - Add downloaded cert as trusted one: Set environment variable
SSL_CERTS_DIRto directory where cert is downloaded
- cortex (follow instruction on link to install CLI)
- This tool fabric. Download OS specific binary and add to system path or bin directory for system wide global access (or execute binary with full path)
- See usage examples of both the tools above in script
- Authoring: Create Skills, Connections, Datasets and compose Agent(s) using Cortex Studio and CLI
- Export:
- Snapshot & export agent(s): see
export_agentsin usage example script - Execute
export_agentsin Git repo (of Cortex Skills/Actions) checkout and push exported assets (.fabricdirectory with snapshots andfabric.yamlmanifest file to drive deployment)
- Snapshot & export agent(s): see
- Deploy (GitOps)
- Execute
fabric <Git Repo checkout directory>
- Execute
1 & 2 are using
cortex-cliand 3 is usingfabric
See usage example script for setup, setup_project and export_agents
-
Git repo checkout folder with manifest file fabric.yaml and .fabric folder containing Cortex artifacts at top level directory (as setup in previous section)
-
This implementation depends and
Dockerdaemon running on host machine -
Environment variables For Docker image builds (for Cortex Action)
DOCKER_PREGISTRY_PREFIXDocker image namespace. This will be same for all actions in theGit repo.DOCKER_PREGISTRY_URLDocker private registry URLDOCKER_BUILD_CONTEXTAllowed valuesDOCKERFILE_CURRENT_DIR | DOCKERFILE_PARENT_DIR | REPO_ROOT | </path/relative/to/repo>. This config directs which directory to copy (build context) in Docker image building
For Cortex DCI v5
CORTEX_URLCortex DCI API base URLCORTEX_ACCOUNTCORTEX_TOKENCORTEX_USERCORTEX_PASSWORD
Either token or user+password is required
For Cortex DCI v6
CORTEX_ACCESS_TOKEN_PATHPath ofcortex-token.jsondownloaded from Cortex consoleSettingsCORTEX_PROJECT
Set environment variables and run fabric <Git repo directory> to deploy all Cortex assets exported in previous Authoring step. This command will:
-
Scan Git repo directory recursively for Dockerfile(s)
-
Build & tag Docker images with configured build context, namespace and git version (commit hash pointing to HEAD)
-
Push built Docker image to configured Docker registry
-
Parse manifest
fabric.yamlto get Cortex artifacts to be deployed -
Deploy agent, skill, action, datasets and agent snapshots. connection and variables will be in next iteration with Vault integration, because we need to handle secrets
-
Action deployment need to substitute image with newly build (namespace, registry url, version change etc). for substitution action name in
skill.yamlandaction deploymust be Docker image name.
The action name and the Docker image name a to be directory name of Dockerfile. This is the only convention need to be followed in Git repo.
See usage in generated doc
When trying to deploy to Cortex, we need to login to the private registry using the following command. Do this only if the Docker private registry is managed by DCI. For external Docker registry do docker login on host machine.
fabric dockerAuth $DOCKER_PREGISTRY_URL 'cli' $CORTEX_TOKEN
For end-to-end deployment use fabric command as
fabric <Git repo directory>
Each step of end-to-end deployment can be executed individually for finer control over deployment, as described below:
- Build & push Cortex Actions Docker images If user is managing Docker images in the registries manually, then use this command to build and push. This can be useful in scenarios like, same Docker registry is shared with all DCIs (dev, stage, prod) or Docker images are replicated to all DCIs using tools like skopeo
fabric build <Git repo directory>
- Deploy Cortex resources as per manifest
fabric deploy <Git repo directory>
Note: executing
buildanddeployseparately will point to Docker registry from which Cortex assets were snapshot & exported.
- Install (Go >1.15](https://golang.org/dl/)
- Checkout this repo and open in IDE
- Install dependencies (IDE will do automatically from go.mod)
- This CLI app is built using Cobra
- Using
Makefileto manage project.make clean build docgenwill clean & build binaries for OSX (darwin), Linux & Windows. Also generate cmd usage document in markdown format
- Support creating Cortex Connections. Need to handle secret credentials
- Fetch Cortex credentials from Vault, instead of environment variables
