-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (102 loc) · 3.63 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: CI
on:
push:
branches: [ main ]
tags:
- "*"
pull_request:
branches: [ main ]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
container:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build container
uses: docker/build-push-action@v5
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build container
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: quay.io/observatorium/namespace-provisioner:test
- name: Setup Kubernetes
uses: helm/kind-action@v1.8.0
with:
cluster_name: e2e
- name: Install namespace-provisioner
run: |
SERVER="$(kubectl config view -o jsonpath='{.clusters[?(@.name == "kind-e2e")].cluster.server}')"
kind load docker-image --name e2e quay.io/observatorium/namespace-provisioner:test
kubectl apply -f manifests/namespace-provisioner.yaml
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: namespace-provisioner
namespace: namespace-provisioner
data:
server: "$SERVER"
ttl: 1h
EOF
kubectl apply -f manifests/example-grants/pods.yaml
kubectl -n namespace-provisioner set image deployment namespace-provisioner namespace-provisioner=quay.io/observatorium/namespace-provisioner:test
kubectl -n namespace-provisioner rollout status deployment namespace-provisioner --timeout 1m
- name: Test namespace-provisioner
run: |
kubectl -n namespace-provisioner port-forward service/namespace-provisioner 8080 &
until lsof -nP -iTCP:8080 -sTCP:LISTEN >/dev/null; do sleep 1; done
curl localhost:8080/api/v1/namespace?ttl=1s -X POST -H "Authorization: bearer PASSWORD" > kubeconfig
kubectl --kubeconfig kubeconfig get pods
sleep 5
[ $(kubectl get ns | grep np- | wc -l) -eq 0 ]
! curl localhost:8080/api/v1/namespace?server=foo -X POST -H "Authorization: bearer PASSWORD" --fail
curl localhost:8080/api/v1/namespace?server=https://example.com -X POST -H "Authorization: bearer PASSWORD" | grep --fixed-strings "server: https://example.com"
- name: Debug failure
if: failure()
run: |
kubectl get -A all
kubectl -n namespace-provisioner logs deploy/namespace-provisioner
push:
if: github.event_name != 'pull_request'
needs:
- container
- e2e
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Determine SHA
id: sha
run: echo "::set-output name=sha::$(git describe --always --tags --dirty)"
- name: Build and push
id: push
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/arm64, linux/amd64
tags: quay.io/observatorium/namespace-provisioner:latest, quay.io/observatorium/namespace-provisioner:${{ steps.sha.outputs.sha }}
- name: Determine digest
run: echo ${{ steps.push.outputs.digest }}