Skip to content

Commit f1efc5f

Browse files
committed
Use private registry for CI tests.
Signed-off-by: Thomas Hallgren <[email protected]>
1 parent 6955feb commit f1efc5f

File tree

3 files changed

+92
-57
lines changed

3 files changed

+92
-57
lines changed

.github/workflows/integration_tests.yaml

+24-53
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ on:
33
pull_request_target:
44
types:
55
- labeled
6+
7+
env:
8+
A8R_AGENT_REGISTRY: 'localhost:5000'
9+
KUBECONFIG: ${{ github.workspace }}/kubeconfig.yaml
10+
611
jobs:
712
build-image:
813
runs-on: ubuntu-latest
@@ -22,69 +27,35 @@ jobs:
2227
uses: actions/setup-go@v3
2328
with:
2429
go-version: stable
25-
- name: Build image
26-
run: |
27-
make image-tar
28-
- name: Upload image
29-
uses: actions/upload-artifact@v3
30-
with:
31-
name: image
32-
path: build-output/ambassador-agent-image.tar
33-
test:
34-
runs-on: ubuntu-latest
35-
needs: build-image
36-
steps:
37-
- name: Checkout
38-
uses: actions/checkout@v3
39-
with:
40-
fetch-depth: 0
41-
ref: "${{ github.event.pull_request.head.sha }}"
42-
- name: Get last run
43-
uses: ./.github/actions/rerun-cache
44-
id: get_last_run
45-
- name: Setup Go
46-
uses: actions/setup-go@v3
47-
with:
48-
go-version: stable
4930
- name: Setup kubectl
5031
uses: azure/setup-kubectl@v3
5132
id: kubectl
52-
if: steps.get_last_run.outputs.passed != 'success'
53-
- name: Download image
54-
uses: actions/download-artifact@v3
55-
if: steps.get_last_run.outputs.passed != 'success'
56-
with:
57-
name: image
58-
- name: Prepare kluster
59-
uses: ./.github/actions/prepare-kluster
60-
if: steps.get_last_run.outputs.passed != 'success'
33+
- name: Provision Kubeception cluster
6134
id: kluster
62-
with:
63-
token: ${{ secrets.DEV_AMBASSADOR_AGENT_KUBECEPTION_TOKEN }}
64-
image-tar: ambassador-agent-image.tar
65-
github-sha: ${{ github.event.pull_request.head.sha }}
35+
uses: datawire/infra-actions/[email protected]
36+
with:
37+
distribution: Kubeception
38+
version: 1.26
39+
kubeconfig: ${{ env.KUBECONFIG }}
40+
kubeceptionToken: ${{ secrets.DEV_AMBASSADOR_AGENT_KUBECEPTION_TOKEN }}
41+
gkeCredentials: '{"project_id": "foo"}'
42+
- name: Add a private image registry to the cluster
43+
run: make private-registry
44+
- name: Build image
45+
id: build
46+
run: |
47+
make push-image
48+
echo "version=$(cat build-output/version.txt)" >> $GITHUB_OUTPUT
6649
- name: Run tests
67-
if: steps.get_last_run.outputs.passed != 'success'
6850
uses: nick-invision/retry@v2
51+
env:
52+
A8R_AGENT_VERSION: ${{ steps.build.outputs.version }}
53+
AMBASSADOR_AGENT_DOCKER_IMAGE: localhost:5000/ambassador-agent:${{ steps.build.outputs.version }}
54+
KAT_SERVER_DOCKER_IMAGE: docker.io/datawiredev/kat-server:3.0.1-0.20220817135951-2cb28ef4f415
6955
with:
7056
max_attempts: 3
7157
timeout_minutes: 15
7258
command: |
73-
export DTEST_KUBECONFIG=${{ steps.kluster.outputs.kubeconfig }}
74-
export KUBECONFIG=${{ steps.kluster.outputs.kubeconfig }}
75-
export AMBASSADOR_AGENT_DOCKER_IMAGE=datawiredev/ambassador-agent:dev-latest
76-
export KAT_SERVER_DOCKER_IMAGE=docker.io/datawiredev/kat-server:3.0.1-0.20220817135951-2cb28ef4f415
7759
make go-integration-test
7860
- name: Mark test as succesfull
7961
run: echo "::set-output name=run_result::success" > run_result
80-
- name: Cleanup kluster
81-
uses: ./.github/actions/cleanup-kluster
82-
if: always()
83-
with:
84-
token: ${{ secrets.DEV_AMBASSADOR_AGENT_KUBECEPTION_TOKEN }}
85-
github-sha: ${{ github.event.pull_request.head.sha }}
86-
87-
88-
89-
90-

Makefile

+41-4
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ push-ximage: image
106106
docker buildx build --build-arg A8R_AGENT_VERSION=$(A8R_AGENT_VERSION) --push --platform=linux/amd64,linux/arm64 --tag=$(IMAGE) .
107107

108108
.PHONY: push-image
109-
push-image: image
109+
push-image:
110110
if docker pull $(IMAGE); then \
111111
printf "Failure: Tag already exists\n"; \
112112
exit 1; \
113113
fi
114+
mkdir -p $(BUILDDIR)
115+
echo $(IMAGE_VERSION) > $(BUILDDIR)/version.txt
114116
docker build --build-arg A8R_AGENT_VERSION=$(A8R_AGENT_VERSION) --tag=$(IMAGE) .
115117
docker push $(IMAGE)
116118

@@ -130,10 +132,45 @@ go-unit-test:
130132
go test ./cmd/... -race
131133
go test ./pkg/... -race
132134

135+
TOOLSDIR = tools
136+
137+
tools/helm = $(TOOLSDIR)/bin/helm
138+
HELM_VERSION=$(shell go mod edit -json | jq -r '.Require[] | select (.Path == "helm.sh/helm/v3") | .Version')
139+
HELM_TGZ = https://get.helm.sh/helm-$(HELM_VERSION)-$(GOHOSTOS)-$(GOHOSTARCH).tar.gz
140+
$(BUILDDIR)/$(notdir $(HELM_TGZ)):
141+
mkdir -p $(@D)
142+
curl -sfL $(HELM_TGZ) -o $@
143+
144+
%/helm: $(BUILDDIR)/$(notdir $(HELM_TGZ))
145+
mkdir -p $(@D)
146+
tar -C $(@D) -zxmf $< --strip-components=1 $(GOHOSTOS)-$(GOHOSTARCH)/helm
147+
148+
# Ensure that the Helm repo index is up to date
149+
HELM_REPO_NAME ?= datawire
150+
HELM_REPO_URL ?= https://app.getambassador.io
151+
152+
$(BUILDDIR)/.helm-update-ts: $(tools/helm)
153+
mkdir -p $(BUILDDIR)
154+
$(tools/helm) repo add --force-update $(HELM_REPO_NAME) $(HELM_REPO_URL)
155+
$(tools/helm) repo update
156+
touch $@
157+
133158
.PHONY: apply
134-
apply: push-image
135-
helm install ambassador-agent ./helm/ambassador-agent -n ambassador --set image.fullImageOverride=$(IMAGE) --set logLevel=DEBUG --set cloudConnectToken=$(APIKEY)
159+
apply: push-image $(tools/helm)
160+
$(tools/helm) install ambassador-agent ./helm/ambassador-agent -n ambassador --set image.fullImageOverride=$(IMAGE) --set logLevel=DEBUG --set cloudConnectToken=$(APIKEY)
136161

137162
.PHONY: delete
138163
delete:
139-
helm delete ambassador-agent -n ambassador
164+
$(tools/helm) delete ambassador-agent -n ambassador
165+
166+
.PHONY: private-registry
167+
private-registry: $(tools/helm) ## (Test) Add a private docker registry to the current k8s cluster and make it available on localhost:5000.
168+
mkdir -p $(BUILDDIR)
169+
$(tools/helm) repo add twuni https://helm.twun.io
170+
$(tools/helm) repo update
171+
$(tools/helm) install --set image.tag=2.8.1,configData.storage.cache.blobdescriptor=inmemory,configData.storage.cache.blobdescriptorsize=10000 docker-registry twuni/docker-registry
172+
kubectl apply -f build-aux/private-reg-proxy.yaml
173+
kubectl rollout status -w daemonset/private-registry-proxy
174+
sleep 5
175+
kubectl wait --for=condition=ready pod --all
176+
kubectl port-forward daemonset/private-registry-proxy 5000:5000 &

build-aux/private-reg-proxy.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: private-registry-proxy
5+
labels:
6+
app: private-registry-proxy
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: private-registry-proxy
11+
template:
12+
metadata:
13+
labels:
14+
app: private-registry-proxy
15+
spec:
16+
containers:
17+
- name: tcp-proxy
18+
image: quay.io/bentoml/proxy-to-service:v2
19+
args:
20+
- tcp
21+
- "5000"
22+
- docker-registry.default.svc.cluster.local
23+
ports:
24+
- containerPort: 5000
25+
hostPort: 5000
26+
name: tcp
27+
protocol: TCP

0 commit comments

Comments
 (0)