Skip to content

Commit f058c8d

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

File tree

2 files changed

+63
-56
lines changed

2 files changed

+63
-56
lines changed

.github/workflows/integration_tests.yaml

+22-52
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
pull_request_target:
44
types:
55
- labeled
6+
7+
env:
8+
A8R_AGENT_REGISTRY: 'localhost:5000'
9+
610
jobs:
711
build-image:
812
runs-on: ubuntu-latest
@@ -22,69 +26,35 @@ jobs:
2226
uses: actions/setup-go@v3
2327
with:
2428
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
4929
- name: Setup kubectl
5030
uses: azure/setup-kubectl@v3
5131
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'
32+
- name: Provision Kubeception cluster
6133
id: kluster
34+
uses: datawire/infra-actions/[email protected]
6235
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 }}
36+
distribution: Kubeception
37+
version: 1.26
38+
kubeconfig: ${{ env.KUBECONFIG }}
39+
kubeceptionToken: ${{ secrets.DEV_AMBASSADOR_AGENT_KUBECEPTION_TOKEN }}
40+
gke-credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
41+
- name: Build image
42+
id: build
43+
run: |
44+
make push-image
45+
echo "version=$(cat build-output/version.txt)" >> $GITHUB_OUTPUT
6646
- name: Run tests
67-
if: steps.get_last_run.outputs.passed != 'success'
6847
uses: nick-invision/retry@v2
48+
env:
49+
A8R_AGENT_VERSION: ${{ steps.build.outputs.version }}
50+
AMBASSADOR_AGENT_DOCKER_IMAGE: localhost:5000/ambassador-agent:${{ steps.build.outputs.version }}
51+
KAT_SERVER_DOCKER_IMAGE: docker.io/datawiredev/kat-server:3.0.1-0.20220817135951-2cb28ef4f415
6952
with:
7053
max_attempts: 3
7154
timeout_minutes: 15
7255
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
7756
make go-integration-test
57+
- name: Add a private image registry to the cluster
58+
run: make private-registry
7859
- name: Mark test as succesfull
7960
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 k8s/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 &

0 commit comments

Comments
 (0)