-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
178 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
|
||
jobs: | ||
build-and-publish-amd64: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
uses: olegtarasov/[email protected] | ||
id: tagName | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: kubetail/echoserver:${{ steps.tagName.outputs.tag }}-amd64 | ||
|
||
build-and-publish-arm64: | ||
runs-on: arm64-ubuntu-22 | ||
steps: | ||
- name: Get tag name | ||
uses: olegtarasov/[email protected] | ||
id: tagName | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: kubetail/echoserver:${{ steps.tagName.outputs.tag }}-arm64 | ||
|
||
create-and-publish-manifest: | ||
runs-on: ubuntu-latest | ||
needs: [build-and-publish-amd64, build-and-publish-arm64] | ||
steps: | ||
- name: Get tag name | ||
uses: olegtarasov/[email protected] | ||
id: tagName | ||
- name: 'Setup jq' | ||
uses: dcarbone/install-jq-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Create and push manifest | ||
run: | | ||
docker buildx imagetools create -t kubetail/echoserver:${{ steps.tagName.outputs.tag }} \ | ||
kubetail/echoserver:${{ steps.tagName.outputs.tag }}-amd64 \ | ||
kubetail/echoserver:${{ steps.tagName.outputs.tag }}-arm64 | ||
- name: Fetch docker token | ||
run: | | ||
TOKEN=$(curl -X POST "https://hub.docker.com/v2/users/login" -H "Content-Type: application/json" -d '{"username": "${{ secrets.DOCKERHUB_USERNAME }}", "password": "${{ secrets.DOCKERHUB_TOKEN }}"}' | jq -r '.token') | ||
echo "TOKEN=$TOKEN" >> $GITHUB_ENV | ||
- name: Delete extra arch manifests | ||
run: | | ||
declare -a archs=("amd64" "arm64") | ||
for arch in "${archs[@]}" | ||
do | ||
RESPONSE=$(curl -s -w "%{http_code}" \ | ||
-X DELETE \ | ||
-H "Authorization: Bearer $TOKEN" \ | ||
"https://hub.docker.com/v2/repositories/kubetail/echoserver/tags/${{ steps.tagName.outputs.tag }}-$arch") | ||
if [ "$RESPONSE" -ne 204 ]; then | ||
echo "DELETE for $arch failed with status $RESPONSE" | ||
exit 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
# Echoserver | ||
|
||
This is a simple server that responds with the http headers it received. | ||
Image versions >= 1.4 removes the redirect introduced in 1.3. | ||
Image versions >= 1.3 redirect requests on :80 with `X-Forwarded-Proto: http` to :443. | ||
Image versions > 1.0 run an nginx server, and implement the echoserver using lua in the nginx config. | ||
Image versions <= 1.0 run a python http server instead of nginx, and don't redirect any requests. | ||
This is a fork of the enigmatic `k8s.gcr.io/echoserver` image, designed to run on amd64 and arm64 architecture. | ||
|
||
## Introduction | ||
|
||
The `k8s.gcr.io/echoserver` image is very useful but unfortunately it's not available for [arm64 architecture](https://github.com/kubernetes-retired/contrib/issues/2991). In addition, we couldn't find the source code online so we dug into the image files, copied the nginx config and created this fork to make an `echoserver` that's more transparent and available across architectures. | ||
|
||
Echoserver, uses a lua script running inside Nginx to respond to HTTP requests on port 8080 and HTTPS requests on port 8443. On start-up, it creates a self-signed certificate for the ssl listener. | ||
|
||
## Install | ||
|
||
Here's a manifest you can use to run an echoserver deployment on kubernetes: | ||
|
||
```yaml | ||
kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: echoserver | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: echoserver | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: echoserver | ||
replicas: 3 | ||
revisionHistoryLimit: 5 | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: echoserver | ||
spec: | ||
containers: | ||
- name: echoserver | ||
image: kubetail/echoserver:0.0.1 | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
- name: https | ||
containerPort: 8443 | ||
``` | ||
## Build | ||
```console | ||
docker build -t echoserver:latest . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
CERT_DIR=/certs | ||
CERT_FILE=$CERT_DIR/certificate.crt | ||
KEY_FILE=$CERT_DIR/privateKey.key | ||
|
||
# Check if certificate and key files exist, if not, create them | ||
if [ ! -f "$CERT_FILE" ] || [ ! -f "$KEY_FILE" ]; then | ||
#echo "Generating self-signed cert" | ||
#echo "Generating a 2048 bit RSA private key" | ||
mkdir -p $CERT_DIR | ||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $KEY_FILE -out $CERT_FILE -subj "/C=US/ST=State/L=City/O=Organization/OU=OrgUnit/CN=localhost" -verbose | ||
#echo "writing new private key to '${KEY_FILE}'" | ||
fi | ||
|
||
# Start your application here, e.g., for a Node.js app | ||
# node /path/to/your/app.js | ||
echo "Starting nginx" | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters