You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vo...@apache.org on 2020/04/12 09:06:46 UTC

[fineract] branch develop updated (beee2e5 -> a9c2140)

This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git.


    from beee2e5  Fixed: Checkstyle Violations
     new 472f5b6  FINERACT-783  - Update README.md with instructions for kubernetes  - Setup fineractmysql configuration file  - Setup fineract-server configuration file closes https://issues.apache.org/jira/browse/FINERACT-783
     new a9c2140  Setup configMap and startup and shutdown scripts

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README.md                                          |  36 +++++++
 kubernetes/fineract-server-deployment.yml          |  79 ++++++++++++++
 .../fineractmysql-configmap.yml                    |  27 +++--
 kubernetes/fineractmysql-deployment.yml            | 120 +++++++++++++++++++++
 .../kubectl-shutdown.sh                            |   9 +-
 kubernetes/kubectl-startup.sh                      |  42 ++++++++
 .../secrets.yml                                    |  13 ++-
 7 files changed, 305 insertions(+), 21 deletions(-)
 create mode 100644 kubernetes/fineract-server-deployment.yml
 copy fineract-provider/src/main/dist/runfineract.sh => kubernetes/fineractmysql-configmap.yml (70%)
 mode change 100755 => 100644
 create mode 100644 kubernetes/fineractmysql-deployment.yml
 copy fineract-provider/properties/oauth/application.properties => kubernetes/kubectl-shutdown.sh (80%)
 create mode 100644 kubernetes/kubectl-startup.sh
 copy fineract-provider/properties/oauth/application.properties => kubernetes/secrets.yml (82%)


[fineract] 01/02: FINERACT-783 - Update README.md with instructions for kubernetes - Setup fineractmysql configuration file - Setup fineract-server configuration file closes https://issues.apache.org/jira/browse/FINERACT-783

Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit 472f5b6280864d46c2ac58fdc06f3a180995718a
Author: xurror <xu...@localhost.localdomain>
AuthorDate: Mon Feb 10 06:10:09 2020 -0500

    FINERACT-783
     - Update README.md with instructions for kubernetes
     - Setup fineractmysql configuration file
     - Setup fineract-server configuration file
    closes https://issues.apache.org/jira/browse/FINERACT-783
---
 README.md                                 |  29 ++++++++
 kubernetes/fineract-server-deployment.yml |  76 ++++++++++++++++++++
 kubernetes/fineractmysql-deployment.yml   | 113 ++++++++++++++++++++++++++++++
 kubernetes/secrets.yml                    |  26 +++++++
 4 files changed, 244 insertions(+)

diff --git a/README.md b/README.md
index 42c577b..e415d06 100644
--- a/README.md
+++ b/README.md
@@ -107,6 +107,35 @@ _(Note that in previous versions, the `mysqlserver` environment variable used at
 and the `mysqlserver` environment variable is now no longer supported.)_
 
 
+Instructions to run using minikube and kubectl
+===================================================
+
+You can also run Fineract using containers on a kubernetes cluster.
+
+As Prerequisites, you must have `minikube` and `kubectl` installed on your machine; see
+[Minikube & Kubectl install](https://kubernetes.io/docs/tasks/tools/install-minikube/).
+
+Now to run a new Fineract instance on minikube you can simply:
+
+1. `git clone https://github.com/apache/fineract.git ; cd fineract`
+1. `minikube start --mount-string="./fineract-db/docker:/fineract-db" --mount`
+1. `kubectl apply -f kubernetes/secrets.yml`
+1. `kubectl apply -f kubernetes/fineractmysql-deployment.yml`
+1. `kubectl apply -f kubernetes/fineract-server-deployment.yml`
+1. `minikube service fineract-server --url`
+1. Fineract will run at the provided url
+
+NB : Change protocol from `http` to `https`
+=======================================
+
+To check the status of your containers on your local kubernetes cluster, run:
+    `minikube dashboard`
+
+Having difficulties setting up minikube locally, you can try out the deployment
+using katacoda(https://www.katacoda.com/courses/kubernetes/launch-single-node-cluster)
+From there start the scenario and follow the instructions as indicated above.
+
+
 Checkstyle
 ============
 
diff --git a/kubernetes/fineract-server-deployment.yml b/kubernetes/fineract-server-deployment.yml
new file mode 100644
index 0000000..7e23e33
--- /dev/null
+++ b/kubernetes/fineract-server-deployment.yml
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: fineract-server
+  name: fineract-server
+spec:
+  ports:
+  - protocol: TCP
+    port: 8443
+    targetPort: 8443
+  selector:
+    app: fineract-server
+    tier: backend
+  type: LoadBalancer
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: fineract-server
+  labels:
+    app: fineract-server
+spec:
+  selector:
+    matchLabels:
+      app: fineract-server
+      tier: backend
+  strategy:
+    type: Recreate
+  template:
+    metadata:
+      labels:
+        app: fineract-server
+        tier: backend
+    spec:
+      containers:
+      - name: fineract-server
+        image: apache/fineract:latest
+        env:
+        - name: JAVA_OPTS
+          value: -Dfineract_tenants_url=jdbc:mysql:thin://fineractmysql:3306/fineract_tenants -Dfineract_tenants_driver=org.drizzle.jdbc.DrizzleDriver -Dfineract_tenants_uid=root -Dfineract_tenants_pwd=skdcnwauicn2ucnaecasdsajdnizucawencascdca -Djava.awt.headless=true -XX:+UseG1GC -Dfile.encoding=UTF-8
+        - name: FINERACT_DEFAULT_TENANTDB_HOSTNAME
+          value: fineractmysql
+        - name: FINERACT_DEFAULT_TENANTDB_PORT
+          value: '3306'
+        - name: FINERACT_DEFAULT_TENANTDB_UID
+          valueFrom:
+            secretKeyRef:
+              name: fineract-tenants-db-secret
+              key: username
+        - name: FINERACT_DEFAULT_TENANTDB_PWD
+          valueFrom:
+            secretKeyRef:
+              name: fineract-tenants-db-secret
+              key: password
+        ports:
+        - containerPort: 8443
+          name: fineract-server
diff --git a/kubernetes/fineractmysql-deployment.yml b/kubernetes/fineractmysql-deployment.yml
new file mode 100644
index 0000000..02176da
--- /dev/null
+++ b/kubernetes/fineractmysql-deployment.yml
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: fineractmysql-pv-volume
+  labels:
+    type: local
+spec:
+  storageClassName: manual
+  capacity:
+    storage: 10Gi
+  accessModes:
+    - ReadWriteMany
+  hostPath:
+    path: "/mnt/data"
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: fineractmysql-pv-claim
+spec:
+  storageClassName: manual
+  accessModes:
+    - ReadWriteMany
+  resources:
+    requests:
+      storage: 5Gi
+---
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: fineract-server
+  name: fineractmysql
+spec:
+  ports:
+    - protocol: TCP
+      port: 3306
+      targetPort: 3306
+  selector:
+    app: fineract-server
+    tier: fineractmysql
+  clusterIP: None
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  labels:
+    app: fineract-server
+  name: fineractmysql
+spec:
+  selector:
+    matchLabels:
+      app: fineract-server
+      tier: fineractmysql
+  strategy:
+    type: Recreate
+  template:
+    metadata:
+      labels:
+        app: fineract-server
+        tier: fineractmysql
+    spec:
+      containers:
+        - image: mysql:5.7
+          name: mysql
+          env:
+            - name: MYSQL_ROOT_PASSWORD
+              valueFrom:
+                secretKeyRef:
+                  name: fineract-tenants-db-secret
+                  key: password
+          livenessProbe:
+            exec:
+              command:
+                - mysqladmin
+                - ping
+                - -h
+                - localhost
+            failureThreshold: 10
+            timeoutSeconds: 10
+          ports:
+            - containerPort: 3306
+              name: fineractmysql
+          volumeMounts:
+            - name: fineractmysql-persistent-storage
+              mountPath: /var/lib/mysql/
+            - name: fineractmysql-host-path
+              mountPath: /docker-entrypoint-initdb.d/
+      volumes:
+        - name: fineractmysql-persistent-storage
+          persistentVolumeClaim:
+            claimName: fineractmysql-pv-claim
+        - name: fineractmysql-host-path
+          hostPath:
+            path: /fineract-db
diff --git a/kubernetes/secrets.yml b/kubernetes/secrets.yml
new file mode 100644
index 0000000..70eedce
--- /dev/null
+++ b/kubernetes/secrets.yml
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+apiVersion: v1
+kind: Secret
+metadata:
+  name: fineract-tenants-db-secret
+type: Opaque
+stringData:
+  username: root
+  password: skdcnwauicn2ucnaecasdsajdnizucawencascdca
\ No newline at end of file


[fineract] 02/02: Setup configMap and startup and shutdown scripts

Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit a9c214046346b100a548b3e828734262e9a79c7a
Author: xurror <ka...@outlook.com>
AuthorDate: Fri Apr 10 14:55:08 2020 +0100

    Setup configMap and startup and shutdown scripts
---
 README.md                                          | 29 +++++++++------
 kubernetes/fineract-server-deployment.yml          |  3 ++
 .../{secrets.yml => fineractmysql-configmap.yml}   | 19 ++++++----
 kubernetes/fineractmysql-deployment.yml            | 15 +++++---
 kubernetes/{secrets.yml => kubectl-shutdown.sh}    | 15 ++++----
 kubernetes/kubectl-startup.sh                      | 42 ++++++++++++++++++++++
 kubernetes/secrets.yml                             |  1 +
 7 files changed, 95 insertions(+), 29 deletions(-)

diff --git a/README.md b/README.md
index e415d06..9326e5a 100644
--- a/README.md
+++ b/README.md
@@ -107,33 +107,40 @@ _(Note that in previous versions, the `mysqlserver` environment variable used at
 and the `mysqlserver` environment variable is now no longer supported.)_
 
 
-Instructions to run using minikube and kubectl
-===================================================
+Instructions to run on kubernetes
+=================================
 
 You can also run Fineract using containers on a kubernetes cluster.
+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. Make sure to replace `apache-fineract-cn` with `apache-fineract`
+
+Now from your cloud shell, run the following commands:
+
+1. `git clone https://github.com/apache/fineract.git ; cd fineract/kubernetes`
+1. `sh kubectl-startup.sh`
 
+To shutdown and reset your cluster, run:
+    `sh kubectl-shutdown.sh`
+
+Alternatively, you can run fineract on a local kubernetes cluster(minikube).
 As Prerequisites, you must have `minikube` and `kubectl` installed on your machine; see
 [Minikube & Kubectl install](https://kubernetes.io/docs/tasks/tools/install-minikube/).
 
 Now to run a new Fineract instance on minikube you can simply:
 
-1. `git clone https://github.com/apache/fineract.git ; cd fineract`
-1. `minikube start --mount-string="./fineract-db/docker:/fineract-db" --mount`
-1. `kubectl apply -f kubernetes/secrets.yml`
-1. `kubectl apply -f kubernetes/fineractmysql-deployment.yml`
-1. `kubectl apply -f kubernetes/fineract-server-deployment.yml`
+1. `git clone https://github.com/apache/fineract.git ; cd fineract/kubernetes`
+1. `minikube start`
+1. `sh kubectl-startup.sh`
 1. `minikube service fineract-server --url`
 1. Fineract will run at the provided url
 
 NB : Change protocol from `http` to `https`
-=======================================
 
 To check the status of your containers on your local kubernetes cluster, run:
     `minikube dashboard`
 
-Having difficulties setting up minikube locally, you can try out the deployment
-using katacoda(https://www.katacoda.com/courses/kubernetes/launch-single-node-cluster)
-From there start the scenario and follow the instructions as indicated above.
+To shutdown and reset your cluster, run:
+    `sh kubectl-shutdown.sh`
 
 
 Checkstyle
diff --git a/kubernetes/fineract-server-deployment.yml b/kubernetes/fineract-server-deployment.yml
index 7e23e33..f7b0355 100644
--- a/kubernetes/fineract-server-deployment.yml
+++ b/kubernetes/fineract-server-deployment.yml
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+
 apiVersion: v1
 kind: Service
 metadata:
@@ -31,7 +32,9 @@ spec:
     app: fineract-server
     tier: backend
   type: LoadBalancer
+
 ---
+
 apiVersion: apps/v1
 kind: Deployment
 metadata:
diff --git a/kubernetes/secrets.yml b/kubernetes/fineractmysql-configmap.yml
similarity index 72%
copy from kubernetes/secrets.yml
copy to kubernetes/fineractmysql-configmap.yml
index 70eedce..2f55518 100644
--- a/kubernetes/secrets.yml
+++ b/kubernetes/fineractmysql-configmap.yml
@@ -16,11 +16,18 @@
 # under the License.
 #
 
+
 apiVersion: v1
-kind: Secret
+kind: ConfigMap
 metadata:
-  name: fineract-tenants-db-secret
-type: Opaque
-stringData:
-  username: root
-  password: skdcnwauicn2ucnaecasdsajdnizucawencascdca
\ No newline at end of file
+  name: fineractmysql-initdb
+  labels:
+    app: fineract-server
+data:
+  init.sql: |
+    # create databases
+    CREATE DATABASE IF NOT EXISTS `fineract_tenants`;
+    CREATE DATABASE IF NOT EXISTS `fineract_default`;
+
+    # create root user and grant rights
+    GRANT ALL ON *.* TO 'root'@'%';
\ No newline at end of file
diff --git a/kubernetes/fineractmysql-deployment.yml b/kubernetes/fineractmysql-deployment.yml
index 02176da..75f3fd8 100644
--- a/kubernetes/fineractmysql-deployment.yml
+++ b/kubernetes/fineractmysql-deployment.yml
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+
 apiVersion: v1
 kind: PersistentVolume
 metadata:
@@ -30,7 +31,9 @@ spec:
     - ReadWriteMany
   hostPath:
     path: "/mnt/data"
+
 ---
+
 apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
@@ -42,7 +45,9 @@ spec:
   resources:
     requests:
       storage: 5Gi
+
 ---
+
 apiVersion: v1
 kind: Service
 metadata:
@@ -58,7 +63,9 @@ spec:
     app: fineract-server
     tier: fineractmysql
   clusterIP: None
+
 ---
+
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -102,12 +109,12 @@ spec:
           volumeMounts:
             - name: fineractmysql-persistent-storage
               mountPath: /var/lib/mysql/
-            - name: fineractmysql-host-path
+            - name: fineractmysql-initdb
               mountPath: /docker-entrypoint-initdb.d/
       volumes:
         - name: fineractmysql-persistent-storage
           persistentVolumeClaim:
             claimName: fineractmysql-pv-claim
-        - name: fineractmysql-host-path
-          hostPath:
-            path: /fineract-db
+        - name: fineractmysql-initdb
+          configMap:
+            name: fineractmysql-initdb
diff --git a/kubernetes/secrets.yml b/kubernetes/kubectl-shutdown.sh
similarity index 80%
copy from kubernetes/secrets.yml
copy to kubernetes/kubectl-shutdown.sh
index 70eedce..17c8493 100644
--- a/kubernetes/secrets.yml
+++ b/kubernetes/kubectl-shutdown.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements. See the NOTICE file
 # distributed with this work for additional information
@@ -16,11 +18,8 @@
 # under the License.
 #
 
-apiVersion: v1
-kind: Secret
-metadata:
-  name: fineract-tenants-db-secret
-type: Opaque
-stringData:
-  username: root
-  password: skdcnwauicn2ucnaecasdsajdnizucawencascdca
\ No newline at end of file
+
+kubectl delete -f secrets.yml
+kubectl delete -f fineractmysql-configmap.yml
+kubectl delete -f fineractmysql-deployment.yml
+kubectl delete -f fineract-server-deployment.yml
\ No newline at end of file
diff --git a/kubernetes/kubectl-startup.sh b/kubernetes/kubectl-startup.sh
new file mode 100644
index 0000000..27fef6d
--- /dev/null
+++ b/kubernetes/kubectl-startup.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+echo "Setting Up Fineract service configuration..."
+kubectl apply -f  secrets.yml
+kubectl apply -f fineractmysql-configmap.yml
+
+echo ""
+echo "Starting fineractmysql..."
+kubectl apply -f fineractmysql-deployment.yml
+
+fineractmysql_pod=""
+while [[ ${#fineractmysql_pod} -eq 0 ]]; do
+    fineractmysql_pod=$(kubectl get pods -l tier=fineractmysql --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
+done
+#sleep 5
+fineractmysql_status=$(kubectl get pods ${fineractmysql_pod} --no-headers -o custom-columns=":status.phase")
+while [[ ${fineractmysql_status} -ne 'Running' ]]; do
+    sleep 1
+    fineractmysql_status=$(kubectl get pods ${fineractmysql_pod} --no-headers -o custom-columns=":status.phase")
+done
+
+echo ""
+echo "Starting fineract server..."
+kubectl apply -f fineract-server-deployment.yml
diff --git a/kubernetes/secrets.yml b/kubernetes/secrets.yml
index 70eedce..b3e6669 100644
--- a/kubernetes/secrets.yml
+++ b/kubernetes/secrets.yml
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+
 apiVersion: v1
 kind: Secret
 metadata: