### Setup and Build spin-operator Source: https://github.com/spinframework/spin-operator/blob/main/CONTRIBUTING.md Guides users through cloning the repository, setting up a fork, creating a new branch, building the project using `make`, and running tests. ```shell $ git clone https://github.com/spinframework/spin-operator && cd spin-operator # add a new remote pointing to your fork of the project $ git remote add fork https://github.com//spin-operator # create a new branch for your work $ git checkout -b # build spin-operator $ make # make sure compilation is successful $ ./bin/manager --help # run the tests and make sure they pass $ make test ``` -------------------------------- ### Install Spin Shim Executor and RuntimeClass Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Installs necessary post-installation resources for spin-operator. This includes the Spin Shim Executor, which runs Spin applications, and a RuntimeClass for the 'wasmtime-spin-v2' container runtime. ```console kubectl apply -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/samples/spin-shim-executor.yaml kubectl apply -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/samples/spin-runtime-class.yaml ``` -------------------------------- ### Install spin-operator Helm Chart Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Installs the spin-operator Helm chart into a specified Kubernetes namespace. This command deploys the operator and its associated resources using Helm, requiring a placeholder for the chart version. ```console helm install spin-operator \ --namespace spin-operator \ --create-namespace \ --version {{ CHART_VERSION }} \ oci://ghcr.io/spinframework/charts/spin-operator ``` -------------------------------- ### Install Spin Operator containerd-shim-spin Executor Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/templates/NOTES.txt Applies the Kubernetes YAML manifest to install the containerd-shim-spin SpinAppExecutor, a prerequisite for running Spin applications with the spin-operator. This command uses kubectl to apply the specified YAML file from a release URL. ```shell kubectl apply -f https://github.com/spinframework/spin-operator/releases/download/v{{ .Chart.Version }}/spin-operator.shim-executor.yaml ``` -------------------------------- ### Show Spin Operator Helm Chart README Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/templates/NOTES.txt Retrieves and displays the README file for the spin-operator Helm chart from its OCI registry. This command is useful for getting detailed information about the chart's configuration and usage. ```shell helm show readme oci://ghcr.io/spinframework/charts/spin-operator ``` -------------------------------- ### Install Cert-Manager for Webhook Support Source: https://github.com/spinframework/spin-operator/blob/main/README.md Installs cert-manager, a Kubernetes add-on for managing TLS certificates, which is required for webhook support in the Spin Operator. ```shell kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.3/cert-manager.yaml kubectl wait --for=condition=available --timeout=300s deployment/cert-manager-webhook -n cert-manager ``` -------------------------------- ### Install Spin Operator wasmtime-spin-v2 RuntimeClass Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/templates/NOTES.txt Applies the Kubernetes YAML manifest to install the wasmtime-spin-v2 RuntimeClass, another prerequisite for the spin-operator to manage Spin applications. This command uses kubectl to apply the specified YAML file from a release URL. ```shell kubectl apply -f https://github.com/spinframework/spin-operator/releases/download/v{{ .Chart.Version }}/spin-operator.runtime-class.yaml ``` -------------------------------- ### Deploy Redis Database Source: https://github.com/spinframework/spin-operator/blob/main/apps/redis-sample/README.md Kubernetes manifests to deploy a Redis database. This includes a Deployment for the Redis server and a Service to expose it within the cluster. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: redis labels: app: redis spec: replicas: 1 selector: matchLabels: app: redis template: metadata: labels: app: redis spec: containers: - name: redis image: redis ports: - containerPort: 6379 --- apiVersion: v1 kind: Service metadata: name: redis spec: selector: app: redis ports: - protocol: TCP port: 6379 targetPort: 6379 ``` -------------------------------- ### Run Spin Operator Locally Source: https://github.com/spinframework/spin-operator/blob/main/README.md Starts the Spin Operator process on the local machine. This is used for development and testing against a Kubernetes cluster. ```shell make run ``` -------------------------------- ### Interact with Spin App via HTTP Source: https://github.com/spinframework/spin-operator/blob/main/apps/redis-sample/README.md Demonstrates how to interact with the deployed Spin application using `curl` commands after port-forwarding. These commands show how to place, retrieve, and delete key-value pairs in Redis through the Spin app's HTTP interface. ```bash # Place a key-value pair in Redis curl --request PUT --data-binary "Hello, world!" -H 'x-key: helloKey' localhost:3000 ``` ```bash # Retrieve a value from Redis curl -H 'x-key: helloKey' localhost:3000 ``` ```bash # Delete a value from Redis curl --request DELETE -H 'x-key: helloKey' localhost:3000 ``` -------------------------------- ### Install SpinApp and SpinAppExecutor CRDs Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Installs the CustomResourceDefinitions (CRDs) for Spin applications and Spin application executors. These CRDs are essential for the spin-operator to manage Spin resources within a Kubernetes cluster. ```console kubectl apply -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/crd/bases/core.spinkube.dev_spinapps.yaml kubectl apply -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/crd/bases/core.spinkube.dev_spinappexecutors.yaml ``` -------------------------------- ### Deploy Spin App with Redis Client Source: https://github.com/spinframework/spin-operator/blob/main/apps/redis-sample/README.md Kubernetes manifest to deploy a Spin application configured to interact with Redis. It specifies the application image, replica count, executor, and sets the Redis endpoint as an environment variable. ```yaml apiVersion: core.spinkube.dev/v1alpha1 kind: SpinApp metadata: name: redis-spinapp spec: image: "ghcr.io/spinkube/redis-sample" replicas: 1 executor: containerd-shim-spin variables: - name: redis_endpoint value: redis://redis.default.svc.cluster.local:6379 ``` -------------------------------- ### Install Spin Operator CRDs Source: https://github.com/spinframework/spin-operator/blob/main/README.md Installs the SpinApp and SpinAppExecutor Custom Resource Definitions (CRDs) into the Kubernetes cluster, enabling the operator to manage these resources. ```shell make install ``` -------------------------------- ### Upgrade spin-operator Helm Chart Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Upgrades an existing spin-operator Helm release to a new version. This command applies updates to the operator deployment and its associated Kubernetes resources. ```console helm upgrade spin-operator \ --namespace spin-operator \ --version {{ CHART_VERSION }} \ oci://ghcr.io/spinframework/charts/spin-operator ``` -------------------------------- ### Uninstall Spin Shim Executor and RuntimeClass Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Removes the Spin Shim Executor and the Wasmtime RuntimeClass resources from the Kubernetes cluster. These are typically uninstalled after the operator itself is removed. ```console kubectl delete -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/samples/spin-runtime-class.yaml kubectl delete -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/samples/spin-shim-executor.yaml ``` -------------------------------- ### Uninstall spin-operator Helm Release Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Deletes the spin-operator Helm release and all associated Kubernetes resources. This command removes the operator deployment from the cluster. ```console helm delete spin-operator --namespace spin-operator ``` -------------------------------- ### Upgrade SpinApp and SpinAppExecutor CRDs Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Upgrades the CustomResourceDefinitions (CRDs) for Spin applications and Spin application executors. This is often required when upgrading the spin-operator itself to ensure compatibility. ```console kubectl apply -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/crd/bases/core.spinkube.dev_spinapps.yaml kubectl apply -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/crd/bases/core.spinkube.dev_spinappexecutors.yaml ``` -------------------------------- ### Uninstall SpinApp and SpinAppExecutor CRDs Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/README.md Deletes the CustomResourceDefinitions (CRDs) for Spin applications and Spin application executors from the Kubernetes cluster. This is a final cleanup step after uninstalling the operator. ```console kubectl delete -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/crd/bases/core.spinkube.dev_spinapps.yaml kubectl delete -f https://raw.githubusercontent.com/spinframework/spin-operator/main/config/crd/bases/core.spinkube.dev_spinappexecutors.yaml ``` -------------------------------- ### Deploy Sample Spin Application Source: https://github.com/spinframework/spin-operator/blob/main/README.md Applies a sample Spin application manifest to the Kubernetes cluster. This demonstrates deploying a basic Spin application. ```shell kubectl apply -f ./config/samples/simple.yaml ``` -------------------------------- ### Build and Run cpu-load-gen Source: https://github.com/spinframework/spin-operator/blob/main/apps/cpu-load-gen/README.md Provides commands to build the Spin application, run it locally, and push it to a container registry for deployment. These commands are essential for the development workflow of the cpu-load-gen application. ```bash # Build it\nspin build\n\n# Run it\nspin up\n\n# Push it to registry to be used by SpinApp in spin-operator\nspin registry push ttl.sh/cpu-load-gen:1h ``` -------------------------------- ### Clone Documentation Repository Source: https://github.com/spinframework/spin-operator/blob/main/RELEASE.md Clones the `spinkube-docs` repository to update documentation. After cloning, navigate into the repository directory to make the necessary version changes. ```console git clone git@github.com:spinframework/spinkube-docs cd spinkube-docs ``` -------------------------------- ### Build Spin Operator Binary Source: https://github.com/spinframework/spin-operator/blob/main/README.md Compiles the Spin Operator project to produce a binary executable. This is the primary build command. ```shell make ``` -------------------------------- ### Apply Spin RuntimeClass and SpinAppExecutor Source: https://github.com/spinframework/spin-operator/blob/main/README.md Applies Kubernetes configuration files for Spin's RuntimeClass and SpinAppExecutor. These are essential for Spin applications to run within the cluster. ```shell kubectl apply -f config/samples/spin-runtime-class.yaml kubectl apply -f config/samples/spin-shim-executor.yaml ``` -------------------------------- ### Run Test Suite Source: https://github.com/spinframework/spin-operator/blob/main/README.md Executes the project's test suite to verify functionality. This is a standard command for ensuring code quality. ```shell make test ``` -------------------------------- ### Create k3d Cluster Source: https://github.com/spinframework/spin-operator/blob/main/README.md Creates a local Kubernetes cluster using k3d, a lightweight distribution. It specifies the containerd shim image and port mapping for the load balancer. ```shell k3d cluster create wasm-cluster \ --image ghcr.io/spinkube/containerd-shim-spin/k3d:v0.16.0 \ -p "8081:80@loadbalancer" \ --agents 2 ``` -------------------------------- ### Check Spin Operator Helm Release Status and Details Source: https://github.com/spinframework/spin-operator/blob/main/charts/spin-operator/templates/NOTES.txt Commands to check the deployment status and retrieve all resources associated with the spin-operator Helm release. These commands require the Helm CLI and the release name and namespace. ```shell helm --namespace {{ .Release.Namespace }} status {{ .Release.Name }} helm --namespace {{ .Release.Namespace }} get all {{ .Release.Name }} ``` -------------------------------- ### Build and Push Spin Operator Docker Image Source: https://github.com/spinframework/spin-operator/blob/main/README.md Builds a Docker image for the Spin Operator and pushes it to a specified container registry. This is an optional step for deploying custom images. ```shell export IMG_REPO=/spin-operator make docker-build docker-push ``` -------------------------------- ### Push Git Tag for Release Source: https://github.com/spinframework/spin-operator/blob/main/RELEASE.md Executes a series of git commands to checkout the main branch, add the upstream remote, pull the latest changes, create a signed git tag for the release, and push the tag to the upstream repository. ```console git checkout main git remote add upstream git@github.com:spinframework/spin-operator git pull upstream main git tag --sign $TAG --message "Release $TAG" git push upstream $TAG ``` -------------------------------- ### Commit Changes with GPG Signature Source: https://github.com/spinframework/spin-operator/blob/main/CONTRIBUTING.md Instructions for committing changes locally, ensuring GPG signature and sign-off message are included as required by the project. ```shell $ git commit -S -s -m "" ``` -------------------------------- ### Run E2e Tests Source: https://github.com/spinframework/spin-operator/blob/main/e2e/README.md Executes the end-to-end tests for the spin operator project using the Go testing framework. The `-v` flag provides verbose output during test execution. ```bash go test ./e2e -v ``` -------------------------------- ### Deploy Spin Operator to Cluster Source: https://github.com/spinframework/spin-operator/blob/main/README.md Deploys the Spin Operator to a Kubernetes cluster. This command assumes the operator image is built and available. ```shell make deploy ``` -------------------------------- ### Set Release Tag Environment Variable Source: https://github.com/spinframework/spin-operator/blob/main/RELEASE.md Sets the `TAG` environment variable to the new release version. This variable is used in subsequent commands for tagging and release messages. Remember to replace `v0.x.0` with the actual version. ```console export TAG=v0.x.0 #CHANGEME ``` -------------------------------- ### Push Changes to Fork Source: https://github.com/spinframework/spin-operator/blob/main/CONTRIBUTING.md Command to push the local branch containing your contributions to your remote fork, preparing it for a pull request. ```shell # "fork" is the name of the git remote pointing to your fork $ git push fork ``` -------------------------------- ### Access Spin Application via Curl Source: https://github.com/spinframework/spin-operator/blob/main/README.md Makes an HTTP request to the Spin application using curl, targeting the locally forwarded port. This verifies the application is running and accessible. ```shell curl localhost:8083/hello ``` -------------------------------- ### Port Forward to Spin Application Service Source: https://github.com/spinframework/spin-operator/blob/main/README.md Forwards a local port to the Spin application's service in the Kubernetes cluster, allowing local access to the deployed application. ```shell kubectl port-forward svc/simple-spinapp 8083:80 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.