https://github.com/tankibaj/httpenv
A very simple docker image serving environment variables over HTTP.
https://github.com/tankibaj/httpenv
Last synced: 5 months ago
JSON representation
A very simple docker image serving environment variables over HTTP.
- Host: GitHub
- URL: https://github.com/tankibaj/httpenv
- Owner: tankibaj
- Created: 2021-04-23T19:46:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-17T11:01:28.000Z (almost 4 years ago)
- Last Synced: 2025-02-17T21:36:48.989Z (8 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A very simple image serving environment variables over HTTP. I use this image to test kubernetes ClusterIP service.
## Quick Start
### Docker
- Run docker container and expose port
```bash
docker run --rm -p8888:8888 thenaim/httpenv
```
- Test endpoint
```bash
curl http://localhost:8888
curl http://localhost:8888/blue
curl http://localhost:8888/green
curl http://localhost:8888/red
```
### Kubernetes
#### Create deployment and service
- In another window, watch the pods (to see when they are created):
```bash
kubectl get pods -w
```
- Create a deployment for this very lightweight HTTP server:
```bash
kubectl create deployment httpenv --image=thenaim/httpenv
```
- Scale it to 10 replicas:
```bash
kubectl scale deployment httpenv --replicas=10
```
- Expose the HTTP port of our server. We'll create a default ClusterIP service
```bash
kubectl expose deployment httpenv --port 8888
```
- Look up which IP address was allocated:
```bash
kubectl get service
```
#### Test endpoint
- Let's obtain the IP address that was allocated for our service:
```bash
IP=$(kubectl get svc httpenv -o go-template --template '{{ .spec.clusterIP }}')
```
- Generate URL
```bash
echo http://$IP:8888/
```- Run Busybox to access ClusterIP
```bash
kubectl run busybox --image=radial/busyboxplus:curl -i --tty
```- Send a few requests:
```bash
curl http://$IP:8888/
```
- Too much output? Filter it with jq:
```bash
curl -s http://$IP:8888/ | jq .HOSTNAME
```
- Others
```bash
curl http://$IP:8888/blue
curl http://$IP:8888/green
curl http://$IP:8888/red
```