Skip to content
Permalink
Browse files
Merge pull request #21 from Anh3h/kubernetes
Complete kubernetes deployment scripts
  • Loading branch information
Anh3h committed Dec 5, 2019
2 parents ed12080 + e3d4a7e commit cdb39820c3b5e7647fc4e21c60788b1c651f1ecd
Showing 16 changed files with 967 additions and 25 deletions.
@@ -1,16 +1,43 @@
# Fineract CN Docker-Compose scripts
This project contains Docker Compose Scripts for running Fineract CN especially in Development.
This project contains Docker and Kubernetes Scripts for deploying Fineract CN, especially in Development.

## Requirements
- Kubernetes
- Docker
- Docker-compose
- Java

# Deploy and provision Fineract CN
# Deploy and provision Fineract CN using Kubernetes
Make sure you set up and connect to your Kubernetes cluster. You can follow [this](https://cwiki.apache.org/confluence/display/FINERACT/Install+and+configure+kubectl+and+Google+Cloud+SDK+on+ubuntu+16.04) guide to set up a Kubernetes cluster on GKE.

- Enter the Kubernetes directory.

`cd kubernetes_scripts`

- To deploy all the Fineract CN services on your cluster, run :

`bash kubectl-start-up.sh`
- You should make sure an external ip address had been assigned to all the deployed services by running:

`kubectl get services`
- Finally provison the microservices by running:

`cd bash_scripts`

`bash provision.sh --deploy-on-kubernetes playground` # where playground is your tenant name

- To shut down and reset you cluster, run:

`bash kubectl-shut-down.sh`

# Deploy and provision Fineract CN using Docker and Docker-compose

You can either deploy and provision Fineract CN automatically using bash scripts or manually using Postman.
Postman is the preferred way as it is more tested and this way you understand better what is happening.
Also this way you don't have to start all the micro services (helpful if your workstation is lacking resources).

## Hints:
- Postman is the preferred approach if you want to understand what is happening and, Bash is preferred when you already understand what's happening so, you simply what to automate the process.

- With Postman, you have more flexibility in deciding which service gets to be deployed and provisioned, therefore, making it the preferred route if you have limited resources.

# 1. Deploy and provision Fineract automatically using bash scripts

@@ -24,7 +51,7 @@ Also this way you don't have to start all the micro services (helpful if your wo

`cd bash_scripts`

`bash provision.sh playground` #where playground is your tenant name
`bash provision.sh playground` # where playground is your tenant name

## 2. Deploy Fineract manually using postman

@@ -181,7 +208,7 @@ docker-compose up

## Integration tests
We have a shell script that verifies if the setup still works.
For this install [Newman](https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/) and
For this install [Newman](https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/) and
run the script ./integration_test.sh. It takes about 15minutes to complete.
Beware that the script overwrites contents of .env file.

@@ -20,7 +20,7 @@ function init-variables {
CUSTOMER_URL="http://customer-ms:2024/customer/v1"
ACCOUNTING_URL="http://accounting-ms:2025/accounting/v1"
PORTFOLIO_URL="http://portfolio-ms:2026/portfolio/v1"
DEPOSIT_URL="http://deposit-account-management-ms:2027/deposit/v1"
DEPOSIT_URL="http://deposit-ms:2027/deposit/v1"
TELLER_URL="http://teller-ms:2028/teller/v1"
REPORT_URL="http://reporting-ms:2029/report/v1"
CHEQUES_URL="http://cheques-ms:2030/cheques/v1"
@@ -44,6 +44,40 @@ function init-variables {
NOTIFICATIONS_MS_NAME="notification-v1"
}

function config-kubernetes-addresss {
kubectl get services -o=jsonpath="{range .items[*]}{.metadata.name}{\"=\"}{.status.loadBalancer.ingress[0].ip}{\"\n\"}{end}" > cluster_addressess.txt
while IFS="=" read -r service ip; do
if [[ ${#ip} -gt 0 ]]
then
case "$service" in
'#'*) ;;
"cassandra-cluster") CASSANDRA_CONTACT_POINTS="$ip:9042" ;;
"postgresdb-cluster") POSTGRES_HOST="$ip" ;;
"provisioner-service") PROVISIONER_URL="http://$ip:2020/provisioner/v1" ;;
"identity-service") IDENTITY_URL="http://$ip:2021/identity/v1" ;;
"rhythm-service") RHYTHM_URL="http://$ip:2022/rhythm/v1" ;;
"office-service") OFFICE_URL="http://$ip:2023/office/v1" ;;
"customer-service") CUSTOMER_URL="http://$ip:2024/customer/v1" ;;
"accounting-service") ACCOUNTING_URL="http://$ip:2025/accounting/v1" ;;
"portfolio-service") PORTFOLIO_URL="http://$ip:2026/portfolio/v1" ;;
"deposit-service") DEPOSIT_URL="http://$ip:2027/deposit/v1" ;;
"teller-service") TELLER_URL="http://$ip:2028/teller/v1" ;;
"reporting-service") REPORT_URL="http://$ip:2029/report/v1" ;;
"cheques-service") CHEQUES_URL="http://$ip:2030/cheques/v1" ;;
"payroll-service") PAYROLL_URL="http://$ip:2031/payroll/v1" ;;
"group-service") GROUP_URL="http://$ip:2032/group/v1" ;;
"notification-service") NOTIFICATIONS_URL="http://$ip:2033/notification/v1" ;;
esac
elif [[ ${service} != "kubernetes" ]]
then
echo "$service ip has not been conigured"
exit 1
fi
done < "cluster_addressess.txt"

echo "Successfully configured kubernetes ip addresses"
}

function auto-seshat {
TOKEN=$( curl -s -X POST -H "Content-Type: application/json" \
"$PROVISIONER_URL"'/auth/token?grant_type=password&client_id=service-runner&username=wepemnefret&password=oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20' \
@@ -378,6 +412,16 @@ function update_ledger {
}

init-variables
if [[ "$1" == "--deploy-on-kubernetes" ]]; then
config-kubernetes-addresss
TENANT=$2
elif [[ "$2" == "--deploy-on-kubernetes" ]]; then
config-kubernetes-addresss
TENANT=$1
else
TENANT=$1
fi

auto-seshat
create-application "$IDENTITY_MS_NAME" "" "$MS_VENDOR" "$IDENTITY_URL"
create-application "$RHYTHM_MS_NAME" "" "$MS_VENDOR" "$RHYTHM_URL"
@@ -393,8 +437,7 @@ create-application "$PAYROLL_MS_NAME" "" "$MS_VENDOR" "$PAYROLL_URL"
create-application "$GROUP_MS_NAME" "" "$MS_VENDOR" "$GROUP_URL"
create-application "$NOTIFICATIONS_MS_NAME" "" "$MS_VENDOR" "$NOTIFICATIONS_URL"

# # Set tenant identifier
TENANT=$1
# Set tenant identifier
create-tenant ${TENANT} "${TENANT}" "All in one Demo Server" ${TENANT}
assign-identity-ms ${TENANT}
login ${TENANT} "antony" $ADMIN_PASSWORD
@@ -0,0 +1,78 @@
apiVersion: v1
kind: Service
metadata:
name: accounting-service
namespace: default
spec:
selector:
app: accounting-ms
ports:
- port: 2025
targetPort: 2025
type: LoadBalancer

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: accounting-ms-cluster
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: accounting-ms
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: accounting-ms
spec:
containers:
- name: fineract-cn-accounting
image: apache/fineract-cn-accounting:latest
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: external-tools-config
- configMapRef:
name: fineract-service-config
env:
- name: eureka.instance.hostname
value: accounting-ms
- name: server.port
value: "2025"
- name: spring.application.name
value: accounting-v1
- name: system.publicKey.modulus
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_MODULUS
name: secret-config
- name: system.publicKey.exponent
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_EXPONENT
name: secret-config
- name: system.publicKey.timestamp
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_TIMESTAMP
name: secret-config
- name: system.privateKey.modulus
valueFrom:
configMapKeyRef:
key: PRIVATE_KEY_MODULUS
name: secret-config
- name: system.privateKey.exponent
valueFrom:
configMapKeyRef:
key: PRIVATE_KEY_EXPONENT
name: secret-config
ports:
- containerPort: 2025
@@ -0,0 +1,78 @@
apiVersion: v1
kind: Service
metadata:
name: cheques-service
namespace: default
spec:
selector:
app: cheques-ms
ports:
- port: 2030
targetPort: 2030
type: LoadBalancer

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cheques-ms-cluster
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: cheques-ms
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: cheques-ms
spec:
containers:
- name: cheques-ms
image: apache/fineract-cn-cheques:latest
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: external-tools-config
- configMapRef:
name: fineract-service-config
env:
- name: eureka.instance.hostname
value: cheques-ms
- name: server.port
value: "2030"
- name: spring.application.name
value: cheques-v1
- name: system.publicKey.modulus
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_MODULUS
name: secret-config
- name: system.publicKey.exponent
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_EXPONENT
name: secret-config
- name: system.publicKey.timestamp
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_TIMESTAMP
name: secret-config
- name: system.privateKey.modulus
valueFrom:
configMapKeyRef:
key: PRIVATE_KEY_MODULUS
name: secret-config
- name: system.privateKey.exponent
valueFrom:
configMapKeyRef:
key: PRIVATE_KEY_EXPONENT
name: secret-config
ports:
- containerPort: 2030
@@ -24,9 +24,4 @@ data:
ribbon.eureka.enabled: "true"
server.max-http-header-size: "16384"
spring.cloud.config.enabled: "false"
spring.cloud.discovery.enabled: "true"
system.privateKey.exponent: ${PRIVATE_KEY_EXPONENT}
system.privateKey.modulus: ${PRIVATE_KEY_MODULUS}
system.publicKey.exponent: ${PUBLIC_KEY_EXPONENT}
system.publicKey.modulus: ${PUBLIC_KEY_MODULUS}
system.publicKey.timestamp: ${PUBLIC_KEY_TIMESTAMP}
spring.cloud.discovery.enabled: "true"
@@ -0,0 +1,78 @@
apiVersion: v1
kind: Service
metadata:
name: customer-service
namespace: default
spec:
selector:
app: customer-ms
ports:
- port: 2024
targetPort: 2024
type: LoadBalancer

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: customer-ms-cluster
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: customer-ms
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: customer-ms
spec:
containers:
- name: customer-ms
image: apache/fineract-cn-customer:latest
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: external-tools-config
- configMapRef:
name: fineract-service-config
env:
- name: eureka.instance.hostname
value: customer-ms
- name: server.port
value: "2024"
- name: spring.application.name
value: customer-v1
- name: system.publicKey.modulus
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_MODULUS
name: secret-config
- name: system.publicKey.exponent
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_EXPONENT
name: secret-config
- name: system.publicKey.timestamp
valueFrom:
configMapKeyRef:
key: PUBLIC_KEY_TIMESTAMP
name: secret-config
- name: system.privateKey.modulus
valueFrom:
configMapKeyRef:
key: PRIVATE_KEY_MODULUS
name: secret-config
- name: system.privateKey.exponent
valueFrom:
configMapKeyRef:
key: PRIVATE_KEY_EXPONENT
name: secret-config
ports:
- containerPort: 2024

0 comments on commit cdb3982

Please sign in to comment.