Watch / Tutorial On demand
Overview

About this video

What You'll Learn

  1. Route multiple paths through one Spin component with the Itty-style JavaScript router
  2. Secure Postgres and MySQL outbound connections with TLS-enabled database access
  3. Push Spin workloads to OCI registries, then sign and verify with cosign

A tour of Spin 0.8: the Itty-style JavaScript router for multi-path components, TLS support for outbound Postgres and MySQL connections, and first-class OCI registry push, sign with cosign, and verify workflows.

Chapters

Jump to a chapter

  1. 0:00 Introduction
  2. 0:16 JS Router (Itty Router)
  3. 2:33 TLS Database Connections (#PostgreSQL, #MySQL)
  4. 3:56 TLS Database Demo
  5. 4:32 OCI Registry Support
  6. 4:33 OCI Registry Support
  7. 5:36 OCI Registry Demo (Push, Sign, Verify)
  8. 6:30 Conclusion
Transcript

Full transcript

Generated from the English captions. Timestamps jump the player to that moment.

Read the full transcript

0:00 Introduction

0:00 In just a moment we're gonna take a look at what's new in Fermion Spin 0.8. From TLS for DB connections to JavaScript routing and OCI registry support. Let's dive in. The first thing we're gonna take a look at is the new JavaScript router. What does this mean? Well, typically architecting your Spin applications, you add a single component for every path in your application. However, sometimes, depending on the complexity of your applications, you may want a single component that handles one or more paths, probably even a collection of sub pass. And to do that, the Spin Node JS

0:16 JS Router (Itty Router)

0:49 SDK provides you with the Eti router. Let's take a look. So the GS routing project here was generated using spin new. I select an HTTP TS for a TypeScript example. I've literally copied and pasted all of this code from the release blog, which is available in the description and on the screen now. As you can see, we have the ability to request a new return from the utils package. Now at first you may be wondering, hey, where where is utils coming from? It's not imported. Well, don't worry about it. This is provided as a global and the TypeScript definition fail.

1:32 So you can call it with ease. From here, we can add using the HTTP method that we want to capture new routes. Here, we're adding a get route of slash, and here, a get route of slash goodbye. You can use any HTTP verb, such as delete, patch, post, put, etcetera. From in there, you're just writing any standard spin endpoint. As you can see, we can risk around a 200 and use the encoder to drop goodbye into the buffer. Whereas here we just say hello Spin is handling this route. To connect the dots we export a handle

2:19 request function which just returns router handle request. Nice and simple. This gives you a bit more flexibility into how you architect and compose your Spin components and to Spin applications. Next up, TLS support for outbound database connections. Previously, you could talk to any cloud style database that exposed their API over TLS. It's a free postgres service built in a serverless fashion. It's very easy with a very low friction onboarding experience, but I couldn't use it because I needed TLS. PlanetScale also offer free databases. CockroachDB also offer free databases. We're in a wonderful world where if you

2:33 TLS Database Connections (#PostgreSQL, #MySQL)

3:06 want to store data for free online and not have to worry about backups, policy, RBAC, etcetera, it's there. However, it was a challenge to use in Spin. Now, that's not a problem. Using the Rust SDK for Spin, I'm able to define a show. I create a try from function to allow me to coerce a raw result from the Postgres driver into a show struct. We can add a format column function to make it easier to print the data to the terminal. And then we use the Postgres module just like we could before. In fact, nothing in this code is any

3:53 different from pre 0.8. So let's see it working. In my spin.toml, I have a Neon Tech, an online free Postgres database available with my username database, and I'm hiding my password for now. I can jump over to the terminal and run spin up. Now we have an endpoint that's going to read all of the shows from my Postgres database, and we can run local host 3,000 like so. This speaks to NeonTech, the remote TLS server based database, and spits out my shows to the terminal. Such a small change, but with powerful possibilities. Lastly, and probably my favorite feature in zero

4:33 OCI Registry Support

4:36 point a is support for OCI registries. This is gonna make interrupt and hybrid applications for web assembly and containers a whole lot simpler because they use the same discoverability and distribution mechanism as container based applications. Here we have a Spin application using the Spin file server, which delivers static assets like my very simple index. HTML. I provided a just file here. One with an image name and here I'm using the GitHub container registry on my own repository to store exploring Spin watch news 0.8 application. We can do a push using Spin OCI push with the image name.

5:24 Even cooler than that, we can sign this because it's a standard OCI artifact. We can use cosign in that suite. Lastly, for the demo, I'm gonna do a push and sign. Well, let's run just demo like so. Spin OCI push is now building the WebAssembly artifact into an OCI artifact and pushing it to get hubs container registry. Next, cosign is going to sign our image for us and we can just confirm the prompt. This will ask me to log in with my GitHub credentials like so. Now, let's clear screen and run Just Verify. This runs a cosign verify against the image

5:36 OCI Registry Demo (Push, Sign, Verify)

6:12 that we just signed. We can see the claims were validated, existence of the claims were verified in the transparency log and certificates were verified against the Visio route. And we can see this was signed with my GitHub credentials. Awesome. And that is spin 0.8. The Fairmount team continued to impress me with their velocity, cool features, shiny new things to play with. So we'll see you for the next video in the complete guide to Spin. Till next time. Have a great day.

Technologies featured

Weekly Cloud Native insights

Stay ahead in cloud native

Tutorials, deep dives, and curated events. No fluff.

Comments, transcript, and resources

Additional Resources

Spin

More about Spin

View all 20 videos