diff --git a/code/easyfranchise/deployment/docker/Dockerfile-approuter b/code/easyfranchise/deployment/docker/Dockerfile-approuter index a1bc6e9..1bf3852 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-approuter +++ b/code/easyfranchise/deployment/docker/Dockerfile-approuter @@ -1,4 +1,4 @@ -FROM node:14 +FROM --platform=linux/amd64 node:20 WORKDIR /app diff --git a/code/easyfranchise/deployment/docker/Dockerfile-bp-service b/code/easyfranchise/deployment/docker/Dockerfile-bp-service index 0dabbbe..7304c27 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-bp-service +++ b/code/easyfranchise/deployment/docker/Dockerfile-bp-service @@ -1,4 +1,4 @@ -FROM maven:3-openjdk-17-slim as BUILDER +FROM --platform=linux/amd64 maven:3-openjdk-17-slim as BUILDER WORKDIR /opt/app COPY code/easyfranchise/source/backend/bp-service/pom.xml bp-service/pom.xml COPY code/easyfranchise/source/backend/db-service/pom.xml db-service/pom.xml @@ -12,7 +12,7 @@ COPY code/easyfranchise/source/backend/db-service/src /opt/app/db-service/src RUN mvn clean install -DskipTests=true # At this point, BUILDER stage should have your .jar or whatever in some path -FROM sapmachine:16 as production-stage +FROM --platform=linux/amd64 sapmachine:latest as production-stage LABEL maintainer="alexander.rieder@sap.com" WORKDIR /opt/app COPY --from=BUILDER /opt/app/bp-service/target/bp-service.jar /opt/app/bp-service.jar diff --git a/code/easyfranchise/deployment/docker/Dockerfile-broker b/code/easyfranchise/deployment/docker/Dockerfile-broker index a6c6a21..8157d24 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-broker +++ b/code/easyfranchise/deployment/docker/Dockerfile-broker @@ -1,4 +1,4 @@ -FROM node:14 +FROM --platform=linux/amd64 node:14 EXPOSE 3002 diff --git a/code/easyfranchise/deployment/docker/Dockerfile-business-partner-mock b/code/easyfranchise/deployment/docker/Dockerfile-business-partner-mock index 75e0a57..015fd9a 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-business-partner-mock +++ b/code/easyfranchise/deployment/docker/Dockerfile-business-partner-mock @@ -1,4 +1,4 @@ -FROM node:latest +FROM --platform=linux/amd64 node:latest EXPOSE 8081 diff --git a/code/easyfranchise/deployment/docker/Dockerfile-db-service b/code/easyfranchise/deployment/docker/Dockerfile-db-service index 4967bfc..7ea5a99 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-db-service +++ b/code/easyfranchise/deployment/docker/Dockerfile-db-service @@ -1,4 +1,4 @@ -FROM maven:3-openjdk-17-slim as BUILDER +FROM --platform=linux/amd64 maven:3-openjdk-17-slim as BUILDER WORKDIR /opt/app COPY code/easyfranchise/source/backend/bp-service/pom.xml bp-service/pom.xml COPY code/easyfranchise/source/backend/db-service/pom.xml db-service/pom.xml @@ -11,7 +11,7 @@ COPY code/easyfranchise/source/backend/ef-service/src /opt/app/ef-service/src COPY code/easyfranchise/source/backend/db-service/src /opt/app/db-service/src RUN mvn clean install -DskipTests=true -FROM sapmachine:16 as production-stage +FROM --platform=linux/amd64 sapmachine:latest as production-stage LABEL maintainer="alexander.rieder@sap.com" WORKDIR /opt/app COPY --from=BUILDER /opt/app/db-service/target/db-service.jar /opt/app/db-service.jar diff --git a/code/easyfranchise/deployment/docker/Dockerfile-ef-service b/code/easyfranchise/deployment/docker/Dockerfile-ef-service index bd91151..ab88490 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-ef-service +++ b/code/easyfranchise/deployment/docker/Dockerfile-ef-service @@ -1,4 +1,4 @@ -FROM maven:3-openjdk-17-slim as BUILDER +FROM --platform=linux/amd64 maven:3-openjdk-17-slim as BUILDER WORKDIR /opt/app COPY code/easyfranchise/source/backend/bp-service/pom.xml bp-service/pom.xml COPY code/easyfranchise/source/backend/db-service/pom.xml db-service/pom.xml @@ -11,7 +11,7 @@ COPY code/easyfranchise/source/backend/ef-service/src /opt/app/ef-service/src COPY code/easyfranchise/source/backend/db-service/src /opt/app/db-service/src RUN mvn clean install -DskipTests=true -FROM sapmachine:16 as production-stage +FROM --platform=linux/amd64 sapmachine:latest as production-stage LABEL maintainer="alexander.rieder@sap.com" WORKDIR /opt/app COPY --from=BUILDER /opt/app/ef-service/target/ef-service.jar /opt/app/ef-service.jar diff --git a/code/easyfranchise/deployment/docker/Dockerfile-email-service b/code/easyfranchise/deployment/docker/Dockerfile-email-service index d97d75f..f506d5d 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-email-service +++ b/code/easyfranchise/deployment/docker/Dockerfile-email-service @@ -1,4 +1,4 @@ -FROM node:latest +FROM --platform=linux/amd64 node:latest EXPOSE 3002 diff --git a/code/easyfranchise/deployment/docker/Dockerfile-ui b/code/easyfranchise/deployment/docker/Dockerfile-ui index e0742aa..923dab0 100644 --- a/code/easyfranchise/deployment/docker/Dockerfile-ui +++ b/code/easyfranchise/deployment/docker/Dockerfile-ui @@ -1,5 +1,5 @@ # build stage -FROM node:14-alpine as build-stage +FROM --platform=linux/amd64 node:14-alpine as build-stage WORKDIR /app COPY code/easyfranchise/source/ui/package*.json ./ RUN npm install @@ -7,7 +7,7 @@ COPY code/easyfranchise/source/ui/. . RUN npm run build # production stage -FROM nginx:stable-alpine as production-stage +FROM --platform=linux/amd64 nginx:stable-alpine as production-stage COPY --from=build-stage /app/resources /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/code/easyfranchise/deployment/k8s/bp-service.yaml b/code/easyfranchise/deployment/k8s/bp-service.yaml index e4b1853..e31ea41 100644 --- a/code/easyfranchise/deployment/k8s/bp-service.yaml +++ b/code/easyfranchise/deployment/k8s/bp-service.yaml @@ -21,7 +21,7 @@ spec: imagePullSecrets: - name: registry-secret containers: - - image: + - image: # use your own image name: bp-service imagePullPolicy: Always resources: {} diff --git a/code/easyfranchise/deployment/k8s/broker.yaml b/code/easyfranchise/deployment/k8s/broker.yaml index 9f53dd8..7313f3b 100644 --- a/code/easyfranchise/deployment/k8s/broker.yaml +++ b/code/easyfranchise/deployment/k8s/broker.yaml @@ -18,7 +18,7 @@ spec: imagePullSecrets: - name: registry-secret # replace with your own registry secret containers: - - image: #cp-enablement.docker.repositories.sap.ondemand.com/easyfranchise/broker # use your own image + - image: # use your own image name: broker imagePullPolicy: Always env: diff --git a/code/easyfranchise/deployment/k8s/business-partner-mock.yaml b/code/easyfranchise/deployment/k8s/business-partner-mock.yaml index 4b60e57..22936e1 100644 --- a/code/easyfranchise/deployment/k8s/business-partner-mock.yaml +++ b/code/easyfranchise/deployment/k8s/business-partner-mock.yaml @@ -18,7 +18,7 @@ spec: imagePullSecrets: - name: registry-secret # replace with your own registry secret containers: - - image: # e.g. cp-enablement.docker.repositories.sap.ondemand.com/com.sap.easyfranchise/s4hanamock: + - image: # use your own image name: business-partner-mock imagePullPolicy: Always ports: diff --git a/code/easyfranchise/source/README.md b/code/easyfranchise/source/README.md new file mode 100644 index 0000000..bd88826 --- /dev/null +++ b/code/easyfranchise/source/README.md @@ -0,0 +1,14 @@ +# Easy Franchise Components + +This section contains all components that are needed to run the Easy Franchise application. + +- [backend](backend): JAVA-based backend services that manage database, SAP S/4HANA Cloud system and the logic of the application + - [Database Service](backend/db-service) + - [Business Partner Service](backend/bp-service) + - [Easy Franchise Service](backend/ef-service) +- [email-service](email-service): node.js-based service that sends notifications +- [ui](ui): vue.js-based user interface +- [Approuter](approuter): node.js-based application router for authorization and authentication +- [broker](broker): service that onboards/offboards new customers of the multitenant application +- [business-partner-mock-server](business-partner-mock-server): service to simulate an SAP S/4HANA Cloud system if not available + diff --git a/code/easyfranchise/source/approuter/approuter-start.js b/code/easyfranchise/source/approuter/approuter-start.js index c5b5b74..4eee10e 100644 --- a/code/easyfranchise/source/approuter/approuter-start.js +++ b/code/easyfranchise/source/approuter/approuter-start.js @@ -1,7 +1,7 @@ -const jwt_decode = require('jwt-decode'); const approuter = require('@sap/approuter'); const xssec = require('@sap/xssec'); const xsenv = require('@sap/xsenv'); +const { jwtDecode } = require('jwt-decode'); var ar = approuter(); ar.beforeRequestHandler.use('/backend', function (req, res, next) { @@ -10,7 +10,7 @@ ar.beforeRequestHandler.use('/backend', function (req, res, next) { res.statusCode = 403; res.end("Missing JWT Token"); } else { - const decodedToken = jwt_decode(token); + const decodedToken = jwtDecode(token); const tenant = decodedToken && decodedToken.zid; req.headers['x-tenant-id'] = tenant; next(); @@ -24,7 +24,7 @@ ar.beforeRequestHandler.use('/userInfo', function (req, res, next) { res.end("Missing JWT Token"); } else { res.statusCode = 200; - let decodedToken = jwt_decode(token); + let decodedToken = jwtDecode(token); res.end(JSON.stringify({ userid: decodedToken.user_name, email: decodedToken.email, diff --git a/code/easyfranchise/source/approuter/package.json b/code/easyfranchise/source/approuter/package.json index d3e2d2e..51e9053 100644 --- a/code/easyfranchise/source/approuter/package.json +++ b/code/easyfranchise/source/approuter/package.json @@ -7,13 +7,13 @@ "start": "node approuter-start.js" }, "dependencies": { - "@sap/approuter": "10.8.2", - "@sap/xsenv": "^3.1.1", - "@sap/xssec": "^3.2.8", - "jwt-decode": "^3.1.2" + "@sap/approuter": "14.3.4", + "@sap/xsenv": "^4.0.0", + "@sap/xssec": "^3.4.0", + "jwt-decode": "^4.0.0" }, "devDependencies": {}, "engines": { - "node": "14.x.x" + "node": "20.x.x" } } diff --git a/code/easyfranchise/source/approuter/readme.md b/code/easyfranchise/source/approuter/readme.md new file mode 100644 index 0000000..038ea28 --- /dev/null +++ b/code/easyfranchise/source/approuter/readme.md @@ -0,0 +1,3 @@ +# Easy Franchise Approuter + +Please refer to [documentation](/documentation/explore/approuter/README.md) for more details. diff --git a/code/easyfranchise/source/backend/README.md b/code/easyfranchise/source/backend/README.md new file mode 100644 index 0000000..ebe4438 --- /dev/null +++ b/code/easyfranchise/source/backend/README.md @@ -0,0 +1,3 @@ +# Easy Franchise Backend + +Please refer to [documentation](/documentation/explore/README.md) for more details. diff --git a/code/easyfranchise/source/backend/bp-service/src/main/java/dev/kyma/samples/easyfranchise/bpservice/BPService.java b/code/easyfranchise/source/backend/bp-service/src/main/java/dev/kyma/samples/easyfranchise/bpservice/BPService.java index c915ef1..9440f4d 100644 --- a/code/easyfranchise/source/backend/bp-service/src/main/java/dev/kyma/samples/easyfranchise/bpservice/BPService.java +++ b/code/easyfranchise/source/backend/bp-service/src/main/java/dev/kyma/samples/easyfranchise/bpservice/BPService.java @@ -1,8 +1,5 @@ package dev.kyma.samples.easyfranchise.bpservice; -import java.net.InetSocketAddress; -import java.net.Proxy; - import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,10 +16,10 @@ import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.container.ContainerRequestContext; import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.UriInfo; -import jakarta.ws.rs.core.HttpHeaders; /** * Rest service for S/4HANA connectivity * diff --git a/code/easyfranchise/source/backend/pom.xml b/code/easyfranchise/source/backend/pom.xml index d297969..b4f38d4 100644 --- a/code/easyfranchise/source/backend/pom.xml +++ b/code/easyfranchise/source/backend/pom.xml @@ -7,9 +7,9 @@ 1.0-SNAPSHOT pom - 11.0.3 - 3.0.1 - 2.0.0-alpha1 + 11.0.18 + 3.1.3 + 2.0.9 ISO-8859-1 @@ -20,7 +20,7 @@ maven-compiler-plugin 3.8.1 - 15 + 17 diff --git a/code/easyfranchise/source/backend/shared-code/src/main/java/dev/kyma/samples/easyfranchise/communication/Connection.java b/code/easyfranchise/source/backend/shared-code/src/main/java/dev/kyma/samples/easyfranchise/communication/Connection.java index 74f5052..15371c7 100644 --- a/code/easyfranchise/source/backend/shared-code/src/main/java/dev/kyma/samples/easyfranchise/communication/Connection.java +++ b/code/easyfranchise/source/backend/shared-code/src/main/java/dev/kyma/samples/easyfranchise/communication/Connection.java @@ -4,9 +4,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.Proxy; import java.net.SocketTimeoutException; import java.net.URL; import java.nio.charset.StandardCharsets; diff --git a/code/easyfranchise/source/broker/readme.md b/code/easyfranchise/source/broker/readme.md new file mode 100644 index 0000000..51eca26 --- /dev/null +++ b/code/easyfranchise/source/broker/readme.md @@ -0,0 +1,3 @@ +# Broker + +Please refer to [documentation](/documentation/explore/broker/README.md) for more details. diff --git a/code/easyfranchise/source/business-partner-mock-server/readme.md b/code/easyfranchise/source/business-partner-mock-server/readme.md new file mode 100644 index 0000000..356df18 --- /dev/null +++ b/code/easyfranchise/source/business-partner-mock-server/readme.md @@ -0,0 +1,3 @@ +# SAP Business Partner Mock Server + +Please refer to [documentation](/documentation/appendix/business-partner-mock) for more details. diff --git a/code/easyfranchise/source/business-partner-mock-server/server.js b/code/easyfranchise/source/business-partner-mock-server/server.js index 0975c63..ac92f99 100644 --- a/code/easyfranchise/source/business-partner-mock-server/server.js +++ b/code/easyfranchise/source/business-partner-mock-server/server.js @@ -17,7 +17,7 @@ app.get('/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner', function (r }); }) -var server = app.listen(8081, '127.0.0.1', function () { +var server = app.listen(8081, '0.0.0.0', function () { var host = server.address().address; if (host === '::') { host = 'localhost'; diff --git a/code/easyfranchise/source/email-service/README.md b/code/easyfranchise/source/email-service/README.md new file mode 100644 index 0000000..c777129 --- /dev/null +++ b/code/easyfranchise/source/email-service/README.md @@ -0,0 +1,3 @@ +# Email Service + +Please refer to [documentation](/documentation/explore/email-service/README.md) for more details. diff --git a/code/easyfranchise/source/ui/README.md b/code/easyfranchise/source/ui/README.md new file mode 100644 index 0000000..407c6d2 --- /dev/null +++ b/code/easyfranchise/source/ui/README.md @@ -0,0 +1,3 @@ +# Easy Franchise Backend + +Please refer to [documentation](/documentation/explore/ui/README.md) for more details. diff --git a/code/easyfranchise/source/ui/public/index.html b/code/easyfranchise/source/ui/public/index.html index cb1d076..4cae005 100644 --- a/code/easyfranchise/source/ui/public/index.html +++ b/code/easyfranchise/source/ui/public/index.html @@ -4,7 +4,7 @@ - + <%= htmlWebpackPlugin.options.title %> diff --git a/code/easyfranchise/source/ui/vue.config.js b/code/easyfranchise/source/ui/vue.config.js index 5e8bf56..a70a685 100644 --- a/code/easyfranchise/source/ui/vue.config.js +++ b/code/easyfranchise/source/ui/vue.config.js @@ -2,6 +2,6 @@ module.exports = { devServer: { host: '0.0.0.0', hot: true, - allowedHosts: "all", + allowedHosts: ['all'], }, }; \ No newline at end of file diff --git a/code/setup/btp-setup-automator/btpsa-deployment.sh b/code/setup/btp-setup-automator/btpsa-deployment.sh index 42450f6..ff58c23 100644 --- a/code/setup/btp-setup-automator/btpsa-deployment.sh +++ b/code/setup/btp-setup-automator/btpsa-deployment.sh @@ -143,7 +143,63 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then log "####################################################################################################" echo "" - log "Step 2.1 - Create Namepaces" + log "Step 2.1 - Enable BTP Operator" + # Download and Install Kyma CLI + curl -Lo kyma.tar.gz "https://github.com/kyma-project/cli/releases/download/$(curl -s https://api.github.com/repos/kyma-project/cli/releases/latest | grep tag_name | cut -d '"' -f 4)/kyma_Linux_x86_64.tar.gz" \ + && mkdir kyma-release && tar -C kyma-release -zxvf kyma.tar.gz && chmod +x kyma-release/kyma && sudo mv kyma-release/kyma /usr/local/bin \ + && rm -rf kyma-release kyma.tar.gz + + # Wait for Kyma CLI to be ready + KYMA_CLI_READY=0 + MAX_RETRIES=5 + RETRY_INTERVAL=5 + + for ((i=1; i<=MAX_RETRIES; i++)); do + if kyma version; then + KYMA_CLI_READY=1 + break + else + echo "Waiting for Kyma CLI to be ready... retry $i/$MAX_RETRIES" + sleep $RETRY_INTERVAL + fi + done + + if [ $KYMA_CLI_READY -eq 0 ]; then + echo "Kyma CLI is not ready. Exiting..." + exit 1 + else + echo "Kyma CLI is ready." + fi + + # Enable BTP Operator + kyma alpha enable module btp-operator --channel regular --kyma-name default --wait + + + # Wait for BTP Operator to be ready + BTP_OPERATOR_READY=0 + MAX_RETRIES=30 + RETRY_INTERVAL=10 + + for ((i=1; i<=MAX_RETRIES; i++)); do + if kubectl get pods -n kyma-system | grep -q 'btp-operator.*Running'; then + BTP_OPERATOR_READY=1 + break + else + echo "Waiting for BTP Operator to be ready... retry $i/$MAX_RETRIES" + sleep $RETRY_INTERVAL + fi + done + + if [ $BTP_OPERATOR_READY -eq 0 ]; then + echo "BTP Operator is not ready. Exiting..." + exit 1 + else + echo "BTP Operator is ready." + fi + + echo + + log "Step 2.2 - Create Namepaces" kubectl create namespace integration || true kubectl create namespace backend || true kubectl create namespace mock || true @@ -155,57 +211,57 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then kubectl label namespace frontend istio-injection=enabled --overwrite || true echo - log "Step 2.2 - DB Secret: " + log "Step 2.3 - DB Secret: " cat /home/user/tutorial/code/easyfranchise/deployment/k8s/db-secret.yaml | sed "s~~$DB_SQLENDPOINT~g" | sed "s~~$DB_ADMIN~g" | sed "s~~$DB_ADMIN_PASSWORD~g" | kubectl apply -f - || true echo - log "Step 2.3 - Backend Configmap" + log "Step 2.4 - Backend Configmap" kubectl apply -n backend -f /home/user/tutorial/code/easyfranchise/deployment/k8s/backend-configmap.yaml kubectl apply -n integration -f /home/user/tutorial/code/easyfranchise/deployment/k8s/backend-configmap.yaml echo - log "Step 2.4 - BTP Service Deployment" + log "Step 2.5 - BTP Service Deployment" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/btp-services.yaml" | sed "s~~$SUBDOMAIN~g" | sed "s~~$CLUSTER_DOMAIN~g" | kubectl apply -f - echo PROJECT=approuter - log "Step 2.5 - Deploy $PROJECT" + log "Step 2.6 - Deploy $PROJECT" FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_APPROUTER:$BTPSA_KYMA_IMAGE_TAG cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | sed "s~~$SUBDOMAIN~g" | sed "s~~$CLUSTER_DOMAIN~g" | kubectl apply -f - PROJECT=db-service FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_DB_SERVICE:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.6 - Deploy $PROJECT" + log "Step 2.7 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - PROJECT=bp-service FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_BP_SERVICE:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.7 - Deploy $PROJECT" + log "Step 2.8 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - PROJECT=ef-service FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_EF_SERVICE:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.8 - Deploy $PROJECT" + log "Step 2.9 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - PROJECT=broker FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_BROKER:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.9 - Deploy $PROJECT" + log "Step 2.10 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - PROJECT=email-service FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_EMAIL_SERVICE:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.10 - Deploy $PROJECT" + log "Step 2.11 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - PROJECT=ui FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_UI:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.11 - Deploy $PROJECT" + log "Step 2.12 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - PROJECT=business-partner-mock FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_BUSINESS_PARTNER_MOCK:$BTPSA_KYMA_IMAGE_TAG - log "Step 2.12 - Deploy $PROJECT" + log "Step 2.13 - Deploy $PROJECT" cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~~$FULL_NAME~g" | kubectl apply -f - @@ -214,15 +270,15 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then kubectl label namespace day2-operations istio-injection=enabled --overwrite || true PROJECT=day2-approuter - log "Step 2.13 - Deploy $PROJECT" + log "Step 2.14 - Deploy $PROJECT" helm upgrade "$PROJECT" "/home/user/tutorial/code/day2-operations/deployment/helmCharts/day2-approuter-chart" --install --namespace "day2-operations" --set clusterdomain="$CLUSTER_DOMAIN" --set image.repository="$BTPSA_KYMA_IMAGE_NAME_DAY2_APPROUTER" --set image.tag="$BTPSA_KYMA_IMAGE_TAG" --wait --timeout 90s --atomic PROJECT=day2-ui - log "Step 2.14 - Deploy $PROJECT" + log "Step 2.15 - Deploy $PROJECT" helm upgrade "$PROJECT" "/home/user/tutorial/code/day2-operations/deployment/helmCharts/day2-ui-chart" --install --namespace "day2-operations" --set image.repository="$BTPSA_KYMA_IMAGE_NAME_DAY2_UI" --set image.tag="$BTPSA_KYMA_IMAGE_TAG" --wait --timeout 90s --atomic PROJECT=day2-service - log "Step 2.15 - Deploy $PROJECT" + log "Step 2.16 - Deploy $PROJECT" helm upgrade "$PROJECT" "/home/user/tutorial/code/day2-operations/deployment/helmCharts/day2-service-chart" --install --namespace "day2-operations" --set db.sqlendpoint="$DB_SQLENDPOINT" --set db.admin="$DB_ADMIN" --set db.password="$DB_ADMIN_PASSWORD" --set image.repository="$BTPSA_KYMA_IMAGE_NAME_DAY2_SERVICE" --set image.tag="$BTPSA_KYMA_IMAGE_TAG" --wait --timeout 90s --atomic fi fi diff --git a/code/setup/easyfranchise-deployment.sh b/code/setup/easyfranchise-deployment.sh old mode 100755 new mode 100644 index aefd5c8..0a8bbfb --- a/code/setup/easyfranchise-deployment.sh +++ b/code/setup/easyfranchise-deployment.sh @@ -319,7 +319,66 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then log "=================================================================================================" echo "" - log "Step 3.1 - Create Namepaces" + log "Step 3.1 - Enable BTP Operator" + if [ "$DRY_RUN" = false ]; then + # Download and Install Kyma CLI + curl -Lo kyma.tar.gz "https://github.com/kyma-project/cli/releases/download/$(curl -s https://api.github.com/repos/kyma-project/cli/releases/latest | grep tag_name | cut -d '"' -f 4)/kyma_Linux_x86_64.tar.gz" \ + && mkdir kyma-release && tar -C kyma-release -zxvf kyma.tar.gz && chmod +x kyma-release/kyma && sudo mv kyma-release/kyma /usr/local/bin \ + && rm -rf kyma-release kyma.tar.gz + + # Wait for Kyma CLI to be ready + KYMA_CLI_READY=0 + MAX_RETRIES=5 + RETRY_INTERVAL=5 + + for ((i=1; i<=MAX_RETRIES; i++)); do + if kyma version; then + KYMA_CLI_READY=1 + break + else + echo "Waiting for Kyma CLI to be ready... retry $i/$MAX_RETRIES" + sleep $RETRY_INTERVAL + fi + done + + if [ $KYMA_CLI_READY -eq 0 ]; then + echo "Kyma CLI is not ready. Exiting..." + exit 1 + else + echo "Kyma CLI is ready." + fi + + # Enable BTP Operator + kyma alpha enable module btp-operator --channel regular --kyma-name default --wait + + + # Wait for BTP Operator to be ready + BTP_OPERATOR_READY=0 + MAX_RETRIES=30 + RETRY_INTERVAL=10 + + for ((i=1; i<=MAX_RETRIES; i++)); do + if kubectl get pods -n kyma-system | grep -q 'btp-operator.*Running'; then + BTP_OPERATOR_READY=1 + break + else + echo "Waiting for BTP Operator to be ready... retry $i/$MAX_RETRIES" + sleep $RETRY_INTERVAL + fi + done + + if [ $BTP_OPERATOR_READY -eq 0 ]; then + echo "BTP Operator is not ready. Exiting..." + exit 1 + else + echo "BTP Operator is ready." + fi + else + log "Skipped for Dry Run" + fi + + echo + log "Step 3.2 - Create Namepaces" if [ "$DRY_RUN" = false ]; then kubectl create namespace integration || true kubectl create namespace backend || true @@ -335,7 +394,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then fi echo - log "Step 3.2 - Create Secrets, Configmap and depended Services" + log "Step 3.3 - Create Secrets, Configmap and depended Services" echo log "DB Secret: " if [ "$DRY_RUN" = true ]; then