Skip to content

Commit 929d4cc

Browse files
authored
Merge pull request #2077 from rnc/KJB40
Minikube CI and development changes
2 parents 60dffab + b11f22a commit 929d4cc

File tree

8 files changed

+51
-105
lines changed

8 files changed

+51
-105
lines changed

.github/workflows/minikube.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
export MAVEN_PASSWORD=secret
7272
export MAVEN_REPOSITORY='http://jvm-build-maven-repo.$(context.taskRun.namespace).svc.cluster.local/releases'
7373
74+
echo "Using worker namespace $JBS_WORKER_NAMESPACE and DEV_IP $DEV_IP"
75+
7476
eval $(minikube -p minikube docker-env)
7577
7678
docker pull quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:on-pr-${{ github.event.pull_request.head.sha }}
@@ -81,6 +83,7 @@ jobs:
8183
docker tag quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/controller:on-pr-${{ github.event.pull_request.head.sha }} quay.io/minikube/hacbs-jvm-controller:dev
8284
8385
export ABTESTSET=${{ matrix.abtestsets }}
86+
echo "Using ABTESTSET $ABTESTSET"
8487
8588
./deploy/minikube-ci.sh
8689
make minikube-test
@@ -132,6 +135,8 @@ jobs:
132135
export MAVEN_PASSWORD=secret
133136
export MAVEN_REPOSITORY='http://jvm-build-maven-repo.$(context.taskRun.namespace).svc.cluster.local/releases'
134137
138+
echo "Using worker namespace $JBS_WORKER_NAMESPACE and DEV_IP $DEV_IP"
139+
135140
eval $(minikube -p minikube docker-env)
136141
137142
docker pull quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:on-pr-${{ github.event.pull_request.head.sha }}
@@ -142,6 +147,7 @@ jobs:
142147
docker tag quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/controller:on-pr-${{ github.event.pull_request.head.sha }} quay.io/minikube/hacbs-jvm-controller:dev
143148
144149
export DBTESTSET=${{ matrix.dbtestsets }}
150+
echo "Using DBTESTSET $DBTESTSET"
145151
146152
./deploy/minikube-ci.sh
147153
make minikube-test

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ The following environment variables are configurable and may be set by the user
4040
| JBS_GIT_CREDENTIALS | Support for private repositories (See below)
4141
| JBS_MAX_MEMORY | Maximum additional memory allowed
4242
| JBS_RECIPE_DATABASE | Recipe database to use (defaults to `https://github.com/redhat-appstudio/jvm-build-data`)
43-
| JBS_S3_SYNC_ENABLED | Whether to enable Amazon S3 sync for storage
44-
| JBS_WORKER_NAMESPACE | Default 'worker' namespace (`test-jvm-namespace`) may be customised by setting this
43+
| JBS_S3_SYNC_ENABLED | Whether to enable Amazon S3 sync for storage (default: `false`)
44+
| JBS_WORKER_NAMESPACE | Worker namespace (default: `test-jvm-namespace`) may be customised by setting this
4545
| MAVEN_PASSWORD | Password for the Maven repository
4646
| MAVEN_REPOSITORY | The URL for the external Maven repository to deploy to
4747
| MAVEN_USERNAME | Username for the Maven repository

deploy/base-development.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
if ! command -v kubectl &> /dev/null; then
44
echo "Install kubectl from https://kubernetes.io/docs/tasks/tools/install-kubectl-linux"
@@ -24,7 +24,7 @@ if [ -z "$JBS_BUILD_IMAGE_SECRET" ]; then
2424
export JBS_BUILD_IMAGE_SECRET="ewogICAgImF1dGhzIjogewogICAgfQp9Cg==" # notsecret
2525
fi
2626
if [ -z "$JBS_S3_SYNC_ENABLED" ]; then
27-
export JBS_S3_SYNC_ENABLED=true
27+
export JBS_S3_SYNC_ENABLED=false
2828
fi
2929
if [ -z "$JBS_CONTAINER_BUILDS" ]; then
3030
export JBS_CONTAINER_BUILDS=false
@@ -39,23 +39,29 @@ fi
3939
export JBS_S3_SYNC_ENABLED="\"$JBS_S3_SYNC_ENABLED\""
4040

4141
kubectl delete --ignore-not-found deployments.apps hacbs-jvm-operator -n jvm-build-service
42-
# we don't restart the cache and local storage by default
43-
# for most cases in development this is not necessary, and just slows things
44-
# down by needing things to be re-cached/rebuilt
42+
kubectl delete --ignore-not-found deployments.apps jvm-build-workspace-artifact-cache
4543

4644
function cleanAllArtifacts() {
47-
kubectl delete --ignore-not-found namespaces $JBS_WORKER_NAMESPACE
48-
}
45+
# Following are created in CI code
46+
kubectl delete --ignore-not-found=true tasks.tekton.dev git-clone
47+
kubectl delete --ignore-not-found=true tasks.tekton.dev maven
48+
kubectl delete --ignore-not-found=true pipelines.tekton.dev sample-component-build
49+
kubectl delete --ignore-not-found=true clusterrolebindings.rbac.authorization.k8s.io pipeline-test-jvm-namespace
4950

50-
kubectl delete --ignore-not-found deployments.apps jvm-build-workspace-artifact-cache
51-
if [ "$1" = "--clean" ]; then
52-
cleanAllArtifacts
53-
fi
51+
kubectl delete --ignore-not-found=true artifactbuilds.jvmbuildservice.io --all
52+
53+
kubectl delete --ignore-not-found=true pipelineruns.tekton.dev --all --wait=false
54+
kubectl delete --ignore-not-found=true taskruns.tekton.dev --all --wait=false
55+
}
5456

5557
echo -e "\033[0;32mSetting context to $JBS_WORKER_NAMESPACE with quay image $JBS_QUAY_IMAGE\033[0m"
5658
# Its possible to set context before namespaces have been created.
5759
kubectl config set-context --current --namespace=$JBS_WORKER_NAMESPACE
5860

61+
if [ "$1" = "--clean" ]; then
62+
cleanAllArtifacts
63+
fi
64+
5965
DIR=`dirname $0`
6066

6167
echo -e "\033[0;32mRunning kustomize/kubectl...\033[0m"
@@ -80,3 +86,5 @@ ${MAVEN_REPOSITORY}
8086
${MAVEN_USERNAME}
8187
${QUAY_USERNAME}' \
8288
| kubectl apply -f -
89+
90+
echo "Completed overlays"

deploy/minikube-ci.sh

Lines changed: 11 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,20 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
DIR=`dirname $0`
4-
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.59.2/release.yaml
5-
timeout=600 #10 minutes in seconds
6-
endTime=$(( $(date +%s) + timeout ))
74

8-
while ! oc get pods -n tekton-pipelines | grep tekton-pipelines-controller | grep "1/1"; do
9-
sleep 1
10-
if [ $(date +%s) -gt $endTime ]; then
11-
exit 1
12-
fi
13-
done
14-
while ! oc get pods -n tekton-pipelines | grep tekton-pipelines-webhook | grep "1/1"; do
15-
sleep 1
16-
if [ $(date +%s) -gt $endTime ]; then
17-
exit 1
18-
fi
19-
done
20-
#we need to make sure the tekton webhook has its rules installed
21-
kubectl wait --for=jsonpath='{.webhooks[0].rules}' --timeout=300s mutatingwebhookconfigurations.admissionregistration.k8s.io webhook.pipeline.tekton.dev
22-
echo "Tekton controller is running"
23-
24-
#CRDS are sometimes racey
25-
kubectl apply -k $DIR/crds/base
26-
## Up to commit https://github.com/openshift/api/commit/60b796dbf3a2d90b6960bb04585a9f9289b0ca1f the flie has been changed, renamed and finally moved
27-
## kubectl apply -f https://raw.githubusercontent.com/openshift/api/master/quota/v1/0000_03_quota-openshift_01_clusterresourcequota.crd.yaml
28-
kubectl apply -f https://raw.githubusercontent.com/openshift/api/master/quota/v1/zz_generated.crd-manifests/0000_03_config-operator_01_clusterresourcequotas.crd.yaml
29-
sleep 2
30-
31-
kubectl delete --ignore-not-found deployments.apps hacbs-jvm-operator -n jvm-build-service
32-
kubectl delete --ignore-not-found deployments.apps jvm-build-workspace-artifact-cache
33-
34-
echo "Using QUAY_USERNAME: $QUAY_USERNAME"
35-
echo "Using JBS_WORKER_NAMESPACE: $JBS_WORKER_NAMESPACE"
36-
export JBS_QUAY_IMAGE=$QUAY_USERNAME
37-
export JVM_BUILD_SERVICE_IMAGE=quay.io/$QUAY_USERNAME/hacbs-jvm-controller
38-
# Represents an empty dockerconfig.json
39-
if [ -z "$JBS_BUILD_IMAGE_SECRET" ]; then
40-
export JBS_BUILD_IMAGE_SECRET="ewogICAgImF1dGhzIjogewogICAgfQp9Cg==" # notsecret
5+
# DEV_IP is only set in .github/workflows/minikube.yaml and only used in CI
6+
if [ -n "$DEV_IP" ]; then
7+
echo "Altering templates to never pull images"
8+
#huge hack to deal with minikube local images, make sure they are never pulled
9+
find $DIR -path \*dev-template\*.yaml -exec sed -i s/Always/Never/ {} \;
4110
fi
42-
export JBS_S3_SYNC_ENABLED="\"false\""
43-
export JBS_CONTAINER_BUILDS=false
44-
export JBS_MAX_MEMORY=4096
45-
46-
cat $DIR/base/namespace/namespace.yaml | envsubst '${JBS_WORKER_NAMESPACE}' | kubectl apply -f -
47-
kubectl config set-context --current --namespace=${JBS_WORKER_NAMESPACE}
4811

49-
#huge hack to deal with minikube local images, make sure they are never pulled
50-
find $DIR -path \*dev-template\*.yaml -exec sed -i s/Always/Never/ {} \;
51-
52-
kustomize build $DIR/overlays/dev-template | envsubst '
53-
${AWS_ACCESS_KEY_ID}
54-
${AWS_PROFILE}
55-
${AWS_SECRET_ACCESS_KEY}
56-
${GIT_DEPLOY_IDENTITY}
57-
${GIT_DEPLOY_TOKEN}
58-
${GIT_DEPLOY_URL}
59-
${GIT_DISABLE_SSL_VERIFICATION}
60-
${JBS_BUILD_IMAGE_SECRET}
61-
${JBS_CONTAINER_BUILDS}
62-
${JBS_GIT_CREDENTIALS}
63-
${JBS_QUAY_IMAGE}
64-
${JBS_MAX_MEMORY}
65-
${JBS_RECIPE_DATABASE}
66-
${JBS_S3_SYNC_ENABLED}
67-
${JBS_WORKER_NAMESPACE}
68-
${MAVEN_PASSWORD}
69-
${MAVEN_REPOSITORY}
70-
${MAVEN_USERNAME}
71-
${QUAY_USERNAME}' \
72-
| kubectl apply -f -
73-
74-
echo "Completed overlays"
75-
#this tells JBS we are in test mode and won't have a secure registry
76-
kubectl annotate --overwrite jbsconfigs.jvmbuildservice.io --all jvmbuildservice.io/test-registry=true
12+
$DIR/minikube-development.sh --clean
7713

7814
# Deleting the jvm-build-config as its created with different settings in util.go::setupMinikube
7915
kubectl delete --ignore-not-found=true jbsconfigs.jvmbuildservice.io jvm-build-config
80-
# Following are created in code
81-
kubectl delete --ignore-not-found=true tasks.tekton.dev git-clone
82-
kubectl delete --ignore-not-found=true tasks.tekton.dev maven
83-
kubectl delete --ignore-not-found=true pipelines.tekton.dev sample-component-build
84-
kubectl delete --ignore-not-found=true clusterrolebindings.rbac.authorization.k8s.io pipeline-test-jvm-namespace
85-
kubectl delete --ignore-not-found=true artifactbuilds.jvmbuildservice.io --all
8616

87-
cat $DIR/minikube-rbac.yaml | envsubst '${JBS_WORKER_NAMESPACE}' | kubectl apply -f -
88-
89-
#revert hack above to avoid edits in place
90-
find $DIR -path \*dev-template\*.yaml -exec sed -i s/Never/Always/ {} \;
17+
# Revert hack above to avoid edits in place
18+
if [ -n "$DEV_IP" ]; then
19+
find $DIR -path \*dev-template\*.yaml -exec sed -i s/Never/Always/ {} \;
20+
fi

deploy/minikube-development.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
DIR=`dirname $0`
44
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.59.2/release.yaml
@@ -24,25 +24,27 @@ echo -e "\033[0;32mTekton controller is running\033[0m"
2424

2525
#CRDS are sometimes racey
2626
kubectl apply -k $DIR/crds/base
27+
# TODO: Don't think this below CRD is needed.
2728
#Load missing CRD
28-
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.69.1/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
29+
#kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.69.1/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
2930
## Up to commit https://github.com/openshift/api/commit/60b796dbf3a2d90b6960bb04585a9f9289b0ca1f the flie has been changed, renamed and finally moved
3031
## kubectl apply -f https://raw.githubusercontent.com/openshift/api/master/quota/v1/0000_03_quota-openshift_01_clusterresourcequota.crd.yaml
3132
kubectl apply -f https://raw.githubusercontent.com/openshift/api/master/quota/v1/zz_generated.crd-manifests/0000_03_config-operator_01_clusterresourcequotas.crd.yaml
3233
sleep 2
3334

34-
$DIR/base-development.sh $1
35+
$DIR/base-development.sh $1
3536

3637
# base-development.sh switches to the test-jvm-namespace namespace
37-
kubectl create --dry-run=client -o=yaml sa pipeline | kubectl apply -f -
3838
if [ -z "$JBS_WORKER_NAMESPACE" ]; then
3939
export JBS_WORKER_NAMESPACE=test-jvm-namespace
4040
fi
4141
cat $DIR/minikube-rbac.yaml | envsubst '${JBS_WORKER_NAMESPACE}' | kubectl apply -f -
4242

43+
# TODO: Unknown if we still need these.
4344
#minikube cannot access registry.redhat.io by default
4445
#you need to have these credentials in your docker config
45-
kubectl create --dry-run=client -o=yaml secret docker-registry minikube-pull-secret --from-file=.dockerconfigjson=$HOME/.docker/config.json | kubectl apply -f -
46-
kubectl patch serviceaccount pipeline -p '{"imagePullSecrets": [{"name": "minikube-pull-secret"}]}'
47-
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "minikube-pull-secret"}]}'
48-
kubectl patch --type=merge jbsconfigs.jvmbuildservice.io jvm-build-config -p '{"spec":{"cacheSettings":{"disableTLS": true}}}'
46+
#kubectl create --dry-run=client -o=yaml secret docker-registry minikube-pull-secret --from-file=.dockerconfigjson=$HOME/.docker/config.json | kubectl apply -f -
47+
#kubectl patch serviceaccount pipeline -p '{"imagePullSecrets": [{"name": "minikube-pull-secret"}]}'
48+
#kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "minikube-pull-secret"}]}'
49+
#kubectl patch --type=merge jbsconfigs.jvmbuildservice.io jvm-build-config -p '{"spec":{"cacheSettings":{"disableTLS": true}}}'
50+

deploy/minikube-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
DIR=`dirname $0`/..
44
eval $(minikube -p minikube docker-env)

deploy/openshift-ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# This is referenced by:
44
# https://github.com/openshift/release/blob/master/ci-operator/config/redhat-appstudio/jvm-build-service/redhat-appstudio-jvm-build-service-main.yaml

deploy/openshift-development.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
deploy_maven_repo=false
44

0 commit comments

Comments
 (0)