Skip to content

Commit 5289a8b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into issue-238-multi-arch
# Conflicts: # .github/workflows/build-and-push.yaml
2 parents d78dd6c + 10c0fc3 commit 5289a8b

File tree

135 files changed

+20625
-3963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+20625
-3963
lines changed

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
assignees:
8+
- ruivieira
9+
reviewers:
10+
- ruivieira

.github/workflows/build-and-push.yaml

+69-11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
# Ensure that tests pass before publishing a new image.
2424
build-and-push-ci:
2525
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
security-events: write
29+
pull-requests: write
2630
steps: # Assign context variable for various action contexts (tag, main, CI)
2731
- name: Assigning CI context
2832
if: github.head_ref != '' && github.head_ref != 'main' && !startsWith(github.ref, 'refs/tags/v')
@@ -56,6 +60,10 @@ jobs:
5660
echo "GITHUB.HEAD_REF: ${{ github.head_ref }}"
5761
echo "SHA: ${{ github.event.pull_request.head.sha }}"
5862
echo "MAIN IMAGE AT: ${{ vars.QUAY_RELEASE_REPO }}:latest"
63+
echo "LMES DRIVER IMAGE AT: ${{ vars.QUAY_RELEASE_LMES_DRIVER_REPO }}:latest"
64+
echo "LMES JOB IMAGE AT: ${{ vars.QUAY_RELEASE_LMES_JOB_REPO }}:latest"
65+
echo "GUARDRAILS ORCH IMAGE AT: ${{ vars.QUAY_RELEASE_GUARDRAILS_REPO }}:latest"
66+
5967
echo "CI IMAGE AT: quay.io/trustyai/trustyai-service-operator-ci:${{ github.event.pull_request.head.sha }}"
6068
#
6169
# Set environments depending on context
@@ -64,39 +72,58 @@ jobs:
6472
run: |
6573
echo "TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
6674
echo "IMAGE_NAME=quay.io/trustyai/trustyai-service-operator-ci" >> $GITHUB_ENV
75+
echo "DRIVER_IMAGE_NAME=quay.io/trustyai/ta-lmes-driver-ci" >> $GITHUB_ENV
76+
echo "JOB_IMAGE_NAME=quay.io/trustyai/ta-lmes-job-ci" >> $GITHUB_ENV
77+
echo "ORCH_IMAGE_NAME=quay.io/trustyai/ta-guardrails-orchestrator-ci" >> $GITHUB_ENV
78+
6779
- name: Set main-branch environment
6880
if: env.BUILD_CONTEXT == 'main'
6981
run: |
7082
echo "TAG=latest" >> $GITHUB_ENV
7183
echo "IMAGE_NAME=${{ vars.QUAY_RELEASE_REPO }}" >> $GITHUB_ENV
84+
echo "DRIVER_IMAGE_NAME=${{ vars.QUAY_RELEASE_LMES_DRIVER_REPO }}" >> $GITHUB_ENV
85+
echo "JOB_IMAGE_NAME=${{ vars.QUAY_RELEASE_LMES_JOB_REPO }}" >> $GITHUB_ENV
86+
echo "ORCH_IMAGE_NAME=${{ vars.QUAY_RELEASE_GUARDRAILS_REPO }}" >> $GITHUB_ENV
87+
7288
- name: Set tag environment
7389
if: env.BUILD_CONTEXT == 'tag'
7490
run: |
7591
echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
7692
echo "IMAGE_NAME=${{ vars.QUAY_RELEASE_REPO }}" >> $GITHUB_ENV
93+
echo "DRIVER_IMAGE_NAME=${{ vars.QUAY_RELEASE_LMES_DRIVER_REPO }}" >> $GITHUB_ENV
94+
echo "JOB_IMAGE_NAME=${{ vars.QUAY_RELEASE_LMES_JOB_REPO }}" >> $GITHUB_ENV
95+
echo "ORCH_IMAGE_NAME=${{ vars.QUAY_RELEASE_GUARDRAILS_REPO }}" >> $GITHUB_ENV
7796
78-
# Run docker commands
97+
# Run docker commands
7998
- name: Put expiry date on CI-tagged image
8099
if: env.BUILD_CONTEXT == 'ci'
81100
run: sed -i 's#summary="odh-trustyai-service-operator\"#summary="odh-trustyai-service-operator" \\ \n quay.expires-after=7d#' Dockerfile
82101
- name: Log in to Quay
83102
run: docker login -u ${{ secrets.QUAY_ROBOT_USERNAME }} -p ${{ secrets.QUAY_ROBOT_SECRET }} quay.io
84-
- name: Set up QEMU
85-
uses: docker/setup-qemu-action@v2
86-
- name: Set up Docker Buildx
87-
uses: docker/setup-buildx-action@v2
88-
- name: Build and Push Image
89-
uses: docker/build-push-action@v3
90-
with:
91-
tags: ${{ env.IMAGE_NAME }}:${{ env.TAG }}
92-
platforms: linux/amd64,linux/s390x,linux/ppc64le
93-
push: true
103+
- name: Build main image
104+
run: docker build -t ${{ env.IMAGE_NAME }}:$TAG .
105+
- name: Push main image to Quay
106+
run: docker push ${{ env.IMAGE_NAME }}:$TAG
107+
- name: Build LMES driver image
108+
run: docker build -f Dockerfile.driver -t ${{ env.DRIVER_IMAGE_NAME }}:$TAG .
109+
- name: Push LMES driver image to Quay
110+
run: docker push ${{ env.DRIVER_IMAGE_NAME }}:$TAG
111+
- name: Build LMES job image
112+
run: docker build -f Dockerfile.lmes-job -t ${{ env.JOB_IMAGE_NAME }}:$TAG .
113+
- name: Push LMES job image to Quay
114+
run: docker push ${{ env.JOB_IMAGE_NAME }}:$TAG
115+
- name: Build Guardrails orchestrator image
116+
run: docker build -f Dockerfile.orchestrator -t ${{ env.ORCH_IMAGE_NAME }}:$TAG .
117+
- name: Push Guardrails orchestrator image to Quay
118+
run: docker push ${{ env.ORCH_IMAGE_NAME }}:$TAG
94119

95120
# Create CI Manifests
96121
- name: Set up manifests for CI
97122
if: env.BUILD_CONTEXT == 'ci'
98123
run: |
99124
sed -i "s#quay.io/trustyai/trustyai-service-operator:latest#${{ env.IMAGE_NAME }}:$TAG#" ./config/base/params.env
125+
sed -i "s#quay.io/trustyai/trustyai-service-operator:latest#${{ env.IMAGE_NAME }}:$TAG#" ./config/overlays/odh/params.env
126+
sed -i "s#quay.io/trustyai/trustyai-service-operator:latest#${{ env.IMAGE_NAME }}:$TAG#" ./config/overlays/rhoai/params.env
100127
rm -Rf $(ls . | grep -v config)
101128
rm -Rf .gitignore .dockerignore .github .git .yamllint.yaml
102129
# pysh to ci-manifest repo
@@ -116,12 +143,14 @@ jobs:
116143
- uses: peter-evans/find-comment@v3
117144
name: Find Comment
118145
id: fc
146+
if: env.BUILD_CONTEXT == 'ci'
119147
with:
120148
issue-number: ${{ github.event.pull_request.number }}
121149
comment-author: 'github-actions[bot]'
122150
body-includes: PR image build and manifest generation completed successfully
123151
- uses: peter-evans/create-or-update-comment@v4
124152
name: Generate/update success message comment
153+
if: env.BUILD_CONTEXT == 'ci'
125154
with:
126155
comment-id: ${{ steps.fc.outputs.comment-id }}
127156
issue-number: ${{ github.event.pull_request.number }}
@@ -131,5 +160,34 @@ jobs:
131160
132161
📦 [PR image](https://quay.io/trustyai/trustyai-service-operator-ci:${{ github.event.pull_request.head.sha }}): `quay.io/trustyai/trustyai-service-operator-ci:${{ github.event.pull_request.head.sha }}`
133162
163+
📦 [LMES driver image](https://quay.io/trustyai/ta-lmes-driver:${{ github.event.pull_request.head.sha }}): `quay.io/trustyai/ta-lmes-driver:${{ github.event.pull_request.head.sha }}`
164+
165+
📦 [LMES job image](https://quay.io/trustyai/ta-lmes-job:${{ github.event.pull_request.head.sha }}): `quay.io/trustyai/ta-lmes-job:${{ github.event.pull_request.head.sha }}`
166+
167+
📦 [Guardrails orchestrator image](https://quay.io/trustyai/ta-guardrails-orchestrator:${{ github.event.pull_request.head.sha }}): `quay.io/trustyai/ta-guardrails-orchestrator:${{ github.event.pull_request.head.sha }}`
168+
134169
🗂️ [CI manifests](https://github.com/trustyai-explainability/trustyai-service-operator-ci/tree/operator-${{ env.TAG }})
135170
171+
```
172+
devFlags:
173+
manifests:
174+
- contextDir: config
175+
sourcePath: ''
176+
uri: https://api.github.com/repos/trustyai-explainability/trustyai-service-operator-ci/tarball/operator-${{ env.TAG }}
177+
```
178+
- name: Trivy scan
179+
uses: aquasecurity/[email protected]
180+
with:
181+
scan-type: 'image'
182+
image-ref: "${{ env.IMAGE_NAME }}:${{ env.TAG }}"
183+
format: 'sarif'
184+
output: 'trivy-results.sarif'
185+
severity: 'MEDIUM,HIGH,CRITICAL'
186+
exit-code: '0'
187+
ignore-unfixed: false
188+
vuln-type: 'os,library'
189+
190+
- name: Update Security tab
191+
uses: github/codeql-action/upload-sarif@v3
192+
with:
193+
sarif_file: 'trivy-results.sarif'

.github/workflows/controller-tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup Go
1414
uses: actions/setup-go@v4
1515
with:
16-
go-version: '1.19.0'
16+
go-version: '1.21.12'
1717

1818
- name: Download & install envtest binaries
1919
run: |

.github/workflows/smoke.yaml

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
name: Smoke test
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
4+
pull_request:
5+
branches:
6+
- main
77

88
jobs:
9-
deploy:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v2
9+
deploy:
10+
runs-on: ubuntu-latest
11+
env:
12+
PR_NUMBER: ${{ github.event.pull_request.number || 'default-pr-number' }}
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
1416

15-
- name: Set up Docker Buildx
16-
uses: docker/setup-buildx-action@v1
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v1
1719

18-
- name: Build and push operator container image
19-
uses: docker/build-push-action@v2
20-
with:
21-
context: .
22-
file: ./Dockerfile
23-
load: true
24-
tags: smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}
20+
- name: Build and push operator container image
21+
uses: docker/build-push-action@v2
22+
with:
23+
context: .
24+
file: ./Dockerfile
25+
load: true
26+
tags: smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}
2527

26-
- name: Create k8s Kind Cluster
27-
uses: helm/kind-action@v1
28-
with:
29-
node_image: kindest/node:v1.24.17
30-
cluster_name: kind
28+
- name: Create k8s Kind Cluster
29+
uses: helm/kind-action@v1
30+
with:
31+
node_image: kindest/node:v1.24.17
32+
cluster_name: kind
3133

32-
- name: Load the operator image into Kind
33-
run: |
34-
kind load docker-image smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}
34+
- name: Load the operator image into Kind
35+
run: |
36+
kind load docker-image smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}
3537
36-
- name: Install kustomize
37-
run: |
38-
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
39-
sudo mv kustomize /usr/local/bin/
38+
- name: Install kustomize
39+
run: |
40+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
41+
sudo mv kustomize /usr/local/bin/
4042
41-
- name: Apply CRDs
42-
run: |
43-
kubectl apply -f tests/crds/monitoring.coreos.com_servicemonitors.yaml
44-
kubectl apply -f tests/crds/route_crd.yaml
45-
kubectl apply -f tests/crds/serving.kserve.io_inferenceservices.yaml
46-
kubectl apply -f tests/crds/serving.kserve.io_servingruntimes.yaml
47-
kustomize build config/crd | kubectl apply -f -
43+
- name: Apply CRDs
44+
run: |
45+
kubectl apply -f tests/crds/monitoring.coreos.com_servicemonitors.yaml
46+
kubectl apply -f tests/crds/route_crd.yaml
47+
kubectl apply -f tests/crds/serving.kserve.io_inferenceservices.yaml
48+
kustomize build config/crd | kubectl apply -f -
4849
49-
- name: Update params.env file
50-
run: |
51-
sed -i 's|trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:latest|trustyaiOperatorImage=smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}|' config/base/params.env
50+
- name: Update params.env file
51+
run: |
52+
sed -i 's|trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:latest|trustyaiOperatorImage=smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}|' config/base/params.env
5253
53-
- name: Deploy the operator with kustomize
54-
run: |
55-
kubectl create namespace system
56-
kustomize build config/base | kubectl apply -f -
57-
58-
- name: Run smoke tests
59-
run: ./tests/smoke/test_smoke.sh
54+
- name: Deploy the operator with kustomize
55+
run: |
56+
kubectl create namespace system
57+
kustomize build config/base | kubectl apply -n system -f -
6058
59+
- name: Run smoke tests
60+
run: ./tests/smoke/test_smoke.sh
6161

6262
env:
63-
PR_NUMBER: "default-pr-number"
64-
KUBECONFIG: "${HOME}/.kube/config"
63+
PR_NUMBER: "default-pr-number"
64+
KUBECONFIG: "${HOME}/.kube/config"

.yamllint.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ rules:
66
level: warning
77
hyphens:
88
max-spaces-after: 1
9-
level: warning
9+
level: warning
10+
indentation:
11+
indent-sequences: consistent

CONTRIBUTING.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Contributing to the TrustyAI Operator
2+
3+
Thanks for your interest in the TrustyAI operator project! You can contribute to this project in various ways: filing bug reports, proposing features, submitting pull requests (PRs), and improving documentation.
4+
5+
Before you begin, please take a look at our contribution guidelines below to ensure that your contribuutions are aligned with the project's goals.
6+
7+
## Reporting Issues
8+
Issues are tracked using [Github](https://github.com/trustyai-explainability/trustyai-service-operator/issues). If you encounter a bug or have suggestions for enhancements, please follow the steps below:
9+
10+
1. **Check for Existing Issues:** Before creating a new issue, search the Github project to see if a similar issue already exists.
11+
2. **Create a Github issue:** If the issue doesn’t exist, create a new ticket in Github.
12+
- **For Feature Requests:** Set the label as `feature`
13+
- **For Bugs:** Set the label to `kind/bug`
14+
- **For all other code changes:** Use the issue type `kind/enhancement`
15+
- Add to the "TrustyAI planning" in "Projects"
16+
- And specify "Component" as "Operator"
17+
18+
## Pull Requests
19+
20+
### Workflow
21+
22+
1. **Fork the Repository:** Create your own fork of the repository to work on your changes.
23+
2. **Create a Branch:** Create your own branch to include changes for the feature or a bug fix off of `main` branch.
24+
3. **Work on Your Changes:** Commit often, and ensure your code passes all the test for the operator.
25+
4. **Testing:** Make sure your code passes all the tests, including any new tests you've added. And that your changes do not decrease the test coverage as shown on report. Every new feature should come with unit tests that cover that new part of the code.
26+
27+
### Open a Pull Request:
28+
29+
1. **Link to Github Issue**: Include the Github issue link in your PR description.
30+
2. **Description**: Provide a detailed description of the changes and what they fix or implement.
31+
3. **Add Testing Steps**: Provide information on how the PR has been tested, and list out testing steps if any for reviewers.
32+
4. **Review Request**: Tag the relevant maintainers(`@trustyai-explainability/developers`) for a review.
33+
5. **Resolve Feedback**: Be open to feedback and iterate on your changes.
34+
35+
### Quality Gates
36+
37+
To ensure the contributed code adheres to the project goals, we have set up some automated quality gates:
38+
39+
1. [linters](https://github.com/trustyai-explainability/trustyai-service-operator/actions/workflows/lint-yaml.yaml): Ensure the check for linters is successful.
40+
2. [smoke tests](https://github.com/trustyai-explainability/trustyai-service-operator/actions/workflows/smoke.yaml): Ensure the operator passes the smoke tests
41+
3. [unit-tests](https://github.com/trustyai-explainability/trustyai-service-operator/actions/workflows/controller-tests.yaml): Ensure unit tests pass.
42+
4. e2e-tests: Ensure OpenShift CI job for e2e tests pass.
43+
44+
### Code Style Guidelines
45+
46+
1. Follow the Go community’s best practices, which can be found in the official [Effective Go](https://go.dev/doc/effective_go) guide.
47+
2. Follow the best practices defined by the [Operator SDK](https://sdk.operatorframework.io/docs/best-practices/).
48+
3. Use `go fmt` to automatically format your code.
49+
4. Ensure you write clear and concise comments, especially for exported functions.
50+
5. Always check and handle errors appropriately. Avoid ignoring errors by using _.
51+
6. Make sure to run `go mod tidy` before submitting a PR to ensure the `go.mod` and `go.sum` files are up-to-date.
52+
53+
### Commit Messages
54+
55+
We follow the conventional commits format for writing commit messages. A good commit message should include:
56+
1. **Type:** `fix`, `feat`, `docs`, `chore`, etc. **Note:** All `fix` and `feat` commits require an associated issue. Please add link to your Github issue.
57+
1. Security fixes should be in the format `fix(CVE-xxx): `
58+
2. **Scope:** A short description of the area affected.
59+
3. **Summary:** A brief explanation of what the commit does.
60+
61+
## Communication
62+
63+
For general questions, feel free to open a discussion in our repository or communicate via:
64+
65+
- **Comments**: Feel free to discuss issues directly on Github issues.
66+
- **Discussions**: Alternatively, use [Github discussions](https://github.com/orgs/trustyai-explainability/discussions)

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM registry.access.redhat.com/ubi8/go-toolset:1.20 as builder
2+
FROM registry.access.redhat.com/ubi8/go-toolset:1.23 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -12,7 +12,7 @@ COPY go.sum go.sum
1212
RUN go mod download
1313

1414
# Copy the go source
15-
COPY main.go main.go
15+
COPY cmd/ cmd/
1616
COPY api/ api/
1717
COPY controllers/ controllers/
1818

@@ -22,7 +22,7 @@ COPY controllers/ controllers/
2222
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2323
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
2424
USER root
25-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
25+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
2626

2727
# Use distroless as minimal base image to package the manager binary
2828
# Refer to https://github.com/GoogleContainerTools/distroless for more details

0 commit comments

Comments
 (0)