Skip to content

Commit

Permalink
ci-search: replace bazel based deployment
Browse files Browse the repository at this point in the history
Replaces the bazel based deployment with kustomize.

Signed-off-by: Daniel Hiller <[email protected]>
  • Loading branch information
dhiller committed Dec 19, 2024
1 parent 7037fe3 commit 49320e7
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ postsubmits:
securityContext:
runAsUser: 0
containers:
- image: quay.io/kubevirtci/bootstrap:v20241213-57bd934
- image: quay.io/kubevirtci/golang:v20241213-57bd934
command:
- "/usr/local/bin/runner.sh"
- "/bin/bash"
Expand All @@ -603,7 +603,7 @@ postsubmits:
source ./hack/manage-secrets.sh
decrypt_secrets
extract_secret 'kubeconfig' ~/.kube/config
extract_secret 'bugzilla.apiKey' github/ci/services/ci-search/secrets/production/bugzilla-credentials/api
extract_secret 'bugzilla.apiKey' github/ci/services/ci-search/overlays/production/secrets/bugzilla-credentials
./github/ci/services/ci-search/hack/deploy.sh production
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ presubmits:
preset-bazel-cache: "true"
spec:
containers:
- image: quay.io/kubevirtci/bootstrap:v20241213-57bd934
- image: quay.io/kubevirtci/golang:v20241213-57bd934
command:
- "/usr/local/bin/runner.sh"
- "/bin/sh"
- "-c"
- "-ce"
- |
make gazelle-update-repos
bazel build //github/ci/services/...
go build ./github/ci/services/...
resources:
requests:
memory: "4Gi"
Expand Down
12 changes: 5 additions & 7 deletions github/ci/services/ci-search/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# ci-search

Customization and deployment of [Openshift's ci-search] on Kubevirt CI cluster.
It uses internally these bazel [gitops rules].

## Deployment

You need:
* a kubernetes configuration at `~/.kube/config` with an user allowed to
create [these resources](./manifests).
* [bazelisk] installed.
create [these resources](./base/manifests).
* golang and kubectl installed.

Then, from the root of project-infra run:
```
Expand All @@ -18,13 +17,12 @@ $ ./github/ci/services/ci-search/hack/deploy.sh production
## Tests

Can be tested locally using [kind] and [bazelisk], from the root of project-infra:
```

```bash
$ kind create cluster
$ ./github/ci/services/ci-search/hack/deploy.sh testing
$ bazelisk test //github/ci/services/ci-search/e2e:go_default_test --test_output=all --test_arg=-test.v
$ go test ./github/ci/services/ci-search/e2e -v
```

[gitops rules]: https://github.com/adobe/rules_gitops#:~:text=Bazel%20GitOps%20Rules,kustomize%20overlays%20for%20their%20services.
[Openshift's ci-search]: https://github.com/openshift/ci-search
[kind]: https://github.com/kubernetes-sigs/kind
[bazelisk]: https://github.com/bazelbuild/bazelisk
8 changes: 8 additions & 0 deletions github/ci/services/ci-search/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace: ci-search

resources:
- manifests/full.yaml
- manifests/ingress.yaml

patches:
- path: patches/statefulset.yaml
63 changes: 56 additions & 7 deletions github/ci/services/ci-search/hack/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,62 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This file is part of the KubeVirt project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright the KubeVirt Authors.
#
#

set -eo pipefail
set -e
set -u
set -o pipefail

main(){
local environment=${1}
set -x

bazelisk run //github/ci/services/ci-search:${environment}.apply
WORK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BASE_DIR="$(cd "${WORK_DIR}/.." && pwd)"

bazelisk run //github/ci/services/common/k8s/cmd/wait -- -namespace ci-search -selector search -kind statefulset
function usage {
cat <<EOF
usage: $0 [-d] <environment>
EOF
}

main "${@}"
dry_run=false
while getopts "d" opt; do
case "${opt}" in
d )
dry_run="true"
shift
;;
\? )
usage
exit 1
;;
esac
done

environment="${1}"
[ -d "${BASE_DIR}/overlays/${environment}" ] || exit 1

cd "${BASE_DIR}"

if [ "$dry_run" = "true" ]; then
kubectl kustomize "./overlays/${environment}"
exit 0
fi

kubectl apply -k "./overlays/${environment}"

go run ../common/k8s/cmd/wait -namespace ci-search -selector search -kind statefulset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resources:
- ../../base

secretGenerator:
- name: bugzilla-credentials
files:
- api=./secrets/bugzilla-credentials
type: Opaque
11 changes: 0 additions & 11 deletions github/ci/services/ci-search/overlays/testing/cluster-issuer.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resources:
- ../../base

secretGenerator:
- name: bugzilla-credentials
files:
- api=./secrets/bugzilla-credentials
type: Opaque
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
95988ba4a329c1b0a62e679f1bf5ade1fe6158f0
Empty file.

0 comments on commit 49320e7

Please sign in to comment.