Skip to content

Commit

Permalink
start in pod
Browse files Browse the repository at this point in the history
  • Loading branch information
bakito committed Oct 31, 2024
1 parent 009254f commit 9d71029
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
# https://hub.docker.com/r/kindest/node/tags
k8s_version: [ "v1.28.13", "v1.29.8", "v1.30.4" ]
k8s_version: ["v1.28.13", "v1.29.8", "v1.30.4"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,9 +30,22 @@ jobs:
kubectl_version: ${{ matrix.k8s_version }}

- name: Run Exporter from outside the cluster
run: go run . --config config.yaml --progress bar >> $GITHUB_STEP_SUMMARY
run: |
echo "## Run Exporter from outside the cluster" >> $GITHUB_STEP_SUMMARY
go run . --config config.yaml --progress bar >> $GITHUB_STEP_SUMMARY
- name: Build the docker image
run: |
docker build -f Dockerfile --build-arg VERSION=e2e-tests -t localhost:5001/kubexporter:e2e .
docker push localhost:5001/kubexporter:e2e
- name: Run Exporter as k8s Job
run: |
kubectl create ns e2e
kubectl apply -n e2e -f testdata/e2e/job-with-rbac.yaml
echo "Waiting for Job to be terminated"
kubectl wait --for=condition=complete job/kubexporter -n e2e --timeout=30s
- name: Print k8s logs
run: |
echo "## Run Exporter as k8s Job" >> $GITHUB_STEP_SUMMARY
kubectl logs -n e2e -l e2e=kubexporter --tail=10000 >> $GITHUB_STEP_SUMMARY
48 changes: 48 additions & 0 deletions testdata/e2e/job-with-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: read-only-sa
namespace: e2e
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cluster-read-only
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: read-only-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-read-only
subjects:
- kind: ServiceAccount
name: read-only-sa
namespace: e2e
---
apiVersion: batch/v1
kind: Job
metadata:
name: kubexporter
namespace: e2e
spec:
template:
metadata:
labels:
e2e: kubexporter
spec:
serviceAccountName: read-only-sa
containers:
- name: kubexporter
image: localhost:5001/kubexporter:e2e
args:
- '--progress'
- 'bar'
restartPolicy: Never
backoffLimit: 1

0 comments on commit 9d71029

Please sign in to comment.