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 8ecfbb4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
16 changes: 14 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,21 @@ 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
kubectl wait --for=condition=complete job/kubexporter -n e2e --timeout=300s
- name: Print k8s logs
run: |
echo "## Run Exporter as k8s Job" >> $GITHUB_STEP_SUMMARY
kubectl logs -n e2e kubexporter
45 changes: 45 additions & 0 deletions testdata/e2e/job-with-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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:
spec:
serviceAccountName: read-only-sa
containers:
- name: kubexporter
image: localhost:5001/kubexporter:e2e
args:
- '--progress'
- 'bar'
restartPolicy: Never
backoffLimit: 4

0 comments on commit 8ecfbb4

Please sign in to comment.