|
9 | 9 | cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" || exit |
10 | 10 | cd .. || exit |
11 | 11 |
|
| 12 | +GREEN='\033[0;32m' |
| 13 | +RED='\033[0;31m' |
| 14 | +NC='\033[0m' # No Color |
| 15 | +function info { |
| 16 | + printf "${GREEN}run-operator.sh: ${1}${NC}\n" |
| 17 | +} |
| 18 | +function error { |
| 19 | + printf "${RED}run-operator.sh: ${1}${NC}\n" |
| 20 | +} |
| 21 | + |
12 | 22 | if ! minikube status |
13 | 23 | then |
14 | | - echo "starting minikube" |
| 24 | + info "starting minikube" |
15 | 25 | minikube start |
16 | 26 | fi |
17 | 27 |
|
18 | | -echo "building operator image in minikube" |
| 28 | +GIT_HASH="$(git rev-parse HEAD)" |
| 29 | +TMP_INSTALL_DIR="$(mktemp -d)" |
| 30 | +trap 'rm -rf -- "$TMP_INSTALL_DIR"' EXIT |
| 31 | + |
| 32 | +info "building operator image in minikube for commit ${GIT_HASH}" |
| 33 | +IMAGE_TAG="dev-git-${GIT_HASH}" |
19 | 34 | KROXYLICIOUS_VERSION=${KROXYLICIOUS_VERSION:-$(mvn org.apache.maven.plugins:maven-help-plugin:3.4.0:evaluate -Dexpression=project.version -q -DforceStdout)} |
20 | | -minikube image build . -f Dockerfile.operator -t quay.io/kroxylicious/operator:latest --build-opt=build-arg=KROXYLICIOUS_VERSION="${KROXYLICIOUS_VERSION}" |
| 35 | +minikube image build . -f Dockerfile.operator -t quay.io/kroxylicious/operator:${IMAGE_TAG} --build-opt=build-arg=KROXYLICIOUS_VERSION="${KROXYLICIOUS_VERSION}" |
21 | 36 |
|
22 | 37 | cd kroxylicious-operator || exit |
23 | | -echo "installing kafka (no-op if already installed)" |
| 38 | +info "installing kafka (no-op if already installed)" |
24 | 39 | kubectl create namespace kafka |
25 | 40 | kubectl create -n kafka -f 'https://strimzi.io/install/latest?namespace=kafka' |
26 | 41 | kubectl wait -n kafka deployment/strimzi-cluster-operator --for=condition=Available=True --timeout=300s |
27 | 42 | kubectl apply -n kafka -f https://strimzi.io/examples/latest/kafka/kraft/kafka-single-node.yaml |
28 | 43 | kubectl wait -n kafka kafka/my-cluster --for=condition=Ready --timeout=300s |
29 | 44 |
|
30 | | -echo "deleting example" |
| 45 | +info "deleting example" |
31 | 46 | kubectl delete -f examples/simple/ --ignore-not-found=true --timeout=30s --grace-period=1 |
32 | 47 |
|
33 | | -echo "deleting kroxylicious-operator installation" |
| 48 | +info "deleting kroxylicious-operator installation" |
34 | 49 | kubectl delete -n kroxylicious-operator all --all --timeout=30s --grace-period=1 |
35 | 50 | kubectl delete -f install --ignore-not-found=true --timeout=30s --grace-period=1 |
36 | 51 |
|
37 | | -echo "deleting all kroxylicious.io resources and crds" |
| 52 | +info "deleting all kroxylicious.io resources and crds" |
38 | 53 | for crd in $(kubectl get crds -oname | grep kroxylicious.io | awk -F / '{ print $2 }'); |
39 | 54 | do |
40 | 55 | export crd |
41 | | - echo "deleting resources for crd: $crd" |
| 56 | + info "deleting resources for crd: $crd" |
42 | 57 | kubectl delete -A --all "$(kubectl get crd "${crd}" -o=jsonpath='{.spec.names.singular}')" --timeout=30s --grace-period=1 |
43 | | - echo "deleting crd: ${crd}" |
| 58 | + info "deleting crd: ${crd}" |
44 | 59 | kubectl delete crd "${crd}" |
45 | 60 | done |
46 | 61 |
|
47 | | -echo "installing crds" |
| 62 | +info "installing crds" |
48 | 63 | kubectl apply -f src/main/resources/META-INF/fabric8 |
49 | | -echo "installing kroxylicious-operator" |
50 | | -kubectl apply -f install |
51 | | -echo "installing simple proxy" |
| 64 | +info "installing kroxylicious-operator" |
| 65 | +cp install/* ${TMP_INSTALL_DIR} |
| 66 | +sed -i "s|quay.io/kroxylicious/operator:latest|quay.io/kroxylicious/operator:${IMAGE_TAG}|g" ${TMP_INSTALL_DIR}/03.Deployment.kroxylicious-operator.yaml |
| 67 | +kubectl apply -f ${TMP_INSTALL_DIR} |
| 68 | +info "installing simple proxy" |
52 | 69 | kubectl apply -f examples/simple/ |
53 | 70 |
|
54 | 71 | if kubectl wait -n my-proxy kafkaproxy/simple --for=condition=Ready=True --timeout=300s |
55 | 72 | then |
56 | | - echo "simple proxy should now be available in-cluster at my-cluster.my-proxy.svc.cluster.local:9292" |
| 73 | + info "simple proxy should now be available in-cluster at my-cluster.my-proxy.svc.cluster.local:9292" |
57 | 74 | else |
58 | | - echo "something went wrong!" |
| 75 | + error "something went wrong waiting for proxy to become ready!" |
59 | 76 | exit 1 |
60 | 77 | fi |
0 commit comments