Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
Packaging and Deploying Spin Apps using App Platform
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Intro placeholder
Workflow Diagram
diagram_placeholder
Concepts
Wasm
Spin
SpinKube
Infrastructure
- App Platform
Apps
Argo CD
Harbor
Ingress-NGINX-Platform
Workloads
Kwasm-Operator
Spin-Operator
Spin-Shim-Executor. This adds the
SpinAppExecutor
CRD (custom resource definition) to the cluster, which is used by the Spin Operator to determine which executor (e.g. the Wasm compatibility layer on the nodes) should be used in running a SpinApp.
Services
Before You Begin
Create a Cloud Manager account, if you do not already have one.
Self-enroll in the Akamai App Platform Beta. To register for the beta, visit the Betas page in the Cloud Manager and click the Sign Up button next to the Akamai App Platform Beta.
Install the Docker Engine on your workstation.
Install Tinygo on your workstation. The demo used in this tutorial requires version 0.34.0. Run the following command to check your installed version:
Your workstationtinygo version
Install the Spin CLI on your workstation.
Install the latest Go release on your workstation.
Deploy and Prepare App Platform
Follow these sections in the Getting Started with the Akamai App Platform guide to provision a App Platform-enabled Kubernetes cluster and to log into the App Platform console:
Familiarize yourself with the App Platform console UI. In particular, the top navigation features two dropdown menus:
The View toggle allows you to switch between the platform view and the team view, which affects which functions of App Platform are displayed in the left-side navigation. Some functions are displayed in both of these views, while others are available only in the platform view or only in the team view. Review the overview documentation of these views for more information.
The Team toggle allows you to switch between teams. Teams are isolated tenants in App Platform, and a namespace for each team (named
team-TEAM_NAME
) is created on the cluster. Prior to creating a workload or other resources on the cluster, select the team (in the top navigation dropdown menu) that the resources should be created for. That team’s namespace is then set for those resources. See the Teams documentation for more information.
Enable the Harbor app for App Platform. Harbor is a registry that is used to store containers for your cluster.
Select the platform option from the View menu in the top navigation.
Click the Apps item in the left-side navigation.
The Harbor app appears as disabled box in the grid of different apps. Hover over this box and click on the power-on icon to enable the app. You are asked if you want to provision object storage for your cluster. This is not required for Harbor to function in a demo environment.
Create a new Team named
demo
:Select the platform option from the View menu in the top navigation.
Click the Teams item in the left-side navigation.
Click the CREATE TEAM button.
Enter
demo
into the Name field. Use the default values for all other options in the form.Click the SUBMIT button at the end of the form.
Install the
kwasm-operator
Helm chart:Select the team option from the View menu in the top navigation. Select the admin option from the Team menu.
Click the Workloads item in the left-side navigation.
Click the CREATE WORKLOAD button.
Select the
kwasm-operator
Helm chart from the catalog.Click the Values tab.
Enter
kwasm-operator
in the Name field.Enter
kwasm
in the namespace field.Enable the Create a new namespace toggle.
Click the SUBMIT button at the end of the form.
Use
kwasm-operator
to enable Wasm support on the cluster nodes:Select the team option from the View menu in the top navigation. Select the admin option from the Team menu.
Click the Shell item in the left-side navigation. A shell session UI appears at the bottom of the console.
In the console shell, run:
App Platform console shell (admin team selected)kubectl annotate node --all kwasm.sh/kwasm-node=true
Output resembling the following should appear:
node/lke377780-583222-38daa4ab0000 annotated node/lke377780-583222-587143350000 annotated node/lke377780-583222-5ac1f8160000 annotated
The
kwasm-operator
installs the required Wasm compatibility layer dependencies on the annotated nodes.Install the
spin-operator
Helm chart:Select the team option from the View menu in the top navigation. Select the admin option from the Team menu.
Click the Workloads item in the left-side navigation.
Click the CREATE WORKLOAD button.
Select the
spin-operator
Helm chart from the catalog.Click the Values tab.
Enter
spin-operator
in the Name field.Enter
spin-operator
in the namespace field.Enable the Create a new namespace toggle.
Click the SUBMIT button at the end of the form.
Install the
spin-shim-executor
Helm chart. This chart should be installed for every team that deploys Spin Apps.Select the team option from the View menu in the top navigation. Select the demo option from the Team menu.
Click the Workloads item in the left-side navigation.
Click the CREATE WORKLOAD button.
Select the
spin-shim-executor
Helm chart from the catalog.Click the Values tab.
Enter
spin-shim-executor-demo
in the Name field.Click the SUBMIT button at the end of the form.
Your App Platform cluster now has the dependencies required to run Spin apps.
Create a New Spin App
This section shows how to create a demo Spin app using the Spin CLI. This demo app responds to HTTP requests with a “hello, world”-style response.
Spin apps are packaged and distributed as OCI artifacts. By leveraging OCI artifacts, Spin apps can be distributed using any registry that implements the Open Container Initiative Distribution Specification (a.k.a. “OCI Distribution Spec”). In particular, the Spin app created in this section is pushed up to the Harbor registry in the App Platform cluster.
The commands in this section should be run on your workstation, not in the App Platform console shell.
Spin provides templates that can be used to create new Spin apps. Run the
spin templates upgrade
command to ensure that the templates available to you are compatible with your version of Spin:Your workstationspin templates upgrade --branch main --repo https://github.com/spinframework/spin
Create a new Spin App using the
http-go
template. Then, navigate into thehello-spin
directory:Your workstationspin new --accept-defaults -t http-go hello-spin cd hello-spin
The Spin CLI created all necessary files inside the
hello-spin
directory. The implementation of the app is inmain.go
:- File: hello-spin/main.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package main import ( "fmt" "net/http" spinhttp "github.com/fermyon/spin/sdk/go/v2/http" ) func init() { spinhttp.Handle(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") fmt.Fprintln(w, "Hello Fermyon!") }) } func main() {}
This implementation responds to any incoming HTTP request. It returns an HTTP response with a status code of 200 (Ok) and
Hello Fermyon!
as the response body.The Spin CLI simplifies packaging and distribution of Spin Apps. It provides the
spin registry push
command to build the app and push it to a container registry. Before you can package and push the app, you first need to login into the private registry. Follow these steps to log into your Harbor registry from your workstation:Select the team option from the View menu in the top navigation. Select the demo option from the Team menu.
Click
Download DOCKERCFG
in the left-side navigation. A file nameddocker-team-demo.json
is downloaded to your local downloads directory.If you have an existing
.docker/
folder on your workstation (from previously authenticating with a container registry), back it up before proceeding:Your workstationcp -r $HOME/.docker $HOME/.docker-backup
Move and rename the
docker-team-demo.json
file toconfig.json
, and place it inside a.docker/
folder under your home directory:Your workstationmkdir -p $HOME/.docker/ mv $HOME/Downloads/docker-team-demo.json $HOME/.docker/config.json
Log in using the Docker CLI. Replace the hostname with the hostname of your Harbor registry. The hostname resembles
harbor.lkeID_NUMBER.akamai-apl.net
.Your workstationdocker login HARBOR_REGISTRY_HOSTNAME
There are a few ways to identify your Harbor registry hostname:
When viewing the App Platform console in your browser, the hostname for the console is displayed, which resembles
console.lkeID_NUMBER.akamai-apl.net
. Replaceconsole
withharbor
to obtain the Harbor hostname.When viewing the Harbor UI in your browser (by selecting it from the Apps item in the left-navigation, while in the platform View), the hostname is in the URL.
After running the login command, output resembling the following appears:
Authenticating with existing credentials... [Username: otomi-team-demo-push] i Info → To login with a different account, run 'docker logout' followed by 'docker login' Login Succeeded
You can now package and distribute the
hello-spin
app. Run the following command:spin registry push --build HARBOR_REGISTRY_HOSTNAME/team-demo/hello-spin:v0.0.1
The output should resemble:
Building component hello-spin with `tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go` go: downloading github.com/fermyon/spin/sdk/go/v2 v2.2.0 go: downloading github.com/julienschmidt/httprouter v1.3.0 Finished building all Spin components Pushing app to the Registry... Pushed with digest sha256:b9594bedae63fc1f701372e4f95a8ac8ee9093405b29e0f16125dc23ad8d6b82
To see the artifact you just pushed to Harbor:
Select the platform option from the View menu in the top navigation. Select the admin option from the Team menu.
Click Apps from the left-side navigation.
Click the Harbor app. The Harbor UI is opened in a new tab.
Click the team-demo project in the Projects table.
Click the hello-spin repository.
Deploy the Spin App
There are a few different ways to deploy Spin Apps:
Use the Spin CLI and run
spin kube deploy
to directly deploy the app to your clusterUse
spin kube scaffold
to generate a .yaml file and usekubectl apply -f
to create theSpinApp
resourceOn App Platform, use the Spin App Helm chart.
This section shows how to use the Spin App Helm chart for App Platform. By using this method, you can take advantage of the continuous delivery and monitoring features of App Platform:
Select the team option from the View menu in the top navigation. Select the admin option from the Team menu.
Click the Workloads item in the left-side navigation.
Click the CREATE WORKLOAD button.
Select the
Spin-App
Helm chart from the catalog.Click the Values tab.
Enter
hello-spin
in the Name field.Set the Auto image updater option to Semver
In the Semver form:
Enter
team-demo/hello-spin
in the imageRepository fieldEnter
v0.x
in the versionConstraint field.
In the chart values file, location the
image
andreplicaCount
parameters. Update the values for these parameters as follows:- File: Chart values file
1 2 3 4
image: repository: HARBOR_REGISTRY_HOSTNAME/team-demo/hello-spin tag: v0.0.1 replicaCount: 1
Click the SUBMIT button at the end of the form.
After a few minutes, the status of the Workload should be healthy. Click on the Application link for the workload to see it in Argo CD.
Connect to the Spin App
The Spin app is now deployed on the cluster, but it is not exposed to the internet. To expose the app, create an NGINX ingress service:
Select the team option from the View menu in the top navigation. Select the admin option from the Team menu.
Click the Services item in the left-side navigation.
Click the CREATE SERVICE button.
Enter ‘hello-spin in the Name field.
In the Exposure form, select the External option.
Click the SUBMIT button at the end of the form.
In the list of services, click on the URL of the
hello-spin
app. The app’s response is displayed in your browser:
Update the Spin App
When you installed the Spin-App Helm chart, you set the Auto image updater to Semver. This automatically updates the deployed image to the most recent pushed version of a given tag. So, to update and re-deploy the Spin app, you just need to build a new version of it and push it to Harbor:
On your workstation, update the contents of the
main.go
file:- File: hello-spin/main.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package main import ( "fmt" "net/http" spinhttp "github.com/fermyon/spin/sdk/go/v2/http" ) func init() { spinhttp.Handle(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") fmt.Fprintln(w, "Hello Fermyon. Welcome to Akamai App Platform!") }) } func main() {}
This updated code features a new response message (
Hello Fermyon. Welcome to Akamai App Platform!
).Build and push the app to Harbor:
Your workstationspin registry push --build harbor.<domain-of-your-cluster>/team-demo/hello-spin:v0.0.2
To check the update, refresh the app in your browser. You should now see the new response message.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on