### Get Deployment Details in YAML Format (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Retrieves the details of the 'nginx-deployment' from the Kubernetes cluster using `kubectl get` and outputs the result in YAML format. This command is used to verify the changes made by the 'hello-koreo' Workflow, such as the addition of the 'hello' label. ```bash kubectl get deployment nginx-deployment -o yaml ``` -------------------------------- ### Checking the Created Deployment (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Uses `kubectl get deployment` to retrieve the YAML definition of the Deployment created by the Workflow for the `my-app` Workload, allowing verification of its configuration. ```bash kubectl get deployment my-app-deployment -o yaml ``` -------------------------------- ### Get Deployment Status (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Retrieves the YAML configuration and status of the 'nginx-deployment' using kubectl. Used to verify the Workflow's skipped condition. ```bash kubectl get deployment nginx-deployment -o yaml ``` -------------------------------- ### Applying the Koreo Workflow Definition (Bash) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This command applies the `hello-service.k.yaml` file, containing the Koreo Workflow definition, to the Kubernetes cluster using `kubectl`. This registers the workflow with the Koreo controller, enabling it to start watching for matching Deployment events. ```bash kubectl apply -f hello-service.k.yaml ``` -------------------------------- ### Cleaning Up Resources (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Uses `kubectl delete` to remove all Kubernetes resources created during the example, including the Workload instance, Workflow, ResourceFunctions, templates, and the Workload CRD itself. ```bash kubectl delete -f workload.yaml kubectl delete -f hello-workload.k.yaml kubectl delete -f service-factory-v2.k.yaml kubectl delete -f service-template.k.yaml kubectl delete -f deployment-factory.k.yaml kubectl delete -f get-deployment-config.k.yaml kubectl delete -f deployment-template.k.yaml kubectl delete -f workload-crd.yaml ``` -------------------------------- ### Get Service Status (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Retrieves the YAML configuration and status of the 'nginx-svc' Service using kubectl. Used to verify that the Koreo Workflow successfully created the Service. ```bash kubectl get service nginx-svc -o yaml ``` -------------------------------- ### Applying the Koreo Workflow (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the `hello-workload.k.yaml` file to the Kubernetes cluster using `kubectl apply`, registering the Workflow definition with Koreo. ```bash kubectl apply -f hello-workload.k.yaml ``` -------------------------------- ### Deploy Koreo Workflow (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the 'hello-koreo.k.yaml' file to the Kubernetes cluster using `kubectl apply`, creating or updating the Koreo Workflow resource. ```bash kubectl apply -f hello-koreo.k.yaml ``` -------------------------------- ### Validating Workload Status (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Uses `kubectl get workload` to retrieve the YAML definition of the `my-app` Workload instance, allowing verification of the `status.conditions` and `status.state` fields populated by the Koreo Workflow. ```bash kubectl get workload my-app -o yaml ``` -------------------------------- ### Start Local Development Server (Yarn) - Bash Source: https://github.com/koreo-dev/koreo.dev/blob/main/README.md Starts a local development server for the website. It typically includes live reloading for development efficiency. ```bash $ yarn start ``` -------------------------------- ### Deploy Sample Kubernetes Deployment (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the 'deployment.yaml' file to the Kubernetes cluster using `kubectl apply`, creating the sample Nginx Deployment. This action will trigger the 'hello-koreo' Workflow. ```bash kubectl apply -f deployment.yaml ``` -------------------------------- ### Example Kubernetes Deployment Trigger (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/examples/kubernetes/hello-koreo.md This YAML defines a standard Kubernetes Deployment for an Nginx application. This specific Deployment resource serves as the trigger for the 'hello-koreo' Workflow defined in this example. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### Apply Koreo Service ResourceTemplate (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the 'service-template.k.yaml' file to the Kubernetes cluster using the kubectl command-line tool, registering the ResourceTemplate with Koreo. ```shell kubectl apply -f service-template.k.yaml ``` -------------------------------- ### Apply Deployment with Service Label (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Deletes the previous Deployment and applies the 'deployment-with-label.yaml' file. This creates the Deployment that triggers the Koreo Workflow to create a Service. ```bash kubectl delete -f deployment.yaml kubectl apply -f deployment-with-label.yaml ``` -------------------------------- ### Apply Koreo Resource using Kubectl Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Command to apply the 'get-deployment-config.k.yaml' file, which contains the Koreo ValueFunction definition, to the Kubernetes cluster using kubectl. ```shell kubectl apply -f get-deployment-config.k.yaml ``` -------------------------------- ### Cleanup Resources (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Deletes the Deployment and the Koreo Workflow resources ('hello-service.k.yaml', 'service-factory.k.yaml', 'get-service-config.k.yaml') using kubectl to clean up the environment. ```bash kubectl delete -f deployment-with-label.yaml kubectl delete -f hello-service.k.yaml kubectl delete -f service-factory.k.yaml kubectl delete -f get-service-config.k.yaml ``` -------------------------------- ### Applying the Workload Instance (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the `workload.yaml` file to the Kubernetes cluster using `kubectl apply`, creating an instance of the `Workload` CRD which triggers the Koreo Workflow. ```bash kubectl apply -f workload.yaml ``` -------------------------------- ### Install Dependencies (Yarn) - Bash Source: https://github.com/koreo-dev/koreo.dev/blob/main/README.md Installs the project dependencies listed in the package.json file using the Yarn package manager. ```bash $ yarn ``` -------------------------------- ### Installing Koreo Controller with Helm Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/controller-installation.md Adds the Koreo Helm repository, updates the local Helm chart repository cache, and installs the koreo-controller chart. The installation command includes an option to control CRD installation. ```shell helm repo add koreo https://koreo.dev/helm helm repo update helm install koreo-controller koreo/koreo --set=crds.install= ``` -------------------------------- ### Apply Koreo Service ResourceFunction v2 (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the 'service-factory.v2.k.yaml' file to the Kubernetes cluster using the kubectl command-line tool, registering the ResourceFunction and its associated FunctionTest with Koreo. ```shell kubectl apply -f service-factory-v2.k.yaml ``` -------------------------------- ### Applying the Deployment ResourceTemplate Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the defined Koreo ResourceTemplate for the Deployment to the Kubernetes cluster using kubectl, making the base Deployment configuration available for use by Workflows. ```shell kubectl apply -f deployment-template.k.yaml ``` -------------------------------- ### Example Trigger Workload Custom Resource (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/examples/kubernetes/hello-workload.md An example definition of a custom 'Workload' resource, illustrating how a trigger resource might be structured with container image, port, and environment details. ```YAML apiVersion: example.koreo.dev/v1 kind: Workload metadata: name: my-app spec: container: image: nginx:latest port: 80 environment: prod ``` -------------------------------- ### Example Nginx Deployment (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/examples/kubernetes/hello-service.md This YAML defines a standard Kubernetes Deployment resource for an Nginx application. It creates a single replica, uses a selector to manage pods with the label 'app: nginx', and exposes container port 80. This deployment can be used as a backend for a Service created by the 'service-factory'. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: service: nginx-svc spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### Applying the Koreo ResourceFunction (Shell) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This command uses `kubectl` to apply the `service-factory.k.yaml` file to the Kubernetes cluster. This registers the `service-factory` ResourceFunction with Koreo, making it available for use in deployments. ```Shell kubectl apply -f service-factory.k.yaml ``` -------------------------------- ### Apply ResourceFunction to Cluster (Shell) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Provides the command-line instruction to apply the `deployment-factory.k.yaml` file to a Kubernetes cluster using `kubectl apply`. This makes the defined `ResourceFunction` available for use within the cluster. ```Shell kubectl apply -f deployment-factory.k.yaml ``` -------------------------------- ### Delete Sample Deployment (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Deletes the 'deployment.yaml' resource from the cluster using `kubectl delete` as part of the cleanup process. ```bash kubectl delete -f deployment.yaml ``` -------------------------------- ### Apply Koreo ValueFunction to Cluster (Shell) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Uses the kubectl command-line tool to apply the 'get-service-config.k.yaml' file to the Kubernetes cluster, creating or updating the ValueFunction resource. ```shell kubectl apply -f get-service-config.k.yaml ``` -------------------------------- ### Defining a Workload Instance (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines an instance of the custom `Workload` CRD named `my-app`. This resource serves as the trigger for the `hello-workload` Koreo Workflow. ```yaml apiVersion: example.koreo.dev/v1 kind: Workload metadata: name: my-app spec: container: image: nginx:latest port: 80 environment: prod ``` -------------------------------- ### Defining a Deployment ResourceTemplate for Workload Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo ResourceTemplate specifying the base configuration for the Kubernetes Deployment resource associated with the Workload abstraction. This template can be dynamically loaded and customized. ```yaml apiVersion: koreo.dev/v1beta1 kind: ResourceTemplate metadata: name: deployment-template spec: template: apiVersion: apps/v1 kind: Deployment spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### Apply Koreo ResourceFunction to Cluster Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Command to apply the `set-deployment-labels.k.yaml` file containing the ResourceFunction definition to the Kubernetes cluster using `kubectl apply`. This makes the ResourceFunction available for use. ```bash kubectl apply -f set-deployment-labels.k.yaml ``` -------------------------------- ### Test ValueFunction with FunctionTest Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo FunctionTest named 'get-deployment-config-test' to verify the behavior of the 'get-deployment-config' ValueFunction. It includes test cases for both 'dev' and 'prod' environments, asserting the expected replica count in the returned spec. ```yaml apiVersion: koreo.dev/v1beta1 kind: FunctionTest metadata: name: get-deployment-config-test spec: functionRef: kind: ValueFunction name: get-deployment-config inputs: env: dev testCases: - label: dev environment expectReturn: spec: replicas: 1 - label: prod environment inputOverrides: env: prod expectReturn: spec: replicas: 3 ``` -------------------------------- ### Apply Deployment without Service Label (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the 'deployment.yaml' file to the Kubernetes cluster using kubectl. This creates the Nginx Deployment that will be skipped by the Koreo Workflow. ```bash kubectl apply -f deployment.yaml ``` -------------------------------- ### Delete Koreo Workflow (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Deletes the 'hello-koreo.k.yaml' resource from the cluster using `kubectl delete` as part of the cleanup process. ```bash kubectl delete -f hello-koreo.k.yaml ``` -------------------------------- ### Delete Koreo ResourceFunction (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Deletes the 'set-deployment-labels.k.yaml' resource from the cluster using `kubectl delete` as part of the cleanup process. ```bash kubectl delete -f set-deployment-labels.k.yaml ``` -------------------------------- ### Define ValueFunction for Deployment Config Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo ValueFunction named 'get-deployment-config' that determines the number of replicas for a Deployment based on an 'env' input variable. It sets replicas to 3 for 'prod' and 1 otherwise. ```yaml apiVersion: koreo.dev/v1beta1 kind: ValueFunction metadata: name: get-deployment-config spec: locals: replicas: | =inputs.env == "prod" ? 3 : 1 return: spec: replicas: =locals.replicas ``` -------------------------------- ### Delete Koreo ValueFunction (kubectl) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Deletes the 'get-labels.k.yaml' resource from the cluster using `kubectl delete` as part of the cleanup process. ```bash kubectl delete -f get-labels.k.yaml ``` -------------------------------- ### Define Nginx Deployment with Service Label (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Kubernetes Deployment for Nginx including the 'service: nginx-svc' label. This label triggers the Koreo Workflow to create a corresponding Service. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: service: nginx-svc spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### Define Koreo Service ResourceTemplate (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo ResourceTemplate named 'service-template' that provides the base configuration for a Kubernetes Service resource, specifying its API version, kind, selector, ports, and type. ```yaml apiVersion: koreo.dev/v1beta1 kind: ResourceTemplate metadata: name: service-template spec: template: apiVersion: v1 kind: Service spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 type: ClusterIP ``` -------------------------------- ### Define Nginx Deployment without Service Label (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a standard Kubernetes Deployment for Nginx. This version lacks the 'service' label required by the Koreo Workflow, causing the Workflow to be skipped. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### Configuring Koreo Language Server in coc-settings.json (Coc) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/tooling-installation.md JSON configuration for Coc to define the 'koreo-ls' language server, specifying the command, file types it handles, root directory pattern, and semantic tokens settings. ```JSON "languageserver": { "koreo-ls": { "command": "koreo-ls", "filetypes": ["koreo"], "root_dir": ["*.git"], "settings": { "semanticTokens.filetypes": ["*"] } } } ``` -------------------------------- ### Accessing Koreo Controller UI via Port Forwarding Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/controller-installation.md Forwards local port 8080 to the koreo-controller-ui service's port 8080, enabling access to the user interface from the local machine. ```shell kubectl port-forward svc/koreo-controller-ui 8080:8080 ``` -------------------------------- ### Applying the Workload CRD Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Applies the defined Workload Custom Resource Definition (CRD) to the Kubernetes cluster using kubectl, making the 'Workload' kind available as an API resource. ```shell kubectl apply -f workload-crd.yaml ``` -------------------------------- ### List Functions in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Examples demonstrating built-in list functions in Koreo Expressions (CEL) for operations like getting size, checking membership, and mapping elements. ```CEL [1, 2, 3].size() ``` ```CEL [1, 2, 3].contains(2) ``` ```CEL [1, 2, 3].map(x, x * 2) ``` -------------------------------- ### Define Sample Kubernetes Deployment (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This YAML defines a standard Kubernetes Deployment named 'nginx-deployment'. It specifies a single replica, selector, and template metadata including the 'app: nginx' label. This Deployment serves as the parent resource that will trigger the 'hello-koreo' Workflow when applied to the cluster. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### Defining ResourceTemplate 2 (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/resource-template.md Defines a Koreo ResourceTemplate named 'docs-template-two.v1'. This template provides a base TestDummy resource with 'value: two' and a structure list, intended as an alternative base for the ResourceFunction. ```yaml apiVersion: koreo.dev/v1beta1 kind: ResourceTemplate metadata: name: docs-template-two.v1 namespace: koreo-demo spec: template: apiVersion: koreo.dev/v1beta1 kind: TestDummy metadata: labels: docs.koreo.dev/example: template-label annotations: docs.koreo.dev/example: template-two spec: value: two structure: - name: doc - name: examples ``` -------------------------------- ### Implementing Dynamic ResourceFunction (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/resource-template.md Defines a Koreo ResourceFunction named 'docs-template-function.v1'. It dynamically selects a ResourceTemplate based on the 'inputs.template' value and applies overlays to merge input metadata and set 'spec.value' and 'spec.addedProperty'. ```yaml apiVersion: koreo.dev/v1beta1 kind: ResourceFunction metadata: name: docs-template-function.v1 namespace: koreo-demo spec: locals: template_name: ="docs-template-" + inputs.template + ".v1" apiConfig: apiVersion: koreo.dev/v1beta1 kind: TestDummy name: =inputs.metadata.name + "-template-docs" namespace: =inputs.metadata.namespace resourceTemplateRef: name: =locals.template_name overlays: - overlay: metadata: =resource.metadata.overlay(inputs.metadata) spec: value: =inputs.value addedProperty: =inputs.value * 17 ``` -------------------------------- ### Setting Koreo Filetype and Indentation in Vimscript (Coc) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/tooling-installation.md Vimscript configuration to associate Koreo file extensions (.k, .koreo, .k.yaml, .k.yml) with the 'koreo' filetype and set indentation options (2 spaces, expandtab). ```Vimscript augroup koreo_filetypes autocmd! autocmd BufRead,BufNewFile *.k,*.koreo,*.k.yaml,*.k.yml setfiletype koreo augroup END augroup koreo_filetype_settings autocmd! autocmd FileType koreo setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2 autoindent smartindent augroup END ``` -------------------------------- ### Defining ResourceTemplate 1 (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/resource-template.md Defines a Koreo ResourceTemplate named 'docs-template-one.v1'. This template provides a base TestDummy resource with 'value: one' and a nested list '[1, 2]', intended to be used by a ResourceFunction. ```yaml apiVersion: koreo.dev/v1beta1 kind: ResourceTemplate metadata: # The template will be looked up by its name. name: docs-template-one.v1 namespace: koreo-demo spec: # Template contains the static resource that will be used as the base. # apiVersion and kind are required. The template is the actual body, or some # portion thereof, which you'd like to set static values for. template: apiVersion: koreo.dev/v1beta1 kind: TestDummy metadata: labels: docs.koreo.dev/example: template-label spec: value: one nested: - 1 - 2 ``` -------------------------------- ### Installing Koreo Developer Tooling with pip (Shell) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/tooling-installation.md Command to install the Koreo Developer Tooling package, including the language server and CLI, using pip. Requires Python 3.13 or later. ```Shell pip install koreo ``` -------------------------------- ### Uninstalling Koreo Controller with Helm Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/controller-installation.md Uninstalls the koreo-controller release previously installed using Helm. ```shell helm uninstall koreo-controller ``` -------------------------------- ### CEL Built-in Function Syntax Examples Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Examples demonstrating the basic syntax for calling built-in CEL functions such as Base64 encoding/decoding and string replacement. ```CEL b64encode(value) ``` ```CEL b64decode(value) ``` ```CEL replace(string, value, value) ``` -------------------------------- ### Installing Koreo CLI with pip Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/koreo-cli.md Installs the Koreo CLI and language server using the pip package manager. Requires Python 3.13 or later. ```Shell pip install koreo ``` -------------------------------- ### Test Deployment ResourceFunction (Koreo YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo `FunctionTest` named `deployment-factory-test` to validate the `deployment-factory` `ResourceFunction`. It provides default inputs and includes multiple test cases covering happy paths with different environments (`dev`, `prod`) and cases expecting specific outcomes like `skip` or `permFail` based on input validation rules defined in the `ResourceFunction`. ```YAML apiVersion: koreo.dev/v1beta1 kind: FunctionTest metadata: name: deployment-factory-test spec: functionRef: kind: ResourceFunction name: deployment-factory inputs: name: test namespace: default image: test-api:latest port: 3000 env: dev testCases: - label: happy path (dev) expectResource: apiVersion: apps/v1 kind: Deployment metadata: name: test-deployment namespace: default labels: env: dev workload: test spec: replicas: 1 selector: matchLabels: app: test template: metadata: labels: app: test spec: containers: - name: test image: test-api:latest ports: - containerPort: 3000 - label: happy path (prod) variant: true inputOverrides: env: prod expectResource: apiVersion: apps/v1 kind: Deployment metadata: name: test-deployment namespace: default labels: env: prod workload: test spec: replicas: 3 selector: matchLabels: app: test template: metadata: labels: app: test spec: containers: - name: test image: test-api:latest ports: - containerPort: 3000 - label: empty deployment name variant: true inputOverrides: name: "" expectOutcome: skip: message: "Invalid deployment name" - label: invalid deployment name variant: true inputOverrides: name: "-invalid-name" expectOutcome: skip: message: "Invalid deployment name" - label: invalid environment variant: true inputOverrides: env: preprod expectOutcome: permFail: message: "Invalid environment" ``` -------------------------------- ### Example TriggerDummy Resource (Koreo/YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/examples/kubernetes/service-account.md Provides an example instance of the `TriggerDummy` custom resource. It defines a `TriggerDummy` named `test-dummy` that references a Kubernetes Secret resource. ```yaml apiVersion: koreo.dev/v1beta1 kind: TriggerDummy metadata: name: test-dummy namespace: koreo-demo spec: name: test-dummy resources: - apiGroup: v1 kind: Secret name: contact-list-api-key ``` -------------------------------- ### Example AWS Environment Custom Resource (Koreo) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/examples/aws/vpc.md Provides an example definition of a custom resource `AwsEnvironment` used to trigger the creation of AWS infrastructure components, specifically demonstrating the configuration for a public subnet. ```yaml apiVersion: acme.example.com/v1beta1 kind: AwsEnvironment metadata: name: test-aws-environment labels: acme.example.com/business-unit: acme-bu acme.example.com/product-line: acme-widgets acme.example.com/domain: acme-domain spec: vpc: publicSubnets: - cidrBlock: 10.0.128.0/20 availabilityZone: us-east-1a name: a-public ``` -------------------------------- ### Defining Koreo Workflow to Create Service from Deployment (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This YAML defines a Koreo Workflow named `hello-service`. It triggers on `apps/v1` Deployments. The workflow has two steps: `get_service_config` (a ValueFunction) which extracts configuration from the parent Deployment's metadata and spec, skipping if no labels exist, and `create_service` (a ResourceFunction) which uses the extracted config to create a Service resource. ```yaml apiVersion: koreo.dev/v1beta1 kind: Workflow metadata: name: hello-service spec: crdRef: apiGroup: apps version: v1 kind: Deployment steps: - label: get_service_config skipIf: =!has(parent.metadata.labels) ref: kind: ValueFunction name: get-service-config inputs: metadata: =parent.metadata spec: =parent.spec - label: create_service ref: kind: ResourceFunction name: service-factory inputs: name: =steps.get_service_config.name namespace: =steps.get_service_config.namespace selector: =steps.get_service_config.selector targetPort: =steps.get_service_config.targetPort ``` -------------------------------- ### Define Koreo Workflow for Deployment Labeling (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This YAML defines a Koreo Workflow named 'hello-koreo'. It targets Kubernetes Deployments (`apps/v1`, `Deployment`) as the parent resource. The workflow consists of two steps: 'get_labels' using a ValueFunction to retrieve labels and 'set_labels' using a ResourceFunction to update the Deployment with new labels, referencing the parent resource's name/namespace and the output of the previous step. ```yaml apiVersion: koreo.dev/v1beta1 kind: Workflow metadata: name: hello-koreo spec: crdRef: apiGroup: apps version: v1 kind: Deployment steps: - label: get_labels ref: kind: ValueFunction name: get-labels inputs: name: =parent.metadata.name - label: set_labels ref: kind: ResourceFunction name: set-deployment-labels inputs: name: =parent.metadata.name namespace: =parent.metadata.namespace labels: =steps.get_labels.labels ``` -------------------------------- ### Example Lambda Workload Definition (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/examples/aws/lambda-workload.md Provides an example of a custom resource definition (LambdaWorkload) used to specify the configuration for deploying a Lambda-based application. It includes parameters for the container image, the required role, and the bucket name, with an option to generate a unique suffix for the bucket. ```yaml apiVersion: example.koreo.dev/v1 kind: LambdaWorkload metadata: name: hello-lambda-workload namespace: koreo-examples spec: image: my-lambda-image:0.0.2 role: writer bucketName: my-unique-bucket-name generateBucketSuffix: true ``` -------------------------------- ### Example koreo.dev/managed-resources Annotation JSON Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/workflow.md This JSON object provides a concrete example of the `koreo.dev/managed-resources` annotation value. It illustrates how different workflow step types (ValueFunctions, ResourceFunctions, forEach loops, sub-Workflows) are represented, showing null values, Kubernetes resource objects, arrays, and nested managed resources objects. ```json { "workflow": "aws-workload-workflow", "resources": { "config": null, "metadata": null, "resource_tags": null, "environment_metadata": { "apiVersion": "aws.konfigurate.realkinetic.com/v1beta1", "kind": "AwsEnvironment", "plural": "awsenvironments", "name": "dev", "readonly": true, "namespace": "realkinetic-dev", "resourceFunction": "aws-environment" }, "resources": [ { "apiVersion": "s3.services.k8s.aws/v1alpha1", "kind": "Bucket", "plural": "buckets", "name": "test-1312e8", "readonly": false, "namespace": "realkinetic-dev", "resourceFunction": "aws-s3-bucket-factory" } ], "runtime": { "workflow": "lambda-workflow", "resources": { "config": null, "lambda_policy": { "apiVersion": "iam.services.k8s.aws/v1alpha1", "kind": "Policy", "plural": "policies", "name": "test-lambda", "readonly": false, "namespace": "realkinetic-dev", "resourceFunction": "lambda-policy" }, "lambda_role": { "apiVersion": "iam.services.k8s.aws/v1alpha1", "kind": "Role", "plural": "roles", "name": "test-lambda", "readonly": false, "namespace": "realkinetic-dev", "resourceFunction": "lambda-role" }, "lambda_resource": { "apiVersion": "lambda.services.k8s.aws/v1alpha1", "kind": "Function", "plural": "functions", "name": "test", "readonly": false, "namespace": "realkinetic-dev", "resourceFunction": "lambda-resource" } } }, "triggers": null } } ``` -------------------------------- ### Defining a Koreo ResourceFunction for Service Creation (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This Koreo ResourceFunction defines how to create a Kubernetes Service. It includes preconditions to validate the input name and selector, uses local variables for defining ports, and specifies the target Service resource configuration inline using `apiConfig` and `resource`. ```YAML apiVersion: koreo.dev/v1beta1 kind: ResourceFunction metadata: name: service-factory spec: preconditions: - assert: | =inputs.name.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") skip: message: "Invalid service name" - assert: =inputs.selector.size() > 0 skip: message: "No selector" locals: ports: - protocol: TCP port: 80 targetPort: =inputs.targetPort apiConfig: apiVersion: v1 kind: Service name: =inputs.name namespace: =inputs.namespace resource: spec: selector: =inputs.selector ports: =locals.ports type: ClusterIP ``` -------------------------------- ### Get Map Values (CEL) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Returns a list containing all values present in the map. ```CEL {"a": 1, "b": 2}.values() ``` -------------------------------- ### Get Map Keys (CEL) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Returns a list containing all keys present in the map. ```CEL {"a": 1, "b": 2}.keys() ``` -------------------------------- ### Define Deployment ResourceFunction (Koreo YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo `ResourceFunction` named `deployment-factory`. It includes preconditions to validate input parameters like `name` and `env`, specifies the target Kubernetes API resource (`apps/v1`, `Deployment`), references a base `resourceTemplateRef` (`deployment-template`), and applies configuration layers using inline `overlays` and an `overlayRef` to customize the Deployment based on inputs. ```YAML apiVersion: koreo.dev/v1beta1 kind: ResourceFunction metadata: name: deployment-factory spec: preconditions: - assert: | =inputs.name.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") skip: message: "Invalid deployment name" - assert: | =inputs.env == "dev" || inputs.env == "staging" || inputs.env == "prod" permFail: message: "Invalid environment" apiConfig: apiVersion: apps/v1 kind: Deployment name: =inputs.name + "-deployment" namespace: =inputs.namespace resourceTemplateRef: name: deployment-template overlays: - overlay: metadata: labels: env: =inputs.env workload: =inputs.name spec: selector: matchLabels: app: =inputs.name template: metadata: labels: app: =inputs.name spec: containers: - name: =inputs.name image: =inputs.image ports: - containerPort: =inputs.port - overlayRef: kind: ValueFunction name: get-deployment-config inputs: env: =inputs.env ``` -------------------------------- ### Get Map Size (CEL) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Returns the total number of key-value pairs within the map. ```CEL {"a": 1, "b": 2}.size() ``` -------------------------------- ### Representing Null Value in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Example of a null literal in Koreo Expressions (CEL). Represents the absence of a value. ```CEL null ``` -------------------------------- ### Comparison Operators in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Examples demonstrating the use of comparison operators (==, !=, <, <=, >, >=) in Koreo Expressions (CEL) for comparing values. ```CEL a == b ``` ```CEL a != b ``` ```CEL a < b ``` ```CEL a <= b ``` ```CEL a > b ``` ```CEL a >= b ``` -------------------------------- ### Arithmetic Operators in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Examples demonstrating the use of basic arithmetic operators (+, -, *, /, %) in Koreo Expressions (CEL) for performing calculations. ```CEL a + b ``` ```CEL a - b ``` ```CEL a * b ``` ```CEL a / b ``` ```CEL a % b ``` -------------------------------- ### Representing Bytes Value in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Example of a binary data literal in Koreo Expressions (CEL). Denoted by a 'b' prefix. ```CEL b"data" ``` -------------------------------- ### Defining a Koreo Workflow (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo Workflow resource named `hello-workload`. It triggers on `Workload` CRD instances and includes steps to create a Kubernetes Deployment and Service using ResourceFunctions, setting conditions and state on the parent resource. ```yaml apiVersion: koreo.dev/v1beta1 kind: Workflow metadata: name: hello-workload spec: crdRef: apiGroup: example.koreo.dev version: v1 kind: Workload steps: - label: create_deployment ref: kind: ResourceFunction name: deployment-factory inputs: name: =parent.metadata.name namespace: =parent.metadata.namespace env: =parent.spec.environment image: =parent.spec.container.image port: =parent.spec.container.port condition: type: Deployment name: Workload Deployment - label: create_service ref: kind: ResourceFunction name: service-factory.v2 inputs: name: =parent.metadata.name namespace: =parent.metadata.namespace env: =parent.spec.environment targetPort: =parent.spec.container.port condition: type: Service name: Workload Service state: service: clusterIP: =value.clusterIP ``` -------------------------------- ### Logical Operators in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Examples demonstrating the use of logical operators (&&, ||, !) in Koreo Expressions (CEL) for evaluating boolean conditions. ```CEL a && b ``` ```CEL a || b ``` ```CEL !a ``` -------------------------------- ### Representing Map in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Example of a map literal in Koreo Expressions (CEL). Maps are key-value dictionaries enclosed in curly braces. ```CEL {"key": "value"} ``` -------------------------------- ### Representing Double Value in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Example of a 64-bit floating-point number literal in Koreo Expressions (CEL). Used for decimal numbers. ```CEL 3.14 ``` -------------------------------- ### Representing Integer Value in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Example of a 64-bit signed integer literal in Koreo Expressions (CEL). Used for whole numbers. ```CEL 42 ``` -------------------------------- ### Test Koreo ResourceFunction for Deployment Labels Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Provides a FunctionTest definition for the `set-deployment-labels` ResourceFunction. It specifies inputs, simulates the current state of the target Deployment using `currentResource`, and defines a test case (`testCases`) to assert that the expected labels are present in the patched resource using `expectResource`. ```yaml apiVersion: koreo.dev/v1beta1 kind: FunctionTest metadata: name: set-deployment-labels-test spec: functionRef: kind: ResourceFunction name: set-deployment-labels inputs: name: test-deployment namespace: default labels: foo: bar baz: qux currentResource: apiVersion: apps/v1 kind: Deployment metadata: name: test-deployment namespace: default testCases: - label: Sets labels expectResource: apiVersion: apps/v1 kind: Deployment metadata: name: test-deployment namespace: default labels: foo: bar baz: qux ``` -------------------------------- ### Apply Koreo Resources with kubectl (Shell) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Uses the `kubectl apply` command to apply the defined Koreo resources (specifically the `get-labels.k.yaml` file) to the Kubernetes cluster. This makes the ValueFunction and FunctionTest available within the cluster environment. ```shell kubectl apply -f get-labels.k.yaml ``` -------------------------------- ### Testing the Koreo Service ResourceFunction (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md This Koreo FunctionTest defines test cases for the `service-factory` ResourceFunction. It includes a happy path test case verifying the expected Service output and multiple variant test cases to validate the precondition checks for invalid or missing inputs. ```YAML apiVersion: koreo.dev/v1beta1 kind: FunctionTest metadata: name: service-factory-test spec: functionRef: kind: ResourceFunction name: service-factory inputs: name: hello-koreo namespace: default selector: app: nginx targetPort: 80 testCases: - label: happy path expectResource: apiVersion: v1 kind: Service metadata: name: hello-koreo namespace: default spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 type: ClusterIP - label: empty service name variant: true inputOverrides: name: "" expectOutcome: skip: message: "Invalid service name" - label: invalid service name variant: true inputOverrides: name: "-invalid-name" expectOutcome: skip: message: "Invalid service name" - label: no selector variant: true inputOverrides: selector: expectOutcome: skip: message: "No selector" ``` -------------------------------- ### Test Koreo Service ResourceFunction v2 (YAML) Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/getting-started/quick-start.md Defines a Koreo FunctionTest for the 'service-factory.v2' ResourceFunction. It includes test cases to validate the generated Service resource for a happy path, test the function's return value by simulating resource state updates using 'overlayResource', and test the precondition skips for invalid or empty service names. ```yaml apiVersion: koreo.dev/v1beta1 kind: FunctionTest metadata: name: service-factory.v2-test spec: functionRef: kind: ResourceFunction name: service-factory.v2 inputs: name: hello-koreo namespace: default env: dev targetPort: 3000 testCases: - label: happy path expectResource: apiVersion: v1 kind: Service metadata: name: hello-koreo-svc namespace: default labels: env: dev workload: hello-koreo spec: selector: app: hello-koreo ports: - protocol: TCP port: 80 targetPort: 3000 type: ClusterIP - label: happy path return value overlayResource: spec: clusterIP: 34.118.232.84 expectReturn: clusterIP: 34.118.232.84 - label: empty service name variant: true inputOverrides: name: "" expectOutcome: skip: message: "Invalid service name" - label: invalid service name variant: true inputOverrides: name: "-invalid-name" expectOutcome: skip: message: "Invalid service name" ``` -------------------------------- ### Representing List in CEL Source: https://github.com/koreo-dev/koreo.dev/blob/main/docs/expressions.md Example of a list literal in Koreo Expressions (CEL). Lists are ordered collections of elements enclosed in square brackets. ```CEL [1, 2, 3] ```