donkeyx/cluster-utils-api

By donkeyx

Updated about 2 years ago

Simple docker image to allow testing within clusters or locally and provides endpoints for debugging

Image
Networking
Developer tools
1

50K+

donkeyx/cluster-utils-api repository overview

cluster-utils-api

description

Simple docker image to allow testing within clusters or locally. It provides me an api as the base which will run with an entrypoint of node/npm/cu-api and still run the base expected binary. This is great for testing that "your" api might be routable with istio or other meshes, without having to worry about issues with the api its self. It also allows me to deploy and verify routing, check headers and other things like verifying env parameters are exposed to the container.

Default route is json response with environment variables, with more to come...

dockerhub: https://hub.docker.com/repository/docker/donkeyx/cluster-utils-api github: https://github.com/donkeyx/cluster-utils-api

Usage

Start container:
docker run -d -p 8080:8080 --name test-api donkeyx/cluster-utils-api:latest

curl -sS localhost:8080/help|jq
{
  "/": "This can be used to redirect to the swagger docs",
  "/a/env": "GET",
  "/debug": "GET",
  "/headers": "GET",
  "/health": "GET",
  "/healthz": "GET",
  "/ping": "GET",
  "/ready": "GET",
  "/readyz": "GET"
}
run image in k8 cluster:

You can run the pod in your cluster with the commands below. This will start a deployment and service called cluster-utils-api but limited to cluster ip. If you want to expose with type loadbalancer you can do it yourself, I don't want you to get a bill from this.

apply the manifest to create the pod and service

# apply pod config with default 30min timeout
kubectl -n default \
    apply -f https://raw.githubusercontent.com/donkeyx/cluster-utils-api/master/k8s-cluster-util-apis.yml

list the created pod and service.

# list the pod and service which shows
$ kubectl get pods,svc -n default
NAME                                     READY   STATUS    RESTARTS   AGE
pod/cluster-utils-api-6c5999df88-wssg6   1/1     Running   0          14m

NAME                        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/cluster-utils-api   ClusterIP   10.114.3.0   <none>        80/TCP    14m
service/kubernetes          ClusterIP   10.114.0.1   <none>        443/TCP   99d
...

Now you can use port forwarding to curl your apis inside the cluster

# in one windows forward the ports to the service
$ kubectl -n default port-forward svc/cluster-utils-api 8080:80

# then curl the service -> pod
curl -sS localhost:8080/debug|jq
{
  "Headers": {
    "Accept": [
      "*/*"
    ],
    "User-Agent": [
      "curl/7.68.0"
    ]
  },
  "Hostname": "DESKTOP-V9N2U1D",
  "RequestURI": "/debug",
  "SourceIP": "127.0.0.1",
  "UserAgent": "curl/7.68.0"
}

Tag summary

Content type

Image

Digest

sha256:d96a1826d

Size

35.6 MB

Last updated

about 2 years ago

docker pull donkeyx/cluster-utils-api