Skip to content
Permalink
Browse files
implement kubernetes scripts for active mq, cassandra, eureka, postgr…
…es and portfolio
  • Loading branch information
Anh3h committed Nov 27, 2019
1 parent 039ce55 commit 4989b5fad9232325b4390a36af3dbdb1fa4f2019
Showing 8 changed files with 480 additions and 0 deletions.
@@ -0,0 +1,61 @@
apiVersion: v1
kind: Service
metadata:
name: activemq-cluster
namespace: default
spec:
selector:
app: activemq
ports:
- name: external-port
port: 8161
targetPort: 8161
- name: internal-port
port: 61616
protocol: TCP
targetPort: 61616
type: LoadBalancer

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: activemq-cluster
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: activemq
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: activemq
spec:
containers:
- image: docker.io/rmohr/activemq:5.14.5
imagePullPolicy: IfNotPresent
name: activemq
ports:
- containerPort: 61616
- containerPort: 8161
env:
- name: ACTIVEMQ_CONFIG_MINMEMORY
value: "512"
- name: ACTIVEMQ_CONFIG_MAXMEMORY
value: "1024"
livenessProbe:
httpGet:
path: /
port: 8161
initialDelaySeconds: 45
timeoutSeconds: 10
periodSeconds: 60
failureThreshold: 3

@@ -0,0 +1,90 @@
# apiVersion: v1
# kind: PersistentVolume
# metadata:
# name: cassandra-pv
# spec:
# accessModes:
# - ReadWriteOnce
# capacity:
# storage: 10Gi
# persistentVolumeReclaimPolicy: Retain
# storageClassName: standard
# gcePersistentDisk:
# fsType: ext4
# pdName: apache-fineract-pd

# ---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cassandra-pvc
namespace: default
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
# volumeName: cassandra-pv

---

apiVersion: v1
kind: Service
metadata:
name: cassandra-cluster
namespace: default
spec:
selector:
app: cassandra
ports:
- port: 9042
targetPort: 9042
type: LoadBalancer

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cassandra-cluster
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: cassandra
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: cassandra
spec:
containers:
- image: docker.io/cassandra:3.11
imagePullPolicy: IfNotPresent
name: cassandra
ports:
- containerPort: 9042
name: cql
livenessProbe:
exec:
command:
- cqlsh
- --help
initialDelaySeconds: 10
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
volumeMounts:
- mountPath: /var/lib/cassandra
name: cassandra-storage
volumes:
- name: cassandra-storage
persistentVolumeClaim:
claimName: cassandra-pvc
@@ -0,0 +1,33 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: fineract-service-config
data:
bonecp.acquireIncrement: "1"
bonecp.maxConnectionsPerPartition: "4"
bonecp.minConnectionsPerPartition: "1"
bonecp.partitionCount: "1"
cassandra.cl.delete: ONE
cassandra.cl.read: ONE
cassandra.cl.write: ONE
cassandra.cluster.pwd: password
cassandra.cluster.user: cassandra
cassandra.clusterName: datacenter1
cassandra.keyspace: seshat
eureka.client.fetchRegistry: "true"
eureka.client.initialInstanceInfoReplicationIntervalSeconds: "25"
eureka.client.instanceInfoReplicationIntervalSeconds: "20"
eureka.instance.leaseRenewalIntervalInSeconds: "20"
eureka.registration.enabled: "true"
feign.hystrix.enabled: "false"
postgresql.database: seshat
ribbon.eureka.enabled: "true"
server.max-http-header-size: "16384"
spring.cloud.config.enabled: "false"
spring.cloud.discovery.enabled: "true"
system.initialclientid: service-runner
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}
@@ -0,0 +1,50 @@
apiVersion: v1
kind: Service
metadata:
name: eureka-cluster
namespace: default
spec:
selector:
app: eureka
ports:
- port: 8761
targetPort: 8761
type: LoadBalancer

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: eureka-cluster
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: eureka
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: eureka
spec:
containers:
- image: docker.io/anh3h/eureka-server:latest
imagePullPolicy: IfNotPresent
name: eureka-server
ports:
- containerPort: 8761
name: http
livenessProbe:
httpGet:
path: /
port: 8761
initialDelaySeconds: 45
timeoutSeconds: 10
periodSeconds: 60
failureThreshold: 3
@@ -0,0 +1,16 @@
# cd kubernetes-scripts/
# kubectl delete -f office.yml
# kubectl delete -f customer.yml
# kubectl delete -f portfolio.yml
# kubectl delete -f rhythm.yml
# kubectl delete -f identity.yml
kubectl delete -f provisioner.yml
kubectl delete configmaps external-tools-config
kubectl delete configmaps fineract-service-config
kubectl delete configmaps secret-config
kubectl delete configmaps provisioner-datasource-config
kubectl delete -f postgres.yml
kubectl delete -f cassandra.yml
kubectl delete -f eureka.yml
kubectl delete -f activemq.yml
kubectl delete -f ledger.yml
@@ -0,0 +1,52 @@
#!/bin/sh

# cd kubernetes-scripts
echo "Starting ActiveMQ, Eureka, PostgreSQL and Cassandra ..."
kubectl apply -f activemq.yml
kubectl apply -f eureka.yml
kubectl apply -f postgres.yml
kubectl apply -f cassandra.yml

cassandra_ip=""
postgres_ip=""
eureka_ip=""
activemq_ip=""

echo ""
echo "Sharing Cassandra, PostgreSQL, Eureka and ActiveMQ IP addresses..."
while [[ ${#cassandra_ip} -eq 0 || ${#postgres_ip} -eq 0 || ${#eureka_ip} -eq 0 || ${#activemq_ip} -eq 0 ]] ; do
cassandra_ip=$(kubectl describe service cassandra-cluster | grep 'LoadBalancer Ingress' \
| grep -Eo '[0-9.]*')
postgres_ip=$(kubectl describe service postgresdb-cluster | grep 'LoadBalancer Ingress'\
| grep -Eo '[0-9.]*')
eureka_ip=$(kubectl describe service eureka-cluster | grep 'LoadBalancer Ingress'\
| grep -Eo '[0-9.]*')
activemq_ip=$(kubectl describe service activemq-cluster | grep 'LoadBalancer Ingress'\
| grep -Eo '[0-9.]*')
done

kubectl create configmap external-tools-config \
--from-literal=ribbon.listOfServers=${eureka_ip}:9090 \
--from-literal=eureka.client.serviceUrl.defaultZone=http://${eureka_ip}:8761/eureka \
--from-literal=postgresql.host=${postgres_ip} \
--from-literal=activemq.brokerUrl=tcp://${activemq_ip}:61616 \
--from-literal=cassandra.contactPoints=${cassandra_ip}:9042

kubectl create configmap provisioner-datasource-config \
--from-literal=spring.datasource.url=jdbc:postgresql://${postgres_ip}:5432/seshat

echo ""
kubectl apply -f config.yml
config_param=$( java -cp ../external_tools/lang-0.1.0-BUILD-SNAPSHOT.jar \
org.apache.fineract.cn.lang.security.RsaKeyPairFactory UNIX | \
sed -e 's/^[ \t]*//' | awk '{print "--from-literal="$1}' )
kubectl create configmap secret-config ${config_param}

kubectl apply -f provisioner.yml
echo "Done"
# kubectl apply -f identity.yml
# kubectl apply -f rhythm.yml
# kubectl apply -f office.yml
# kubectl apply -f customer.yml
# kubectl apply -f portfolio.yml
# kubectl apply -f ledger.yml

0 comments on commit 4989b5f

Please sign in to comment.