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
- Host: GitHub
- URL: https://github.com/stiks/defaultbackend-rest
- Owner: stiks
- License: mit
- Created: 2017-11-28T15:23:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T16:51:09.000Z (over 8 years ago)
- Last Synced: 2025-09-09T21:10:01.671Z (9 months ago)
- Topics: default-backend, go, ingress, kubernetes
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```