Experimenting with Deno for Easier Kubernetes Deployments

Rate this content
Bookmark

As we all know, dealing with Kubernetes YAML is not very intuitive (especially for those just getting starting) and the more resources and dependencies are added the messier and more complex the process becomes. In this talk, we'll explore how we can use Typescript and Deno to bring typing, composition, code-reuse, and testing as an alternative to YAML - that doesn't include these capabilities, all while still remaining declarative and easy to use.

This talk has been presented at DevOps.js Conf 2022, check out the latest edition of this JavaScript Conference.

FAQ

The primary focus of Ishai's talk is how to use Deno to define Kubernetes deployments more easily and efficiently compared to traditional methods.

Developers face challenges such as the complexity and large size of Kubernetes YAML files, which can make them hard to manage, error-prone, and tedious to write and maintain manually.

Lifecycle is a collaboration tool for development teams based on a previous environment, currently in public beta. Ishai is the CTO and cofounder of Lifecycle.

The purpose of using TypeScript with Deno for Kubernetes configurations is to leverage TypeScript's powerful type system, enabling better composition, abstraction, and error-checking, ultimately making configurations easier and more reliable.

A Kubernetes pod is the smallest and simplest compute unit in Kubernetes, which can run one or more containers. It is used to deploy and manage containerized applications.

Deno improves security by running scripts in a sandbox environment by default, restricting access to environment variables, file systems, and networks unless explicitly allowed by the user.

Deno offers several advantages for writing Kubernetes configurations, including built-in TypeScript support, no dependencies or boilerplate, a secure runtime, and a simpler, more concise way to handle configurations using TypeScript.

Yes, Deno can be adapted for other configuration tasks that use JSON schema. The approach involves generating TypeScript types from the schema and then writing and serializing the configurations in TypeScript.

Ingress in Kubernetes is a resource that manages external access to services within a cluster, typically HTTP. It provides routing rules to manage traffic, making it crucial for exposing services to the outside world.

YAML is a human-readable data serialization standard commonly used for configuration files. In Kubernetes, YAML is significant because it is used to define configurations for various resources like pods, services, and deployments.

Yshay Yaacobi
Yshay Yaacobi
31 min
25 Mar, 2022

Comments

Sign in or register to post your comment.
Video Summary and Transcription
The Talk discusses using Dino and TypeScript to simplify writing and managing Kubernetes YAML configurations. It explores the challenges of working with large YAML files and introduces a unique solution. The Talk also highlights the features and benefits of Deno, such as its secure runtime and powerful typing capabilities. It demonstrates how Deno can be used to create and modify Kubernetes objects, and emphasizes the advantages of using a general-purpose language for configuration. The Talk concludes by discussing the potential applications of this approach beyond Kubernetes deployments.

1. Introduction to Dino and YAML in Kubernetes

Short description:

I'm going to talk about how we can use Dino to define our Kubernetes deployment in an easier way. Let's talk about YAML and its challenges. Kubernetes YAMLs are huge and complex, making manual writing difficult. Today, we'll discuss how to write YAMLs easier using DNO and TypeScript. I'm a cofounder of Lifecycle and an open source maintainer of Tweak. Lifecycle is a collaboration tool for development teams. We'll also explore how resources in Kubernetes work.

Hi, everyone. I'm Ishai. I'm the CTO of Lifecycle. Today I'm going to talk about how we can use Dino to define our Kubernetes deployment in a much more easier way than what we are usually doing.

To give some context, let's talk about YAML. Because Kubernetes is basically, like, all the configuration of Kubernetes is like this big, giant YAML file. And you probably, like, even if you didn't use Kubernetes, you know the YAML files from other places, like from GitHub Actions or from Docker Compose or CloudFormation. And basically, like, every tool, I mean, so many tools, like, in the DevOps ecosystem, are using YAML to define this configuration. And to be honest, for me, the first time I encountered this YAML file, it was terrible. I didn't, I mean, it wasn't convenient, like, copying from different YAMLs and merging them, and the indentation was weird and, like, DRA object differences. But I got used to that. And I will get, I'm, like, writing lots of YAMLs, and it works well. But the thing is that Kubernetes YAMLs, they're like, huge and complex, and there are so many of them. Which in this case, like, writing the YAMLs manually simply doesn't cut it in terms of, like, scale and correctness and even, like, fun and sanity.

So, today I'm going to talk about how we can write these YAMLs easier and more specifically, how we can do it with using DNO and TypeScript.

A few words about myself. As I mentioned, I'm a cofounder of Lifecycle. I'm a software engineer. I've used Kubernetes in the past five years. I'm also open source maintainer of Tweak. It's a Cloud native feature management solution. Two words on Lifecycle, it's a collaboration tools for development teams based on a like previous environment. It's a product in public beta that we launched like a few weeks ago, and we are very excited about it. You are welcome to check it out on Lifecycle.io.

Okay, so, what's on the agenda today? We are going to look at Kubernetes. We are going to define the same configuration in DNO, and we'll summarize. A few words about how resources in Kubernetes works. Basically, the idea is that we have the Kubernetes users, which can be developers or administrators. They are pushing a definition to the API server using YAML, and we have the controllers of Kubernetes that make all the magic happening. Now, these resources can be everything from a cron job, or a network thing, or a volume, or a bucket.

2. Introduction to YAML and Kubernetes Resources

Short description:

Kubernetes is vast and awesome. Everything is described with YAML, making it extensible and enabling the creation of custom resources. I'll show a naive use case with a Tetris application and demonstrate how to run and delete it. Then, I'll explain a naive definition of a service using a deployment object, which is more powerful than a pod.

It's really vast and it's pretty awesome. I mean, it's really one of the selling points of Kubernetes, in my opinion. Everything is data, everything is resource. Every resource is described with YAML. It's extensible, so we can have custom resources, and we really have those kind of things for monitoring, or for scaling, or for platform, like a build or CI stuff. And this ecosystem of Kubernetes is huge, and everything is defined in YAML. So it's pretty amazing.

So I'm going to show how these YAMLs look like in a very naive use cases. So we'll be like on the same page of what we are trying to solve in this kind of YAMLs. So the first example I'm going to show an application that is like a Tetris application. We can say that we have the definition of Kubernetes. Every resource has the version of the group of this resource, the API version it's called in Kubernetes. The kind, in this case, is a pod. A pod is simply compute units that run containers. And if I want to run it, I'm using the Kubernetes CLI and I'm just running it. I either have like a working Kubernetes cluster with all of the subgroups. It's a real server. So, we can see these examples live. So, I run the Tetris application. And basically, we now have a container that runs Tetris. It's not very useful, because I want to interact with it. So, I'm going to delete this definition. The same way, instead of applying the file, I'm deleting it.

And let's look at how usually again, a very naïve definition of a service will look like. So, I have the same configuration of the application. But with CPU and memory limits, I'm using a deployment object, which is a bit more powerful than a pod, because it's basically create a number of pods. For example, in this case, it's like two pods. It's also like, if one of them is going down, it's going to revive them. It's also designed for a rollout strategy. Basically, deployment is the way we usually define an application.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
NPM workspaces help manage multiple nested packages within a single top-level package, improving since the release of NPM CLI 7.0. You can easily add dependencies to workspaces and handle duplications. Running scripts and orchestration in a monorepo is made easier with NPM workspaces. The npm pkg command is useful for setting and retrieving keys and values from package.json files. NPM workspaces offer benefits compared to Lerna and future plans include better workspace linking and adding missing features.
Automating All the Code & Testing Things with GitHub Actions
React Advanced 2021React Advanced 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
We will learn how to automate code and testing with GitHub Actions, including linting, formatting, testing, and deployments. Automating deployments with scripts and Git hooks can help avoid mistakes. Popular CI-CD frameworks like Jenkins offer powerful orchestration but can be challenging to work with. GitHub Actions are flexible and approachable, allowing for environment setup, testing, deployment, and custom actions. A custom AppleTools Eyes GitHub action simplifies visual testing. Other examples include automating content reminders for sharing old content and tutorials.
Fine-tuning DevOps for People over Perfection
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
DevOps is a journey that varies for each company, and remote work makes transformation challenging. Pull requests can be frustrating and slow, but success stories like Mateo Colia's company show the benefits of deploying every day. Challenges with tools and vulnerabilities require careful consideration and prioritization. Investing in documentation and people is important for efficient workflows and team growth. Trust is more important than excessive control when deploying to production.
Why is CI so Damn Slow?
DevOps.js Conf 2022DevOps.js Conf 2022
27 min
Why is CI so Damn Slow?
Slow CI has a negative impact on productivity and finances. Debugging CI workflows and tool slowness is even worse. Dependencies impact CI and waiting for NPM or YARN is frustrating. The ideal CI job involves native programs for static jobs and lightweight environments for dynamic jobs. Improving formatter performance and linting is a priority. Performance optimization and fast tools are essential for CI and developers using slower hardware.
The Zen of Yarn
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
The Zen of Yarn
Let's talk about React and TypeScript, Yarn's philosophy and long-term relevance, stability and error handling in Yarn, Yarn's behavior and open source sustainability, investing in maintenance and future contributors, contributing to the JavaScript ecosystem, open-source contribution experience, maintaining naming consistency in large projects, version consistency and strictness in Yarn, and Yarn 4 experiments for performance improvement.
Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Deno aims to provide Node.js compatibility to make migration smoother and easier. While Deno can run apps and libraries offered for Node.js, not all are supported yet. There are trade-offs to consider, such as incompatible APIs and a less ideal developer experience. Deno is working on improving compatibility and the transition process. Efforts include porting Node.js modules, exploring a superset approach, and transparent package installation from npm.

Workshops on related topic

Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.
MERN Stack Application Deployment in Kubernetes
DevOps.js Conf 2022DevOps.js Conf 2022
152 min
MERN Stack Application Deployment in Kubernetes
Workshop
Joel Lord
Joel Lord
Deploying and managing JavaScript applications in Kubernetes can get tricky. Especially when a database also has to be part of the deployment. MongoDB Atlas has made developers' lives much easier, however, how do you take a SaaS product and integrate it with your existing Kubernetes cluster? This is where the MongoDB Atlas Operator comes into play. In this workshop, the attendees will learn about how to create a MERN (MongoDB, Express, React, Node.js) application locally, and how to deploy everything into a Kubernetes cluster with the Atlas Operator.
Azure Static Web Apps (SWA) with Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
13 min
Azure Static Web Apps (SWA) with Azure DevOps
WorkshopFree
Juarez Barbosa Junior
Juarez Barbosa Junior
Azure Static Web Apps were launched earlier in 2021, and out of the box, they could integrate your existing repository and deploy your Static Web App from Azure DevOps. This workshop demonstrates how to publish an Azure Static Web App with Azure DevOps.
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
163 min
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop gives a practical perspective of key principles needed to develop, build, and maintain a set of microservices in the Node.js stack. It covers specifics of creating isolated TypeScript services using the monorepo approach with lerna and yarn workspaces. The workshop includes an overview and a live exercise to create cloud environment with Pulumi framework and Azure services. The sessions fits the best developers who want to learn and practice build and deploy techniques using Azure stack and Pulumi for Node.js.