title | description | categories | tags | weight | ||
---|---|---|---|---|---|---|
Quickstart |
What does your user need to know to try your project? |
|
|
2 |
This Quickstart guide demonstrates how to set up a new Kubernetes cluster, install the Spin Operator and deploy your first Spin application.
Ensure necessary [prerequisites]({{< ref "prerequisites" >}}) are installed.
For this Quickstart in particular, you will need:
- [kubectl]({{< ref "prerequisites#kubectl" >}}) - the Kubernetes CLI
- [k3d]({{< ref "prerequisites#k3d" >}}) - a lightweight Kubernetes distribution that runs on Docker
- [Docker]({{< ref "prerequisites#docker" >}}) - for running k3d
Also, ensure you have cloned this repository and have navigated to the root of the project:
git clone git@github.com:spinkube/spin-operator.git
cd spin-operator
- Create a Kubernetes cluster with a k3d image that includes the containerd-shim-spin prerequisite already installed:
k3d cluster create wasm-cluster \
--image ghcr.io/deislabs/containerd-wasm-shims/examples/k3d:v0.11.0 \
--port "8081:80@loadbalancer" \
--agents 2
Note: Spin Operator requires a few Kubernetes resources that are installed globally to the cluster. We create these directly through
kubectl
as a best practice, since their lifetimes are usually managed separately from a given Spin Operator installation.
For now our quickstart relies on
make
tasks within the repository. We will provide Kustomize and Helm instructions in the future.
- Install cert manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.3/cert-manager.yaml
- Apply the Runtime Class used for scheduling Spin apps onto nodes running the shim:
Note: In a production cluster you likely want to customize the runtimeClass with a
nodeSelector:
that matches nodes that have the shim installed. In the K3D example they're installed on every node.
kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.0.2/spin-operator.runtime-class.yaml
- Apply the Custom Resource Definitions used by the Spin Operator:
kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.0.2/spin-operator.crds.yaml
Run the following command to run the Spin Operator locally. This will create all of the Kubernetes resources required by Spin Operator under the Kubernetes namespace spin-operator. It may take a moment for the installation to complete as dependencies are installed and pods are spinning up.
make docker-build IMG=ghcr.io/spinkube/spin-operator:dev
k3d image import -c wasm-cluster ghcr.io/spinkube/spin-operator:dev
make deploy IMG=ghcr.io/spinkube/spin-operator:dev
Lastly, create the shim executor:
kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.0.2/spin-operator.shim-executor.yaml
You are now ready to deploy Spin applications onto the cluster!
- Create your first application in the same
spin-operator
namespace that the operator is running:
kubectl apply -f https://raw.githubusercontent.com/spinkube/spin-operator/main/config/samples/simple.yaml
- Forward a local port to the application pod so that it can be reached:
kubectl port-forward svc/simple-spinapp 8083:80
- In a different terminal window, make a request to the application:
curl localhost:8083/hello
You should see:
Hello world from Spin!
Congrats on deploying your first SpinApp! Recommended next steps:
- Scale your [Spin Apps with Horizontal Pod Autoscaler (HPA)]({{< ref "scaling-with-hpa.md" >}})
- Scale your [Spin Apps with Kubernetes Event Driven Autoscaler (KEDA)]({{< ref "scaling-with-keda.md" >}})