Skip to content

Commit

Permalink
Migrated to BTP-Operator
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRieder committed Jun 8, 2022
1 parent 3a8c88e commit 23e0956
Show file tree
Hide file tree
Showing 132 changed files with 3,074 additions and 69 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
node_modules
75 changes: 50 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,66 @@
# SAP-samples/repository-template
This default template for SAP Samples repositories includes files for README, LICENSE, and .reuse/dep5. All repositories on github.com/SAP-samples will be created based on this template.
# Easy Franchise: Extend a Kyma-Based Multitenant Application with Day 2 Operations
<!--
TODO: update the url of the Discovery mission once it's created.
TODO: generate and add the reuse license
-->
> Important information: The content of this GitHub repository has been created as a source for the [Enrich a Kyma based multitenant application with new identity features](https://discovery-center.cloud.sap/missiondetail/url-to-be-updated) mission at SAP Discovery Center. So, we recommend you use directly the mission in the SAP Discovery Center for a better experience.
## Description
This mission explains how to extend a Kyma-based multitenant application with day 2 operations topics like continuous integration and delivery, observability and metering.

It is related to the [Develop a Multitenant Extension Application in SAP BTP, Kyma Runtime](https://discovery-center.cloud.sap/missiondetail/3683/3726/) mission.
<!--
todo reface below chapter
-->

# Containing Files
As a result, in this mission everything will be based on the multitenant application called Easy Franchise, which is a multitenant application running on SAP BTP, Kyma environment and extending SAP S/4HANA Cloud. We highly recommend that you have a look at the above mentioned mission where you can find all the necessary details. Be aware that we will not spend so much time here explaining the application. We will rather focus on enriching it with new features.

1. The LICENSE file:
In most cases, the license for SAP sample projects is `Apache 2.0`.
For the sake of simplicity, our team has taken some compromise compared to a real application. So, this application doesn't aim to be used productively.
<!--
TODO: we should have here the new target solution diagramm with the day 2 services!
-->
Here is an overview diagram of the Easy Franchise application:
![](https://raw.githubusercontent.com/SAP-samples/btp-kyma-multitenant-extension/main/documentation/images/easyfranchise-diagrams/Slide4.jpeg)

2. The .reuse/dep5 file:
The [Reuse Tool](https://reuse.software/) must be used for your samples project. You can find the .reuse/dep5 in the project initial. Please replace the parts inside the single angle quotation marks < > by the specific information for your repository.
The repository has been structured in 2 sections:
* [documentation](/documentation/README.md): Contains the content of the mission, explaining in details how to enrich the existing Easy Franchise application.
* [code](/code/README.md): Contains the code and the deployment files of the multitenant application Easy Franchise and the Metering Dashboard Application. In addition, the [setup](https://github.tools.sap/saas-extension-on-kyma/easyfranchise-day2/tree/main/code/setup) folder contains a script to set up the required SAP BTP environment and another script to deploy the Easy Franchise application automatically.

3. The README.md file (this file):
Please edit this file as it is the primary description file for your project. You can find some placeholder titles for sections below.

# [Title]
<!-- Please include descriptive title -->
## Who Is This Mission For?

<!--- Register repository https://api.reuse.software/register, then add REUSE badge:
[![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/REPO-NAME)](https://api.reuse.software/info/github.com/SAP-samples/REPO-NAME)
-->
The business scenario of this mission has been created with the SAP partner as focus persona. This is, of course, not exclusively relevant for SAP partners and can be useful for every person (developer, operator, architect) looking for details on how to enrich a multitenant application running on Kyma with day 2 operations topics like continuous integration and delivery, observability and metering.
As mentioned before, we highly recommend to start with the [Develop a Multitenant Extension Application in SAP BTP, Kyma Runtime](https://discovery-center.cloud.sap/missiondetail/3683/3726/) mission as we are expecting some prior knowledge (for example, Kyma, and SAP BTP) to run this mission. As we are concentrating on advanced topics, this mission is mainly suitable for experienced developers on SAP Business Technology Platform (SAP BTP).

## Description
<!-- Please include SEO-friendly description -->
## Focus Topics of the Mission

The mission focuses on the following aspects:
- Observability (logging, monitoring and alerting)
- Metering
- Continuous integration and delivery deployment

## Requirements

## Download and Installation
You can find all requirements to execute the mission in this [Prerequisites](/documentation/discover/prerequisites/README.md) section.

## Known Issues
<!-- You may simply state "No known issues. -->

## How to obtain support
[Create an issue](https://github.com/SAP-samples/<repository-name>/issues) in this repository if you find a bug or have questions about the content.

For additional support, [ask a question in SAP Community](https://answers.sap.com/questions/ask.html).
The mission is provided on the "as-is" basis. Currently, there are no known issues for the project.

## How to Get Support?

Check if you find an answer in the [Troubleshooting](/documentation/troubleshooting/README.md) section.

Create an issue to get support, report a bug at the [Issues](https://github.com/SAP-samples/btp-kyma-multitenant-extension/issues/new/choose) section or interact with us via the SAP Discovery Center, in the *Conversations* section of the Project Board of the mission..

## Contributing
If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses [the standard DCO text of the Linux Foundation](https://developercertificate.org/).
## How to Provide Feedback?

Have you found the enablement material easy to understand? Are you missing something? What can we improve? [Share your feedback](https://github.com/SAP-samples/btp-kyma-multitenant-extension/issues/new/choose), so that we can improve the documentation and provide a better material for future stakeholders.

## What's New

Check the details of our last [releases](/documentation/discover/whats-new/README.md).

## License
Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file.

Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the (TODO update licence licences link) file.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ metadata:
data:
cluster-domain: {{ .Values.clusterdomain }} ## adapt to your Kyma cluster
---
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: xsuaa-service
namespace: day2-operations
spec:
clusterServiceClassExternalName: xsuaa
clusterServicePlanExternalName: broker # https://jam4.sapjam.com/blogs/show/2dxT4cVGxTXZRJT0D1DQQM
serviceOfferingName: xsuaa
servicePlanName: broker # https://jam4.sapjam.com/blogs/show/2dxT4cVGxTXZRJT0D1DQQM
externalName: xsuaa-service-external
parameters:
xsappname: day2-operations
tenant-mode: dedicated # use "shared" for multi-tenant application
Expand All @@ -129,12 +130,13 @@ spec:
- http://localhost:5000/login/callback
token-validity: 900
---
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: xsuaa-service-binding
namespace: day2-operations
spec:
instanceRef:
name: xsuaa-service
serviceInstanceName: xsuaa-service
externalName: xsuaa-service-external
secretName: xsuaa-service-binding
---
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
creationTimestamp: null
labels:
app: day2-service
sidecar.istio.io/inject: "false" # disable istio injection, otherwise facing "connection reset by peer" error
sidecar.istio.io/inject: "false" # disable istio injection, otherwise facing "connection reset by peer" error, when in use with Dynatrace in the Observability context
spec:
imagePullSecrets:
- name: registry-secret
Expand Down
4 changes: 2 additions & 2 deletions code/day2-operations/deployment/k8s/fluentbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ spec:
spec:
containers:
- name: fluent-bit
image: fluent/fluent-bit:1.8-debug # 1.8
imagePullPolicy: Always
image: fluent/fluent-bit:1.9.3 # 1.9.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 2020
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.slf4j.LoggerFactory;

@Component
public class C3P0ConnectionPoolMetricsScheduler {
public class C3P0ConnectionPoolMetricsScheduler { // TODO: what was the reason to name this class C3P0? please add class documentation

private static final Logger logger = LoggerFactory.getLogger(C3P0ConnectionPoolMetricsScheduler.class);

Expand Down Expand Up @@ -36,4 +36,4 @@ public void schedulingTask() {
C3P0GaugeController.retrieveMetrics(attributeClient);
}

}
}
3 changes: 3 additions & 0 deletions code/day2-operations/source/day2-ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
package-lock.json

42 changes: 24 additions & 18 deletions code/easyfranchise/deployment/k8s/btp-services.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: xsuaa-service
namespace: integration
spec:
clusterServiceClassExternalName: xsuaa
clusterServicePlanExternalName: broker # https://jam4.sapjam.com/blogs/show/2dxT4cVGxTXZRJT0D1DQQM
serviceOfferingName: xsuaa
servicePlanName: broker # https://jam4.sapjam.com/blogs/show/2dxT4cVGxTXZRJT0D1DQQM
externalName: xsuaa-service-external
parameters:
xsappname: easyfranchise
tenant-mode: shared # use "shared" for multi-tenant application
Expand Down Expand Up @@ -38,24 +39,26 @@ spec:
- http://localhost:5000/login/callback
token-validity: 900
---
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: xsuaa-service-binding
namespace: integration
spec:
instanceRef:
name: xsuaa-service
serviceInstanceName: xsuaa-service
externalName: xsuaa-service-external
secretName: xsuaa-service-binding
---
# # Resource to create instance for SaaS Registry services
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: saas-registry-service
namespace: integration
spec:
clusterServiceClassExternalName: saas-registry
clusterServicePlanExternalName: application
serviceOfferingName: saas-registry
servicePlanName: application
externalName: saas-registry-service-external
parameters:
# the xsappname refers to the one defined in xsuaa service
xsappname: easyfranchise
Expand All @@ -67,32 +70,35 @@ spec:
onSubscription: https://subscription.<cluster-domain>/callback/v1.0/tenants/{tenantId}
getDependencies: https://subscription.<cluster-domain>/callback/v1.0/dependencies
---
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: saas-registry-service-binding
namespace: integration
spec:
instanceRef:
name: saas-registry-service
serviceInstanceName: saas-registry-service
externalName: saas-registry-service-external
secretName: saas-registry-service-binding
---
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: ef-destination-service
namespace: integration
spec:
clusterServiceClassExternalName: destination
clusterServicePlanExternalName: lite
serviceOfferingName: destination
servicePlanName: lite
externalName: ef-destination-service-external
---
apiVersion: servicecatalog.k8s.io/v1beta1
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: destination-service-binding
namespace: integration
spec:
instanceRef:
name: ef-destination-service
serviceInstanceName: ef-destination-service
externalName: ef-destination-service-external
secretName: destination-service-binding
---
apiVersion: gateway.kyma-project.io/v1alpha1
kind: APIRule
Expand Down
69 changes: 57 additions & 12 deletions code/setup/btp-setup-automator/btpsa-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ log() {
echo -e "${yellow}$*${no_color}"
}

# user selection via passed array
# return ( index value)
createmenu() {
#echo "Size of array: $#"
#echo "$@"
select option; do # in "$@" is the default
if [ "$REPLY" -eq "$#" ];
then
#echo "Exiting..."
break;
elif [ 1 -le "$REPLY" ] && [ "$REPLY" -le $(($#-1)) ];
then
#echo "You selected $option which is option $REPLY"
break;
else
echo "Incorrect Input: Select a number 1-$#"
fi
done
retval=$REPLY
}


read_automator_config() {
result=$(jq '.' /home/user/log/metadata_log.json)
SUBDOMAIN=$(jq -r '."subdomain"' <<< "${result}")
Expand All @@ -16,7 +38,7 @@ read_automator_config() {
DB_ADMIN="DBADMIN"
DB_ADMIN_PASSWORD="$( echo "$result" | jq -r '.createdServiceInstances[] | select(.name == "hana-cloud") | .parameters.data.systempassword' 2> /dev/null)"

DB_DASHBOARD="$( echo "$result" | jq -r '.createdServiceInstances[] | select(.name == "hana-cloud") | .statusResponse | .dashboard ' 2> /dev/null)"
DB_DASHBOARD="$( echo "$result" | jq -r '.createdServiceInstances[] | select(.name == "hana-cloud") | .statusResponse | ."dashboard url" ' 2> /dev/null)"
DB_HOST="${DB_DASHBOARD#*?host=}"
DB_HOST=${DB_HOST/&component*}
DB_PORT=${DB_DASHBOARD/*port=/}
Expand All @@ -29,10 +51,29 @@ echo "##########################################################################
echo ""
read_automator_config

# log "Choose Deployment option, Variant 1 will deploy the application ready for the Mission. Variant 2 contains all the enhancements which will be introduced throughout the mission:"
# declare -a arr="(Mission-Start Mission-End)" # must be quoted like this
#createmenu "${arr[@]}"
#VARIANT_NUMBER="$retval"

#case $VARIANT_NUMBER in
# 1)
# BTPSA_KYMA_IMAGE_TAG="main"
# ;;&
# 2)
# BTPSA_KYMA_IMAGE_TAG="final"
# log "Checkout final branch"
# cd /home/user/tutorial || exit
# git checkout final
# ;;
#esac

# Summary Step 1
echo
log "Deployment will be performed with the following attributes:"
echo ""
log "Selected Deployment Variant: $BTPSA_KYMA_IMAGE_TAG"
echo
log "BTP Environment"
log "Provider Subdomain: " "$SUBDOMAIN"
log "Kyma Cluster Domain: " "$CLUSTER_DOMAIN"
Expand All @@ -55,7 +96,6 @@ kubectl create namespace integration || true
kubectl create namespace backend || true
kubectl create namespace mock || true
kubectl create namespace frontend || true
kubectl create namespace day2-operations || true
echo

log "Step 2.2 - DB Secret: "
Expand Down Expand Up @@ -111,17 +151,22 @@ FULL_NAME=$BTPSA_KYMA_IMAGE_NAME_BUSINESS_PARTNER_MOCK:$BTPSA_KYMA_IMAGE_TAG
log "Step 2.12 - Deploy $PROJECT"
cat "/home/user/tutorial/code/easyfranchise/deployment/k8s/$PROJECT.yaml" | sed "s~<image-name>~$FULL_NAME~g" | kubectl apply -f -

PROJECT=day2-approuter
log "Step 2.13 - 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"
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"
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
if [ "$BTPSA_KYMA_IMAGE_TAG" = "final" ]; then
kubectl create namespace day2-operations || true

PROJECT=day2-approuter
log "Step 2.13 - 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"
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"
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

echo
log "####################################################################################################"
Expand Down
Loading

0 comments on commit 23e0956

Please sign in to comment.