Skip to content

Commit a28a391

Browse files
committed
BUG/MEDIUM: do not pull echo image from dockerhub, build it locally
Signed-off-by: Zlatko Bratkovic <[email protected]>
1 parent f0e5688 commit a28a391

File tree

22 files changed

+295
-32
lines changed

22 files changed

+295
-32
lines changed

.gitlab-ci.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ unit-tests:
8585
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY_GO
8686
script:
8787
- go version
88+
- docker pull $CI_REGISTRY_GO/alpine:3
89+
- docker image tag $CI_REGISTRY_GO/alpine:3 alpine:3
90+
- docker pull $CI_REGISTRY_GO/golang:1.17-alpine
91+
- docker image tag $CI_REGISTRY_GO/golang:1.17-alpine golang:1.17-alpine
8892
- wget -q -o /dev/null -O &> /dev/null /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND}/kind-linux-amd64
8993
- chmod +x /usr/local/bin/kind
9094
- wget -q -o /dev/null -O &> /dev/null /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL}/bin/linux/amd64/kubectl
@@ -97,26 +101,33 @@ unit-tests:
97101
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "$HOME/.kube/config"
98102
- sed -i -E -e "s/localhost|0\.0\.0\.0|127\.0\.0\.1/docker/g" "deploy/tests/e2e/client.go"
99103
- until kubectl get nodes -o wide;do sleep 2; done
104+
- kubectl get pods -A
100105
- CI_ENV=gitlab deploy/tests/create.sh
106+
- kubectl get pods -A
101107
- KIND_URL=docker CGO_ENABLED=0 go test -v ./deploy/tests/e2e/... --tags=e2e_parallel
102108
- KIND_URL=docker CGO_ENABLED=0 go test -v -p 1 ./deploy/tests/e2e/... --tags=e2e_sequential
103109
after_script:
110+
- kubectl get pods -A
104111
- kind delete cluster --name=dev
105112
only:
106113
- merge_requests
107114
- branches
108-
k8s_19:
115+
.kind_deployment_schedules:
109116
only:
110117
- schedules
118+
extends: .kind_deployment
119+
k8s_18:
120+
variables:
121+
K8S_VERSION: v1.18.19
122+
extends: .kind_deployment_schedules
123+
k8s_19:
111124
variables:
112125
K8S_VERSION: v1.19.11
113-
extends: .kind_deployment
126+
extends: .kind_deployment_schedules
114127
k8s_20:
115-
only:
116-
- schedules
117128
variables:
118129
K8S_VERSION: v1.20.7
119-
extends: .kind_deployment
130+
extends: .kind_deployment_schedules
120131
k8s_21:
121132
variables:
122133
K8S_VERSION: v1.21.1

deploy/tests/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This will also deploy the HAProxy Ingress Controller using config in `deploy/tes
2727
kubectl apply -f ./config/echo-app.yaml
2828
```
2929

30-
Deploys [http-echo](https://github.com/Mo3m3n/http-echo) as a test application.
30+
Deploys `haproxytech/http-echo` as a test application.
3131

3232
```bash
3333
curl --header "Host: echo.haproxy.local" 127.0.0.1:30080
@@ -41,22 +41,22 @@ Response will include a couple of useful information:
4141
### E2E tests
4242

4343
```bash
44-
go test -v --tags=<tag_name> ./e2e/...
44+
go test -v --tags=<tag_name> ./e2e/...
4545
```
4646

47-
This will run all e2e tests in `./e2e` directory tagged with `<tag_name>`.
47+
This will run all e2e tests in `./e2e` directory tagged with `<tag_name>`.
4848
There are two available tags:
49-
- **e2e_parallel**: which will run tests in parallel
49+
- **e2e_parallel**: which will run tests in parallel
5050
- **e2e_sequential**: which will run tests in sequence
5151

5252
Currently two tests are run sequentially:
5353
- endpoints: in order to test endpoints scaling without reloading haproxy.
5454
- tls-auth: tls authentication is a global config that will impact other tests running in parallel.
5555

56-
Each E2E test runs in its **own Namespace** and has its own directory.
57-
Tests are deployed by applying yaml files or/and templates from the `config` directory of the corresponding test.
58-
When using yaml templates, the generated yaml files are stored in a temporary directory in `/tmp/`.
59-
Using `--dev` option will keep generated files after test execution.
56+
Each E2E test runs in its **own Namespace** and has its own directory.
57+
Tests are deployed by applying yaml files or/and templates from the `config` directory of the corresponding test.
58+
When using yaml templates, the generated yaml files are stored in a temporary directory in `/tmp/`.
59+
Using `--dev` option will keep generated files after test execution.
6060
Example:
6161
```bash
6262
go test -v --tags=e2e_sequential --dev ./e2e/endpoints/

deploy/tests/config/echo-app.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ spec:
1414
spec:
1515
containers:
1616
- name: http-echo
17-
image: 'mo3m3n/http-echo:v1.0.0'
17+
image: 'haproxytech/http-echo:latest'
18+
imagePullPolicy: Never
1819
ports:
1920
- name: http
2021
containerPort: 8888

deploy/tests/create.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ else
3131
kind load docker-image haproxytech/kubernetes-ingress:latest --name=$clustername
3232
fi
3333

34+
docker build --build-arg TARGETPLATFORM="linux/amd64" -t haproxytech/http-echo -f deploy/tests/images/http-echo/Dockerfile deploy/tests/images/http-echo
35+
echo "loading image http-echo in kind"
36+
kind load docker-image haproxytech/http-echo:latest --name=$clustername
37+
3438
echo "deploying Ingress Controller ..."
3539
kubectl apply -f $DIR/config/0.namespace.yaml
3640
kubectl apply -f $DIR/config/1.default-backend.yaml

deploy/tests/e2e/basic-auth/config/deploy.yaml.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ spec:
2727
spec:
2828
containers:
2929
- name: http-echo
30-
image: mo3m3n/http-echo:v1.0.0
30+
image: haproxytech/http-echo:latest
31+
imagePullPolicy: Never
3132
args:
3233
- --default-response=hostname
3334
ports:
@@ -71,4 +72,4 @@ spec:
7172
- path: /
7273
backend:
7374
serviceName: http-echo
74-
servicePort: http
75+
servicePort: http

deploy/tests/e2e/canary-deployment/config/deploy.yaml.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ spec:
1717
spec:
1818
containers:
1919
- name: http-echo-prod
20-
image: mo3m3n/http-echo:v1.0.0
20+
image: haproxytech/http-echo:latest
21+
imagePullPolicy: Never
2122
args:
2223
- --default-response=hostname
2324
ports:
@@ -56,7 +57,8 @@ spec:
5657
spec:
5758
containers:
5859
- name: http-echo-staging
59-
image: mo3m3n/http-echo:v1.0.0
60+
image: haproxytech/http-echo:latest
61+
imagePullPolicy: Never
6062
args:
6163
- --default-response=hostname
6264
ports:

deploy/tests/e2e/config-snippet/config/deploy.yaml.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ spec:
1515
spec:
1616
containers:
1717
- name: http-echo
18-
image: mo3m3n/http-echo:v1.0.0
18+
image: haproxytech/http-echo:latest
19+
imagePullPolicy: Never
1920
args:
2021
ports:
2122
- name: http

deploy/tests/e2e/endpoints/config/endpoints.yaml.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ spec:
1111
spec:
1212
containers:
1313
- name: http-echo
14-
image: mo3m3n/http-echo:v1.0.0
14+
image: haproxytech/http-echo:latest
15+
imagePullPolicy: Never
1516
args:
1617
- --default-response=hostname
1718
ports:

deploy/tests/e2e/https/config/deploy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ spec:
1515
spec:
1616
containers:
1717
- name: http-echo
18-
image: mo3m3n/http-echo:v1.0.0
18+
image: haproxytech/http-echo:latest
19+
imagePullPolicy: Never
1920
args:
2021
ports:
2122
- name: http

deploy/tests/e2e/ingress-match/config/deploy.yaml.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ spec:
1616
spec:
1717
containers:
1818
- name: http-echo-{{$i}}
19-
image: mo3m3n/http-echo:v1.0.0
19+
image: haproxytech/http-echo:latest
20+
imagePullPolicy: Never
2021
args:
2122
- --default-response=hostname
2223
ports:

deploy/tests/e2e/ingressclass/config/deploy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ spec:
1313
spec:
1414
containers:
1515
- name: http-echo
16-
image: mo3m3n/http-echo:v1.0.0
16+
image: haproxytech/http-echo:latest
17+
imagePullPolicy: Never
1718
args:
1819
- --default-response=hostname
1920
ports:

deploy/tests/e2e/rate-limiting/config/deploy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ spec:
1616
spec:
1717
containers:
1818
- name: http-echo
19-
image: mo3m3n/http-echo:v1.0.0
19+
image: haproxytech/http-echo:latest
20+
imagePullPolicy: Never
2021
args:
2122
- --default-response=hostname
2223
ports:

deploy/tests/e2e/service-discovery/config/deploy.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ spec:
1515
spec:
1616
containers:
1717
- name: http-echo-1
18-
image: mo3m3n/http-echo:v1.0.0
18+
image: haproxytech/http-echo:latest
19+
imagePullPolicy: Never
1920
args:
2021
- --default-response=hostname
2122
ports:
@@ -55,7 +56,8 @@ spec:
5556
spec:
5657
containers:
5758
- name: http-echo-2
58-
image: mo3m3n/http-echo:v1.0.0
59+
image: haproxytech/http-echo:latest
60+
imagePullPolicy: Never
5961
args:
6062
- --default-response=hostname
6163
ports:

deploy/tests/e2e/set-header/config/deploy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ spec:
1414
spec:
1515
containers:
1616
- name: http-echo
17-
image: mo3m3n/http-echo:v1.0.0
17+
image: haproxytech/http-echo:latest
18+
imagePullPolicy: Never
1819
args:
1920
ports:
2021
- name: http

deploy/tests/e2e/source-ip/config/deploy.yaml.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ spec:
1515
spec:
1616
containers:
1717
- name: http-echo
18-
image: mo3m3n/http-echo:v1.0.0
18+
image: haproxytech/http-echo:latest
19+
imagePullPolicy: Never
1920
args:
2021
- --default-response=hostname
2122
ports:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM golang:1.17-alpine AS builder
2+
3+
COPY *.go /src/
4+
COPY go.mod /src/go.mod
5+
6+
RUN cd /src && go build -o echo-http
7+
8+
FROM alpine:3
9+
RUN apk --no-cache add openssl
10+
WORKDIR /app
11+
COPY --from=builder /src/echo-http .
12+
COPY generate-cert.sh .
13+
RUN chmod +x generate-cert.sh
14+
15+
ENTRYPOINT ["./echo-http"]
16+
CMD []
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# http-echo
2+
3+
A simple golang HTTP/S server that echoes back request attributes to the client in JSON formats.
4+
By default the certificate CN is the hostname of the machine where the program is running.
5+
6+
## How to use
7+
8+
```bash
9+
docker build -t haproxytech/http-echo -f deploy/tests/images/http-echo/Dockerfile deploy/tests/images/http-echo
10+
docker run -p 8888:80 -p 8443:443 --rm -t haproxytech/http-echo
11+
```
12+
13+
## Output example
14+
15+
```bash
16+
curl -b "test=bar" -k https://localhost:8443/path\?a\=foo1\&b\=foo2
17+
````
18+
```json
19+
{
20+
"http": {
21+
"cookies": [
22+
"test=bar"
23+
],
24+
"headers": {
25+
"Accept": "*/*",
26+
"Cookie": "test=bar",
27+
"User-Agent": "curl/7.70.0"
28+
},
29+
"host": "localhost:8443",
30+
"method": "GET",
31+
"path": "/path",
32+
"protocol": "HTTP/2.0",
33+
"query": "a=foo1\u0026b=foo2",
34+
"raw": "GET /path?a=foo1\u0026b=foo2 HTTP/1.1\r\nHost: localhost:8443\r\nUser-Agent: curl/7.70.0\r\nAccept: */*\r\nCookie: test=bar\r\n\r\n"
35+
},
36+
"os": {
37+
"hostname": "traktour"
38+
},
39+
"tcp": {
40+
"ip": "[::1]",
41+
"port": "53364"
42+
},
43+
"tls": {
44+
"cipher": "TLS_AES_128_GCM_SHA256",
45+
"sni": "localhost"
46+
}
47+
}
48+
```
49+
50+
51+
## Credits
52+
53+
[mendhak/docker-http-https-echo](https://github.com/mendhak/docker-http-https-echo)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /bin/sh
2+
3+
set -e
4+
if [ -z $SUBJECT ];
5+
then
6+
SUBJECT="/C=FR/L=PARIS/O=Echo HTTP/CN=$(hostname)"
7+
fi
8+
openssl req -x509 -nodes -days 365 \
9+
-newkey rsa:2048 \
10+
-keyout server.key \
11+
-out server.crt \
12+
-subj "$SUBJECT"

deploy/tests/images/http-echo/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module echo-http
2+
3+
go 1.17

0 commit comments

Comments
 (0)