npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@winglibs/k8s

v0.0.10

Published

Wing for Kubernetes

Downloads

763

Readme

Wing for Kubernetes

A framework for synthesizing Kubernetes manifests using Winglang.

Installation

Install the Wing CLI:

npm i -g winglang

Create a new project and install this library:

mkdir wing-loves-k8s
cd wing-loves-k8s
npm i @winglibs/k8s

Usage

Let's define an app with a simple Kubernetes object:

// main.w
bring k8s;

new k8s.ApiObject(
  apiVersion: "v1",
  kind: "ConfigMap",
  spec: {
    data: {
      key: "value",
    },
  }
);

Now, compile it to YAML:

$ wing compile -t @winglibs/k8s ubuntu.main.w
target/ubuntu.main.k8s

You

The output is a valid K8S YAML is in target/ubuntu.main.k8s:

$ ls target/ubuntu.main.k8s
chart-c86185a7.k8s.yaml

Creating Helm charts

You can set WING_K8S_OUTPUT to helm in order to produce a helm chart instead of simple manifest. This requires a Chart.yaml file next in the current directory.

Default labels and namespace

You can use the WING_K8S_LABELS environment variable to apply labels to all resources in an app. The value is a JSON-encoded map.

The WING_K8S_NAMESPACE variable can be used to specify the default namespace.

export WING_K8S_LABELS='{ "my-label": "123", "your-label": "444" }'
export WING_K8S_NAMESPACE='my-namespace'
wing compile -t @winglibs/k8s main.w

CDK8s Support

This library supports cdk8s and cdk8s-plus, so you can do stuff like this:

npm i cdk8s-plus-27

And then:

bring "cdk8s-plus-27" as k8s;

// lets create a volume that contains our app.
let appData = new k8s.ConfigMap();
appData.addDirectory("./nodejs-app");

let appVolume = k8s.Volume.fromConfigMap(this, "App", appData);

// lets create a deployment to run a few instances of a pod
let deployment = new k8s.Deployment(
  replicas: 3,
);

// now we create a container that runs our app
let appPath = "/var/lib/app";
let port = 80;
let container = deployment.addContainer({
  image: "node:14.4.0-alpine3.12",
  command: ["node", "index.js", "{port}"],
  port: port,
  workingDir: appPath,
});

// make the app accessible to the container
container.mount(appPath, appVolume);

// finally, we expose the deployment as a load balancer service and make it run
deployment.exposeViaService(serviceType: k8s.ServiceType.LOAD_BALANCER);

Roadmap

  • [ ] Support generating Wing bindings from K8S API specifications and CRDs (cdk8s import).

Maintainers

License

This library is licensed under the MIT License.