Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Yoke
https://github.com/yokecd/docs
Admin
Yoke is a project.
Tokens:
30,434
Snippets:
193
Trust Score:
5.4
Update:
8 months ago
Context
Chat
Benchmark
93
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Write and Print Kubernetes Deployment (Go) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/basics.mdx This Go program defines a Kubernetes Deployment resource as a string and prints it to standard output. It serves as a basic example of how to programmatically define resources for Yoke. No external dependencies are required beyond the Go standard library. ```go // example.go package main import "fmt" var deployment = ` apiVersion: apps/v1 kind: Deployment metadata: name: example-app labels: app: example-app spec: replicas: 2 selector: matchLabels: app: example-app template: metadata: labels: app: example-app spec: containers: - name: example-app-container image: nginx:latest # Replace with your actual container image ports: - containerPort: 80 ` func main() { fmt.Println(deployment) } ``` -------------------------------- ### Deploy Wasm Flight with Yoke Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/basics.mdx This command deploys a compiled WebAssembly module as a Yoke Flight. It takes the release name (`example`) and the path to the Wasm binary (`./example.wasm`) as arguments. Yoke then interprets the Wasm module to manage the Kubernetes resources. ```bash yoke takeoff example ./example.wasm ``` -------------------------------- ### Compile Go to Wasm Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/basics.mdx This command compiles a Go program into a WebAssembly binary. It sets the target operating system to `wasip1` and the architecture to `wasm`, producing an executable file named `example.wasm`. This is a prerequisite for deploying Wasm modules with Yoke. ```bash GOOS=wasip1 GOARCH=wasm go build -o example.wasm ./example.go ``` -------------------------------- ### Deploy YAML file with Yoke Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/basics.mdx This command demonstrates deploying Kubernetes resources directly from a YAML file using Yoke. It's equivalent to the Wasm deployment but bypasses the compilation step, serving as a baseline for comparison. The `example.yaml` file should contain the Kubernetes resource definitions. ```bash yoke takeoff example < example.yaml ``` -------------------------------- ### Basic Deployment Configuration in Go Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/configuration.mdx A simplified Go example demonstrating how to create a Kubernetes Deployment object and set its replica count. This code snippet is a starting point for understanding Yoke's configuration capabilities and relies on Kubernetes API packages. ```go // example.go package main import ( "encoding/json" "os" appsv1 "k8s.io/api/apps/v1" "k8s.io/utils/ptr" ) // This example is not fully runnable // As the deployment is missing too many properties to be useful. // We will only be interested in learning to configure the Replicas value. func main() { deployment := &appsv1.Deployment{ Spec: appsv1.DeploymentSpec{ Replicas: ptr.To[int32](2), }, } json.NewEncoder(os.Stdout).Encode(deployment) } ``` -------------------------------- ### Install Yoke CLI Source: https://context7.com/yokecd/docs/llms.txt Instructions for installing the Yoke command-line interface using various methods including Go, direct download, Homebrew, and Scoop. Ensure Go is installed for the source installation method. ```bash # From source using Go go install github.com/yokecd/yoke/cmd/yoke@latest # Download pre-built binary (macOS ARM64 example) curl -L -o - 'https://github.com/yokecd/yoke/releases/download/latest/yoke_latest_darwin_arm64.gz' | gunzip > /usr/local/bin/yoke && \ chmod +x /usr/local/bin/yoke # Using Homebrew brew install yoke # Using Scoop (Windows) scoop install yoke ``` -------------------------------- ### YokeCD Installer Values Configuration Source: https://context7.com/yokecd/docs/llms.txt Example values.yaml file for the yokecd-installer, configuring image, version, secrets, and resource settings for YokeCD and ArgoCD. ```yaml # values.yaml for yokecd-installer image: ghcr.io/yokecd/yokecd version: 0.15.0 dockerAuthSecretName: my-secret yokecd: resources: {} yokecdServer: cacheFS: /tmp resources: {} argocd: {} ``` -------------------------------- ### Create Kubernetes Deployment and Service using Go Types Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/basics.mdx This Go program defines functions to create Kubernetes Deployment and Service resources using strongly typed configurations. It utilizes the 'k8s.io/api' packages for resource definitions and 'github.com/yokecd/yoke/pkg/flight' for integration with the yoke deployment tool. The program outputs these resources as a JSON-encoded slice of flight.Resource. ```go package main import ( "encoding/json" "fmt" "os" "github.com/yokecd/yoke/pkg/flight" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" ) func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func run() error { var ( release = flight.Release() // the first argument passed to yoke takeoff; ie: yoke takeoff RELEASE foo namespace = flight.Namespace() // the value of the flag namespace during takeoff; ie: yoke takeoff -namespace NAMESPACE ... labels = map[string]string{"app": release} ) resources := []flight.Resource{ CreateDeployment(DeploymentConfig{ Name: release, Namespace: namespace, Labels: labels, Replicas: 2, }), CreateService(ServiceConfig{ Name: release, Namespace: namespace, Labels: labels, Port: 80, TargetPort: 80, }), } return json.NewEncoder(os.Stdout).Encode(resources) } type DeploymentConfig struct { Name string Namespace string Labels map[string]string Replicas int32 } func CreateDeployment(cfg DeploymentConfig) *appsv1.Deployment { return &appsv1.Deployment{ TypeMeta: metav1.TypeMeta{ APIVersion: appsv1.SchemeGroupVersion.Identifier(), Kind: "Deployment", }, ObjectMeta: metav1.ObjectMeta{ Name: cfg.Name, Namespace: cfg.Namespace, }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: cfg.Labels, }, Replicas: ptr.To(cfg.Replicas), Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: cfg.Labels, }, Spec: corev1.PodSpec{ Containers: []corev1.Container{ { Name: cfg.Name, Image: "alpine:latest", Command: []string{"watch", "echo", "hello world"}, }, }, }, }, }, } } type ServiceConfig struct { Name string Namespace string Labels map[string]string Port int32 TargetPort int32 } func CreateService(cfg ServiceConfig) *corev1.Service { return &corev1.Service{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", Kind: "Service", }, ObjectMeta: metav1.ObjectMeta{ Name: cfg.Name, Namespace: cfg.Namespace, }, Spec: corev1.ServiceSpec{ Type: corev1.ServiceTypeClusterIP, Selector: cfg.Labels, Ports: []corev1.ServicePort{ { Protocol: corev1.ProtocolTCP, Port: cfg.Port, TargetPort: intstr.FromInt32(cfg.TargetPort), }, }, }, } } ``` -------------------------------- ### Go Example for k8s_lookup Function Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Concepts/cluster-access.mdx A Go program demonstrating the usage of the k8s_lookup function provided by the Yoke Go package. This example shows how to wrap the low-level WASI export in a user-friendly API for accessing Kubernetes resources. ```go package main import ( "encoding/json" "fmt" "log" k8s "github.com/yokecd/yoke/pkg/flight/wasi/k8s" ) func main() { // Example: Lookup a Deployment in the 'default' namespace. // The format is "<namespace>/<groupkind>:<name>" // If namespace or name is omitted, it defaults to "*" resourceToLookup := "default/Deployment:my-deployment" resourceJSON, err := k8s.Lookup(resourceToLookup) if err != nil { log.Fatalf("Failed to lookup resource %s: %v", resourceToLookup, err) } // The result is a JSON string. You can parse it as needed. fmt.Printf("Successfully looked up resource: %s\n", resourceToLookup) fmt.Println("Resource JSON:") var prettyJSON bytes.Buffer if err := json.Indent(&prettyJSON, []byte(resourceJSON), "", " "); err != nil { log.Fatalf("Failed to pretty print JSON: %v", err) } fmt.Println(prettyJSON.String()) // Example: Lookup all ConfigMaps in the 'infra' namespace. resourceToLookupAll := "infra/Configmap" resourceJSONAll, err := k8s.Lookup(resourceToLookupAll) if err != nil { log.Fatalf("Failed to lookup resources %s: %v", resourceToLookupAll, err) } fmt.Printf("Successfully looked up resources: %s\n", resourceToLookupAll) fmt.Println("Resources JSON:") var prettyJSONAll bytes.Buffer if err := json.Indent(&prettyJSONAll, []byte(resourceJSONAll), "", " "); err != nil { log.Fatalf("Failed to pretty print JSON: %v", err) } fmt.Println(prettyJSONAll.String()) } ``` -------------------------------- ### Install Yoke CLI via Pre-built Binary Source: https://github.com/yokecd/docs/blob/main/src/content/docs/index.mdx Downloads and installs a pre-built Yoke CLI binary. This is a convenient way to install Yoke without needing to compile from source. Remember to substitute the tag and architecture to match your system. ```bash # Substitute tag and architecture to fit your needs. curl -L -o - 'https://github.com/yokecd/yoke/releases/download/latest/yoke_latest_darwin_arm64.gz' | gunzip > /usr/local/bin/yoke && \ chmod +x /usr/local/bin/yoke ``` -------------------------------- ### Install Air Traffic Controller (ATC) (Bash) Source: https://context7.com/yokecd/docs/llms.txt These commands demonstrate how to install the Air Traffic Controller (ATC), which manages Flights as native Kubernetes custom resources. It covers basic installation, installation with a local Kind cluster, and installation with private registry authentication. ```bash # Install ATC NAMESPACE=atc VERSION=latest RELEASE=atc yoke takeoff --create-namespace --namespace $NAMESPACE $RELEASE oci://ghcr.io/yokecd/atc-installer:$VERSION # Create a local cluster and install ATC kind delete cluster && kind create cluster yoke takeoff -wait 30s --create-namespace --namespace atc atc oci://ghcr.io/yokecd/atc-installer:latest # Install with private registry authentication AUTH=$(echo -n ${USERNAME}:${PASSWORD} | base64) cat > config.json <<EOF { "auths": { "$REGISTRY": { "auth": "$AUTH" } } } EOF kubectl create secret docker-registry registry --from-file=config.json yoke takeoff atc oci://ghcr.io/yokecd/atc-installer:latest <<EOF dockerConfigSecretName: registry EOF ``` -------------------------------- ### Yokecd Plugin Configuration Example (YAML) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md An example demonstrating how to configure the Yokecd plugin within an Argo CD Application manifest. It showcases the use of 'wasm' or 'build' parameters, along with 'args', 'input', and 'inputFiles' for passing data and configurations to the WASM executable. ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: pg namespace: argocd spec: project: default destination: name: in-cluster namespace: default syncPolicy: automated: prune: true selfHeal: true source: repoURL: https://github.com/davidmdm/yokecd-demo path: ./cmd/pg targetRevision: main plugin: name: yokecd parameters: # Will use the asset found at https://github.com/davidmdm/yokecd-demo/cmd/pg/main.wasm.gz # at revision main. # # This parameter cannot be used at the same time as "build" - name: wasm string: main.wasm.gz # Alternatively can be a url for example: # https://github.com/org/repo/releases/downloads/v1.0.0/main.wasm # If this is the case the application's source is not used. # Will build the wasm executable using the Go Toolchain with the source specified by the application. # The source must be a Go Module or inside a Go module. # # This parameter cannot be used at the same time as "wasm" - name: build string: 'true' - name: args array: ["--key=value", "positional-arg"] # this will override any other `input*` parameters, do not combine them - name: input string: 'any-input-you-want' # these files will be read relative to the source URL, path, revision # in this case `https://github.com/davidmdm/yokecd-demo/cmd/pg/{values.yaml, overrides.json}` - name: inputFiles array: - values.yaml - overrides.json # you can use this parameter to override anything read from `inputFiles` or add new properties # for examples, see below - name: input map: another: simple override: foo ``` -------------------------------- ### Install helm2go Utility Source: https://github.com/yokecd/docs/blob/main/src/content/docs/helm-compatibility.md Installs the helm2go utility using the Go build tool. This command requires the Go toolchain to be installed and configured in your system's PATH. ```bash go install github.com/yokecd/yoke/cmd/helm2go@latest ``` -------------------------------- ### Resource Access Matcher Examples Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Concepts/cluster-access.mdx Illustrates different formats for Resource Access Matchers, which control which Kubernetes resources a Flight can access. These matchers can be broad or granular. ```text * default/* Deployment.apps default/Deployment.apps:example ``` -------------------------------- ### Install YokeCD with ArgoCD Source: https://context7.com/yokecd/docs/llms.txt Command to perform a fresh ArgoCD installation with the YokeCD plugin, specifying namespace and installer image. ```bash # Fresh ArgoCD installation with YokeCD yoke takeoff --create-namespace --namespace argocd yokecd oci://ghcr.io/yokecd/yokecd-installer:latest < values.yaml ``` -------------------------------- ### Install ATC using Yoke CLI Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/generic-flights.mdx Installs the AirTrafficController (ATC) on your Kubernetes cluster using the `yoke takeoff` command. This command requires the OCI URL of the ATC installer. It deploys the ATC as a Flight resource. ```bash yoke takeoff atc oci://ghcr.io/yokecd/atc-installer:latest ``` -------------------------------- ### Install Yoke, ATC, and Backend Airway (Bash) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/atc.mdx Provides bash commands to install the Yoke CLI, set up a local Kubernetes cluster using Kind, install the ATC controller, and deploy the custom Backend Airway. ```bash # install yoke cli go install github.com/yokecd/yoke/cmd/yoke@latest # create a local cluster kind delete cluster && kind create cluster # install the atc yoke takeoff -wait 30s --create-namespace --namespace atc atc oci://ghcr.io/yokecd/atc-installer:latest # install the yokcd/examples Backend-Airway yoke takeoff -wait 30s backendairway "https://github.com/yokecd/examples/releases/download/latest/atc_backend_airway.wasm.gz" # You are done! You can now create Backends! kubectl apply -f - <<EOF apiVersion: examples.com/v1 kind: Backend metadata: name: nginx spec: image: nginx:latest replicas: 2 EOF ``` -------------------------------- ### Install Yoke CLI from Source Source: https://github.com/yokecd/docs/blob/main/src/content/docs/index.mdx Installs the Yoke CLI tool from its source code using the Go build tool. This method ensures you have the latest version directly from the repository. ```bash go install github.com/yokecd/yoke/cmd/yoke@latest ``` -------------------------------- ### Install Airway and Deploy Custom Resource (Bash) Source: https://context7.com/yokecd/docs/llms.txt This sequence of commands first installs an Airway using its Wasm definition and then applies a custom resource of the `Backend` kind to the Kubernetes cluster. This demonstrates the end-to-end process of defining and deploying custom resources managed by Yoke. ```bash # Install Airway and deploy custom resource yoke takeoff -wait 30s backendairway "https://github.com/yokecd/examples/releases/download/latest/atc_backend_airway.wasm.gz" kubectl apply -f - <<EOF apiVersion: examples.com/v1 kind: Backend metadata: name: nginx spec: image: nginx:latest replicas: 2 EOF ``` -------------------------------- ### YokeCD Service Catalog Structure Example (Bash) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md Illustrates a typical service catalog directory structure for YokeCD, where each release (e.g., alpha, beta) contains its application manifest (`app.yaml`) and Go program (`main.go`). This structure facilitates the deployment of Go programs using ArgoCD via the yokecd plugin. ```bash services ├── alpha │ ├── app.yaml │ └── main.go ├── beta │ ├── app.yaml │ └── main.go ├── go.mod └── go.sum ``` -------------------------------- ### Configure Deployment Replicas using Stdin in Go Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Examples/configuration.mdx This Go example demonstrates configuring a Kubernetes Deployment's replica count by reading JSON input from standard input. It defines a `Values` struct to unmarshal the input and uses `encoding/json` for decoding. This approach is similar to Helm's `values.yaml` and allows passing configuration via stdin or a file to the Yoke CLI. ```go // example.go package main import ( "encoding/json" "io" "os" appsv1 "k8s.io/api/apps/v1" "k8s.io/utils/ptr" ) type Values struct { Replicas int32 `json:"replicas"` } func main() { // Default Values values := Values{Replicas: 2} // Here we need to check that the error is not io.EOF as this is what you will get if // no standard input is used. if err := json.NewDecoder(os.Stdin).Decode(&values); err != nil && err != io.EOF { panic(err) } deployment := &appsv1.Deployment{ Spec: appsv1.DeploymentSpec{ Replicas: ptr.To(values.Replicas), }, } json.NewEncoder(os.Stdout).Encode(deployment) } ``` -------------------------------- ### Install Yoke CLI using Scoop Source: https://github.com/yokecd/docs/blob/main/src/content/docs/index.mdx Installs the Yoke CLI using the Scoop package manager on Windows. This provides a straightforward way to manage Yoke on Windows systems. ```bash scoop install yoke ``` -------------------------------- ### Install Yoke CLI using Homebrew Source: https://github.com/yokecd/docs/blob/main/src/content/docs/index.mdx Installs the Yoke CLI using the Homebrew package manager on macOS and Linux. This is a simple and common method for managing command-line tools. ```bash brew install yoke ``` -------------------------------- ### Install YokeCD Sidecar using Yoke CLI Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md This bash command deploys the YokeCD installer Flight to an ArgoCD namespace. It utilizes the `yoke takeoff` command to apply the Flight from a specified OCI registry, creating the namespace if it doesn't exist, and passing the configuration defined in `values.yaml` via stdin. ```bash yoke takeoff --create-namespace --namespace argocd yokecd oci://ghcr.io/yokecd/yokecd-installer:latest < values.yaml ``` -------------------------------- ### ArgoCD Input Map Parameter Example (YAML) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md Demonstrates how to use the `map` parameter in ArgoCD's Content Management Plugin spec to represent complex data structures like nested objects, arrays, and different data types using JSON/YAML formatting and JSON paths. Values for booleans and numbers need to be quoted to be parsed correctly. ```yaml - name: input map: # you can override/add any simple properties property: value newProperty: value # you can override/add nested properties nested.property: value # you can override array elements (with 0-based indices) array.0: value arrayOfObjects.0.property: value # you can append items to arrays with a special `-1` index (only once however, that would lead to duplicate keys in this map) arrayOfObjects.-1.property: value # in order to set more complex values, you can use JSON or YAML format (note the quotes or the `|` character) jsonObject: '{"some": "value"}' jsonObjectMultiline: | { "some": "value" } yamlObject: | some: value nested: value: foo # data types - booleans and numbers have to be quoted, but are parsed as respective types in the output JSON bool: "true" # will turn into: "bool": true number: "42" # will turn into: "number": 42 # unless double quoted (then they're forced strings) boolString: '"true"' # will turn into: "boolString": "true" numberString: '"42"' # will turn into: "numberString": "42" # in YAML/JSON, the string quoting on booleans/numbers works normally, no need for additional quoting jsonTypes: | { "bool": true, "boolString": "true", "num": 42, "numString": "42" } yamlTypes: | bool: true boolString: "true" num: 42 numString: "42" ``` -------------------------------- ### Configure YokeCD Installer Flight for ArgoCD Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md This YAML configuration defines parameters for the yokecd-installer Flight, which patches the ArgoCD chart to include the YokeCD sidecar. It allows customization of image, version, authentication secrets, and resource limits for both the yokecd and yokecd-server containers, as well as ArgoCD itself. The cache location for the yokecd-server can also be specified. ```yaml # values.yaml image: ghcr.io/yokecd/yokecd # default version: 0.15.0 # default is "latest" dockerAuthSecretName: my-secret # see below yokecd: resources: {} # normal limits and requests for the yokecd-plugin container. yokecdServer: cacheFS: /tmp # optional: default is "/tmp". However, you may choose move your cache to another location. # This cache avoids duplicate module downloads and avoids compiling modules from scratch. resources: {} # normal limits and requests for the yokecd-server container argocd: {} # values are passed directly to the argocd chart ``` -------------------------------- ### Deploy Generic Flight Kubernetes Manifest Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/generic-flights.mdx An example Kubernetes manifest for deploying a generic `Flight` resource. This manifest specifies the WASM module URL, input data for the Flight, and command-line arguments to be passed to the WASM execution. The `kind` can be changed to `ClusterFlight` for cluster-scoped deployments. ```yaml apiVersion: yoke.cd/v1alpha1 kind: Flight # Change to ClusterFlight for cluster-scoped deployments metadata: name: example-deployment namespace: foo spec: # The source of the Flight (HTTP(S) or OCI URL) wasmUrl: https://github.com/yokecd/examples/releases/download/latest/demos_ingress.wasm.gz # Input passed to the Flight (YAML or JSON string) input: | image: ealen/echo-server:latest replicas: 2 # Command line arguments passed to the WASM execution args: - --flag - value ``` -------------------------------- ### Get ATC Installer Schema using Yoke CLI Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/generic-flights.mdx Retrieves the schema for the ATC installer Flight using the `yoke schematics` command. This is useful for understanding the configuration inputs required for the ATC installation. The `--wasm` flag specifies that we are querying the schema of a WASM module. ```bash yoke schematics --wasm oci://ghcr.io/yokecd/atc-installer get schema ``` -------------------------------- ### Deploy Flights with Configuration (Bash) Source: https://context7.com/yokecd/docs/llms.txt These bash commands demonstrate various ways to deploy a Flight with runtime configuration. They show how to pass flags directly, provide JSON input via stdin, and use a separate values file for configuration, all using the `yoke takeoff` command. ```bash # Deploy with flags yoke takeoff example ./example.wasm -- --replicas=5 # Deploy with stdin JSON yoke takeoff example ./example.wasm <<< '{"replicas":5}' # Deploy with values file yoke takeoff example ./example.wasm < values.json ``` -------------------------------- ### Install Air Traffic Controller using Yoke CLI Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/atc.mdx This command installs the Air Traffic Controller (ATC) into a Kubernetes cluster using the `yoke` CLI. It allows for customization of the namespace, version, and release name. The installation is performed by pulling an OCI image from a specified registry. ```bash # Substitute the following variables as desired for your deployment. NAMESPACE=atc VERSION=latest RELEASE=atc # Use the yoke cli to deploy the Air Traffic Controller! yoke takeoff --create-namespace --namespace $NAMESPACE $RELEASE oci://ghcr.io/yokecd/atc-installer:$VERSION ``` -------------------------------- ### Create SQL Database Instance with Connection Secret (Go) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/orchestration.mdx Implements the logic for an Airway module to create a Crossplane-managed SQL database instance. This Go code decodes an 'App' resource from stdin, defines a 'CloudSQLInstance' with a reference to a connection secret, and adds it to the list of resources to be managed. ```go package main import ( "encoding/json" "fmt" "os" "slices" databasev1beta1 "github.com/crossplane-contrib/provider-gcp/apis/database/v1beta1" commonv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/yaml" "github.com/yokecd/yoke/pkg/flight" "github.com/yokecd/yoke/pkg/flight/wasi/k8s" ) func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func run() error { var app App if err := yaml.NewYAMLToJSONDecoder(os.Stdin).Decode(&app); err != nil { return fmt.Errorf("failed to decode stdin into App instance: %v", err) } // include the app itself in the final json result. This allows us to set its status. // this resource is special as the ATC knows its the identity of the top-level parent. // You cannot set status properties for other resources. resources := flight.Resources{&app} // Create the database instance using the crossplane project. // Most fields are omitted for brevity. database := databasev1beta1.CloudSQLInstance{ TypeMeta: metav1.TypeMeta{ APIVersion: databasev1beta1.SchemeGroupVersion.Identifier(), Kind: "CloudSQLInstance", }, ObjectMeta: metav1.ObjectMeta{ Name: app.Name, }, Spec: databasev1beta1.CloudSQLInstanceSpec{ ForProvider: databasev1beta1.CloudSQLInstanceParameters{ // Your cloud instance parameters from your application }, ResourceSpec: commonv1.ResourceSpec{ WriteConnectionSecretToReference: &commonv1.SecretReference{ Name: app.Name, Namespace: app.Namespace, }, }, }, } resources = append(resources, &database) ``` -------------------------------- ### Write a Basic Flight in Go Source: https://context7.com/yokecd/docs/llms.txt A simple Go program that generates a Kubernetes Deployment resource as a string and prints it to stdout. This demonstrates the fundamental concept of a Flight outputting raw YAML. ```go // example.go package main import "fmt" var deployment = ` apiVersion: apps/v1 kind: Deployment metadata: name: example-app labels: app: example-app spec: replicas: 2 selector: matchLabels: app: example-app template: metadata: labels: app: example-app spec: containers: - name: example-app-container image: nginx:latest ports: - containerPort: 80 ` func main() { fmt.Println(deployment) } ``` -------------------------------- ### Explain Flight Spec using kubectl Source: https://github.com/yokecd/docs/blob/main/src/content/docs/AirTrafficController/generic-flights.mdx Uses `kubectl explain` to retrieve documentation for the `spec` field of `flights` custom resources. This command provides detailed information about the available properties and their expected values for configuring a Flight. ```bash kubectl explain flights.spec ``` -------------------------------- ### Write Typed Flights with Kubernetes API (Go) Source: https://context7.com/yokecd/docs/llms.txt Demonstrates how to create a Flight using strongly-typed Kubernetes API packages in Go. This approach ensures type safety, provides IntelliSense, and offers compiler guarantees for Kubernetes resource definitions. It utilizes the `yoke/pkg/flight` library to define Kubernetes resources like Deployments and Services. ```go // example.go package main import ( "encoding/json" "fmt" "os" "github.com/yokecd/yoke/pkg/flight" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" ) func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func run() error { var ( release = flight.Release() // First argument to yoke takeoff namespace = flight.Namespace() // Value of --namespace flag labels = map[string]string{"app": release} ) resources := []flight.Resource{ &appsv1.Deployment{ TypeMeta: metav1.TypeMeta{ APIVersion: appsv1.SchemeGroupVersion.Identifier(), Kind: "Deployment", }, ObjectMeta: metav1.ObjectMeta{ Name: release, Namespace: namespace, }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, Replicas: ptr.To[int32](2), Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{Labels: labels}, Spec: corev1.PodSpec{ Containers: []corev1.Container{ { Name: release, Image: "alpine:latest", Command: []string{"watch", "echo", "hello world"}, }, }, }, }, }, }, &corev1.Service{ TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "Service"}, ObjectMeta: metav1.ObjectMeta{ Name: release, Namespace: namespace, }, Spec: corev1.ServiceSpec{ Type: corev1.ServiceTypeClusterIP, Selector: labels, Ports: []corev1.ServicePort{ { Protocol: corev1.ProtocolTCP, Port: 80, TargetPort: intstr.FromInt32(80), }, }, }, }, } return json.NewEncoder(os.Stdout).Encode(resources) } ``` -------------------------------- ### Configure Yokecd Installer with Docker Auth Secret Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md This YAML snippet shows how to configure the `yokecd-installer` to use a Docker authentication secret. By setting the `dockerAuthSecretName` parameter, the installer will automatically use the specified Kubernetes secret for Docker registry authentication. ```yaml // values.yaml dockerAuthSecretName: $SECRET_NAME ``` -------------------------------- ### Override Airway Mode for Specific Instance Source: https://context7.com/yokecd/docs/llms.txt An example of overriding the Airway's resource management mode for a specific resource instance using annotations. ```yaml apiVersion: examples.com/v1 kind: Backend metadata: annotations: overrides.yoke.cd/mode: standard name: demo spec: image: nginx:latest replicas: 2 ``` -------------------------------- ### Deploy a Flight with `yoke takeoff` Source: https://context7.com/yokecd/docs/llms.txt Demonstrates various ways to deploy a WASM package (Flight) to a Kubernetes cluster using the `yoke takeoff` command. Supports deployment from URLs, local files, OCI registries, and includes options for namespaces, input, flags, cluster access, and resource matching. ```bash # Deploy from a remote URL yoke takeoff my-release https://my-domain.com/example/v1/main.wasm.gz # Deploy from a local WASM file yoke takeoff example ./main.wasm # Deploy with namespace yoke takeoff --namespace production my-release ./main.wasm # Deploy with stdin input (like Helm values) yoke takeoff example ./example.wasm <<< '{"replicas":5}' # Deploy with input file yoke takeoff example ./example.wasm < values.json # Deploy with CLI flags passed to the WASM module yoke takeoff example ./example.wasm -- --replicas=5 # Deploy from OCI registry yoke takeoff foo oci://ghcr.io/example/repo:v1 # Deploy with cluster access enabled (allows WASM to read cluster state) yoke takeoff --cluster-access foo bar.wasm # Deploy with resource access matchers for external resources yoke takeoff -resource-access=infra/Configmap:global -resource-access=default/* my-release ./main.wasm # Deploy with namespace creation and wait yoke takeoff --create-namespace --namespace atc -wait 30s atc oci://ghcr.io/yokecd/atc-installer:latest ``` -------------------------------- ### Download Helm Chart Archive Source: https://github.com/yokecd/docs/blob/main/src/content/docs/helm-compatibility.md This command downloads a specified Helm chart from an OCI registry and saves it as a compressed tar.gz file. It requires the Helm CLI to be installed and configured. ```bash helm pull oci://registry-1.docker.io/bitnamicharts/redis --version 18.17.0 ``` -------------------------------- ### Generate Flights from Chart Repository with helm2go Source: https://github.com/yokecd/docs/blob/main/src/content/docs/helm-compatibility.md Generates Flight packages from a specified Helm chart repository. This command requires helm to be installed and accessible in the PATH. The output is directed to the specified outdir. ```bash helm2go --repo=oci://registry-1.docker.io/bitnamicharts/mongodb --outdir=flights/mongodb ``` -------------------------------- ### Compile and Deploy WASM Module (Bash) Source: https://context7.com/yokecd/docs/llms.txt This command compiles a Go program into a WebAssembly module and then deploys it using the `yoke takeoff` command. It specifies the target operating system and architecture for the WASM build and executes the compiled module. ```bash # Compile and deploy GOOS=wasip1 GOARCH=wasm go build -o example.wasm ./example.go yoke takeoff example ./example.wasm ``` -------------------------------- ### Get Schematic Data from WASM Module (CLI) Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Concepts/schematics.md Retrieves and prints the data for a specific schematic by its name from a WASM module. If the schematic is command-based, this command executes the module to generate the data. ```bash yoke schematics --wasm module.wasm get docs ``` -------------------------------- ### Auto-generate Flight from Helm Chart (Bash) Source: https://context7.com/yokecd/docs/llms.txt This command installs the `helm2go` tool, which automatically generates Yoke Flights from Helm charts. It supports specifying the Helm repository and an output directory for the generated flights. ```bash # Auto-generate Flight from Helm chart with typed values go install github.com/yokecd/yoke/cmd/helm2go@latest helm2go --repo=oci://registry-1.docker.io/bitnamicharts/mongodb --outdir=flights/mongodb ``` -------------------------------- ### CLI Usage with Resource Access Matchers Source: https://github.com/yokecd/docs/blob/main/src/content/docs/Concepts/cluster-access.mdx Demonstrates how to specify multiple resource access matchers when deploying a Flight using the Yoke CLI. The flag can be repeated or matchers can be comma-separated. ```bash yoke takeoff -resource-access=infra/Configmap:global -resource-access=... ``` -------------------------------- ### Apply ArgoCD Deployment Patch Source: https://github.com/yokecd/docs/blob/main/src/content/docs/yokecd.md This bash command applies the previously created YAML manifest to patch the existing ArgoCD repo-server deployment. It uses `kubectl patch` with the `--patch-file` option. Ensure the deployment name and namespace match your ArgoCD setup. ```bash kubectl patch deployments/argocd-repo-server --namespace=argocd --patch-file=patch.yaml ``` -------------------------------- ### Configure Flights with Flags (Go) Source: https://context7.com/yokecd/docs/llms.txt This Go code snippet demonstrates how to create a Flight that accepts configuration via command-line flags. It uses the standard `flag` package to define an integer flag for the replica count of a Kubernetes Deployment. The configured Deployment object is then encoded to JSON. ```go // Using flags package main import ( "encoding/json" "flag" "os" appsv1 "k8s.io/api/apps/v1" "k8s.io/utils/ptr" ) func main() { replicas := flag.Int("replicas", 2, "replica count for deployment") flag.Parse() deployment := &appsv1.Deployment{ Spec: appsv1.DeploymentSpec{ Replicas: ptr.To(int32(*replicas)), }, } json.NewEncoder(os.Stdout).Encode(deployment) } ```