An open API service indexing awesome lists of open source software.

https://github.com/stiks/defaultbackend-rest

Kubernetes Default Backend REST
https://github.com/stiks/defaultbackend-rest

default-backend go ingress kubernetes

Last synced: 25 days ago
JSON representation

Kubernetes Default Backend REST

Awesome Lists containing this project

README

          

# Default Backend Server

This is a simple webserver that satisfies the ingress, which means it has to do two things:

1. Serves a 404 page at `/`
2. Serves 200 on a `/healthz`

Server respond JSON instead of plain text

Not found page:
```
$ curl http://localhost:8080
{"code":404,"message":"Not found"}
```

Status page:

```
$ curl http://localhost:8080/healthz
{"status":"ok"}
```

## Why?!

In my projects, it's important that alive server respond JSON, even if this is default backend server. This image is only 2mb which is extreamly small compare to others custom error images.

Also I personally think JSON response looks better than html error without formatting

Example usage:
```
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: default-http-backend
labels:
app: default-http-backend
namespace: ingress-nginx
spec:
replicas: 1
template:
metadata:
labels:
app: default-http-backend
spec:
terminationGracePeriodSeconds: 60
containers:
- name: default-http-backend
image: stiks/defaultbackend-rest:1.0
livenessProbe:
httpGet:
path: /healthz
port: 8080
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 5
ports:
- containerPort: 8080
resources:
limits:
cpu: 10m
memory: 20Mi
requests:
cpu: 10m
memory: 20Mi
---
apiVersion: v1
kind: Service
metadata:
name: default-http-backend
namespace: ingress-nginx
labels:
app: default-http-backend
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: default-http-backend
```