wy : a set of command-line tools to test your container-based platform

wy

wy (Abbreviation of Would You) is a set of command-line tools to test your container-based platform.

ToC:

Commands

Currently, it provides the following commands:

serve is intended to be run inside containers and Kubernetes pods, so that you can interact with it with wy get and see e.g. Datadog, Prometheus, Grafana dashboards to see if it works.

serve

This comand starts a long-running http server with variouos useful options for testing.

$ wy serve -h
Usage of wy:
  -bind string
        The socket to bind to. (default ":8080")
  -delay-body-first-byte duration
    
  -delay-body-last-byte duration
    
  -delay-header-first-byte duration
    
  -h2c
        Enable h2c (http/2 over tcp) protocol.

get

This command sends a single HTTP GET request against the server.

The default URL is that of wy serve is running locally with the default configuration. If you had customize wy serve options, or it's behind a loadbalancer, set -url accordingly.

$ wy get -h
Usage of wy:
  -print
        Print response body to stdout (default true)
  -url string
        The URL to where send request (default "http://localhost:8080/")

Another use-case of this command is to print all the metrics exposed by the server with the exposition fomrat:

$ wy repeat get -count 5 -url http://localhost:8080
$ wy repeat get -count 10 -url http://localhost:8080/404
$ wy repeat get -count 15 -url http://localhost:8080/500
$ wy get -url http://localhost:8080/metrics
...snip...
# HELP http_requests_total Count of all HTTP requests
# TYPE http_requests_total counter
http_requests_total{code="200",method="get"} 5
http_requests_total{code="404",method="get"} 10
http_requests_total{code="500",method="get"} 15
...snip...

repeat get

This command repeatedly runs wy get so that the server emits more realistic metrics.

$ wy repeat get -h
Usage of repeat:
  -count int
        Number of repetitions (default 5)
  -print
        Print response body to stdout (default true)
  -url string
        The URL to where send request (default "http://localhost:8080/")

Deployment

Technically speaking, wy can be deployment onto any platform based on baremetal or VMs or containers.

That said, I'll show you an example for deploying it onto a Kubernetes cluster.

First, create the deployment YAML using kubectl command:

$ kubectl create deployment --image mumoshu/wy:latest --port=8080 --replicas=1 --dry-run=client -o=yaml wy-serve > wy-serve.yaml
$ echo '---' >> wy-serve.yaml
$ kubectl create service nodeport --node-port=30080 --tcp=8080:8080 --dry-run=client -o=yaml wy-serve >> wy-serve.yaml

Second, update the deployment's template.metadata.annotations so that a metrics agent can scape metrics from the metrics endpoint.

annotations:
  prometheus.io/scrape: "true"

This gives you the following manifest file:

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: wy-serve
  name: wy-serve
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wy-serve
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: wy-serve
      annotations:
        prometheus.io/scrape: "true"
    spec:
      containers:
      - image: mumoshu/wy:latest
        name: wy
        command:
        - /wy
        args:
        - serve
        ports:
        - containerPort: 8080
        resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: wy-serve
  name: wy-serve
spec:
  ports:
  - name: 8080-8080
    nodePort: 30080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: wy-serve
  type: NodePort
status:
  loadBalancer: {}

This is how you'd deploy it:

$ kubectl apply -f wy-serve.yaml

Expose the pods via the NodePort by creating a external loadbalancer. For AWS, you'd use an ALB where the target group is associated to the nodeport of 30080.

Finally, try accessing it to verify that it's actually working or not:

$ wy repeat get -count 5 -url http://$AWS_ALB_HOST:30080/

Monitoring

wy serve exposes various Prometheus metrics via the exposition format. It's just a specifially crafted HTTP endpoint so that it can be easily scraped by Prometheus or other products and services that supports it.

One example of such services is Datadog. Now, let's set it up so that you can view metrics in your Datadog dashboard.

First, install the Datadog agent onto your cluster:

$ helm install datadog datadog/datadog \
  --set datadog.apiKey=$DATADOG_API_KEY \
  --set datadog.site=datadoghq.com \
  --set datadog.clusterName=cluster1 \
  --set datadog.prometheusScrape.enabled=true

Hold on for just dozens of seconds and datadog-agent will be up and running, scraping and forwarding metrics from your wy-serve deployment to Datadog.

Browse Datadog dashboard and see the metrics!

Contributing

We welcome your contribution!

Before submitting your change as a pull request, I'd highly recommend testing it youself.

We provide a few make targets to help that.

First, build a custom docker image with:

$ NAME=$DOCKER_USER/wy make docker-buildx
$ docker push $DOCKER_USER/wy:latest

Second, deploy wy from the custom image:

$ cat wy-serve.yaml | sed "s/mumoshu/$DOCKER_USER/" | kubectl apply -f -

Finally, run wy get against your custom wy-serve pods and see if it's really working as intended.

Related Projects

This project has been inspired by the following projects. Thanks for the authors!

Owner
Yusuke Kuoka
AWS Container Hero / Maintains actions-runner-controller, helmfile, helm-diff, variant 1/2, terraform providers / Wanna be a paid OSS dev someday
Yusuke Kuoka
Similar Resources

Command line tools for creating and compiling JavaScript Minecraft plugins.

@customrealms/cli CustomRealms command-line tools for setting up and compiling JavaScript Minecraft plugins. Installation Install the CLI on your comp

Aug 2, 2022

Command-line tools for the FFS module.

Command-line tools for FFS The blobd tool defines a JSON-RPC service that implements the FFS blob store interface over various underlying key-value st

Dec 14, 2022

A command-line tool and library for generating regular expressions from user-provided test cases

A command-line tool and library for generating regular expressions from user-provided test cases

Table of Contents What does this tool do? Do I still need to learn to write regexes then? Current features How to install? 4.1 The command-line tool 4

Jan 9, 2023

A command line http test tool. Maintain the case via git and pure text

A command line http test tool. Maintain the case via git and pure text

httptest A command line http test tool Maintain the api test cases via git and pure text We want to test the APIs via http requests and assert the res

Dec 16, 2022

Go test command line interface for dlv(delve)

What does it do? Delver makes the command line interface for starting dlv the same as the one used in go test Example Say you're using this when devel

Jan 7, 2022

Beacon-fronting - A simple command line program to help defender test their detections for network beacon patterns and domain fronting

beacon-fronting A simple command line program to help network defenders test the

Oct 1, 2022

Watch your favourite anime using the video player of your choice directly from the command line

anime-cli Watch your favourite anime using the video player of your choice direc

Feb 10, 2022

cross platform command line tool to list, notify and book vaccine using cowin API

Command line tool to List and Book Vaccine cowin-cli is a simple cli tool to book vaccines and list centers using the COWIN API. It also supports auto

Mar 7, 2022

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely.

Dec 31, 2022
Related tags
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
An open-source GitLab command line tool bringing GitLab's cool features to your command line
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Dec 30, 2022
Aces is a command line utility that lets you encode any file to a character set of your choice.

Aces Any Character Encoding Set Aces is a command line utility that lets you encode any file to a character set of your choice. For example, you could

Nov 28, 2022
top in container - Running the original top command in a container
top in container - Running the original top command in a container

Running the original top command in a container will not get information of the container, many metrics like uptime, users, load average, tasks, cpu, memory, are about the host in fact. topic(top in container) will retrieve those metrics from container instead, and shows the status of the container, not the host.

Dec 2, 2022
Jan 3, 2023
Simple activity indicator for your command line tools.
Simple activity indicator for your command line tools.

Simple activity indicator for your command line tools.

Oct 22, 2021
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Dec 22, 2021
A set of Go scripts to monitor YAGPDB status via the command-line.
A set of Go scripts to monitor YAGPDB status via the command-line.

A set of Go scripts to monitor YAGPDB status by making GET requests to the YAGPDB status endpoint.

Apr 20, 2022
Inspect-descriptor-set - Example protobuf descriptor set inspector CLI tool

Quick little example of parsing a protobuf descriptor file. ❯ go run main.go -f

Jan 25, 2022
Basic command line example using golang grpc client tools

This is a basic command line interface that demonstrates using the golang GRPC API. The API is reused between dishy and the wifi router, however both

Jan 3, 2023