Skip to content

Commit 3ba3846

Browse files
committed
Github actions for build/release
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
1 parent f729b5d commit 3ba3846

File tree

9 files changed

+1161
-62
lines changed

9 files changed

+1161
-62
lines changed

.github/workflows/build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build Container Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build:
17+
name: Build Multi-Platform Image
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version-file: go.mod
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Login to GitHub Container Registry
32+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ghcr.io/${{ github.repository_owner }}/kubevirt-rbac-webhook
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=pr
47+
type=sha,prefix={{branch}}-
48+
49+
- name: Build multi-platform image (PR)
50+
if: github.event_name == 'pull_request'
51+
uses: docker/build-push-action@v5
52+
with:
53+
context: .
54+
platforms: linux/amd64,linux/arm64
55+
push: false
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
61+
- name: Build and push multi-platform image (main)
62+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: .
66+
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
67+
push: true
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max
72+
73+
- name: Test build-installer target
74+
run: |
75+
make build-installer IMG=ghcr.io/${{ github.repository_owner }}/kubevirt-rbac-webhook:test
76+
77+
- name: Validate install.yaml
78+
run: |
79+
# Check that install.yaml was generated
80+
test -f dist/install.yaml
81+
82+
# Check that it contains expected resources
83+
grep -q "kind: Namespace" dist/install.yaml
84+
grep -q "kind: ClusterRole" dist/install.yaml
85+
grep -q "kind: ValidatingWebhookConfiguration" dist/install.yaml
86+
grep -q "kind: Deployment" dist/install.yaml
87+
grep -q "kubevirt.io:vm-full-admin" dist/install.yaml
88+
grep -q "kubevirt.io:vm-storage-admin" dist/install.yaml
89+
90+
echo "✅ install.yaml validation passed"
91+
92+
- name: Upload install.yaml artifact
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: install-yaml-${{ github.sha }}
96+
path: dist/install.yaml
97+
retention-days: 30

.github/workflows/release.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
name: Create Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Login to GitHub Container Registry
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Extract version from tag
38+
id: version
39+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
40+
41+
- name: Build and push multi-platform image
42+
run: |
43+
make docker-buildx IMG=ghcr.io/${{ github.repository_owner }}/kubevirt-rbac-webhook:${{ steps.version.outputs.VERSION }}
44+
make docker-buildx IMG=ghcr.io/${{ github.repository_owner }}/kubevirt-rbac-webhook:latest
45+
46+
- name: Generate install.yaml
47+
run: |
48+
make build-installer IMG=ghcr.io/${{ github.repository_owner }}/kubevirt-rbac-webhook:${{ steps.version.outputs.VERSION }}
49+
50+
- name: Create Release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
files: |
54+
dist/install.yaml
55+
body: |
56+
## KubeVirt RBAC Webhook ${{ steps.version.outputs.VERSION }}
57+
58+
### Installation
59+
60+
Install with a single command:
61+
```bash
62+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/install.yaml
63+
```
64+
65+
Or install the latest version:
66+
```bash
67+
kubectl apply -f https://github.com/${{ github.repository }}/releases/latest/download/install.yaml
68+
```
69+
70+
### Prerequisites
71+
72+
- Kubernetes cluster (v1.28+)
73+
- KubeVirt installed
74+
- cert-manager installed (for webhook TLS certificates)
75+
76+
### What's Included
77+
78+
- ✅ ValidatingWebhookConfiguration
79+
- ✅ Fine-grained ClusterRoles for VM management
80+
- ✅ Webhook deployment with TLS
81+
- ✅ RBAC permissions
82+
- ✅ Service and networking configuration
83+
84+
### Quick Start
85+
86+
1. **Install cert-manager** (if not already installed):
87+
```bash
88+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml
89+
kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=cert-manager -n cert-manager --timeout=60s
90+
```
91+
92+
2. **Install the webhook**:
93+
```bash
94+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/install.yaml
95+
```
96+
97+
3. **Verify the installation**:
98+
```bash
99+
# Check webhook pod
100+
kubectl get pods -n kubevirt-rbac-webhook-system
101+
102+
# Check ClusterRoles
103+
kubectl get clusterroles | grep kubevirt.io:vm-
104+
105+
# Check webhook configuration
106+
kubectl get validatingwebhookconfigurations | grep kubevirt-rbac
107+
```
108+
109+
### Uninstall
110+
111+
```bash
112+
kubectl delete -f https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/install.yaml
113+
```
114+
115+
### Documentation
116+
117+
- [README](https://github.com/${{ github.repository }}/blob/${{ steps.version.outputs.VERSION }}/README.md)
118+
- [Quick Start](https://github.com/${{ github.repository }}/blob/${{ steps.version.outputs.VERSION }}/QUICKSTART.md)
119+
120+
### Container Image
121+
122+
Multi-platform image (linux/amd64, linux/arm64, linux/s390x, linux/ppc64le):
123+
```
124+
ghcr.io/${{ github.repository_owner }}/kubevirt-rbac-webhook:${{ steps.version.outputs.VERSION }}
125+
```
126+
draft: false
127+
prerelease: false

0 commit comments

Comments
 (0)