Skip to content

Commit

Permalink
Kubernetes ConfigMaps, External Database Service & tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Araf Karsh Hamid committed Jan 21, 2025
1 parent ca2a629 commit 9d7946f
Show file tree
Hide file tree
Showing 18 changed files with 379 additions and 24 deletions.
2 changes: 1 addition & 1 deletion compile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# -------------------------------------------------------------------------------------------
# @author: Araf Karsh Hamid
# -------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions config/application.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# =======================================================================
# MS-Vanilla Service Properties
# =======================================================================
build.number=211
build.date=Tue Jan 21 10:05:58 IST 2025
build.number=212
build.date=Tue Jan 21 18:03:47 IST 2025
# ------------------------------------------------------------------------
# Spring Profile
# ------------------------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions getServiceName
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ containerName=4
param=$1
if [ -z "$param" ]
then
fgrep service.name= $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
grep '^service.name=' $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
exit
fi
if [ $param == $orgName ]
then
fgrep service.org= $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
grep '^service.org=' $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
exit
elif [ $param == $serviceName ]
then
fgrep service.name= $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
grep '^service.name=' $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
exit
elif [ $param == $apiName ]
then
fgrep service.api.name= $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
grep '^service.api.name=' $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
exit
elif [ $param == $containerName ]
then
fgrep service.container= $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
grep '^service.container=' $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
exit
fi
fgrep service.api.name= $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
grep '^service.api.name=' $SRC_BASE/src/main/resources/app.props.tmpl | cut -d "=" -f 2
exit
4 changes: 2 additions & 2 deletions src/docker/Input/application.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# =======================================================================
# MS-Vanilla Service Properties
# =======================================================================
build.number=211
build.date=Tue Jan 21 10:05:58 IST 2025
build.number=212
build.date=Tue Jan 21 18:03:47 IST 2025
# ------------------------------------------------------------------------
# Spring Profile
# ------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/kubernetes/Package/default/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build.number=211
build.date=Tue Jan 21 10:05:58 IST 2025
build.number=212
build.date=Tue Jan 21 18:03:47 IST 2025
spring.profiles.default=dev
service.org=arafkarsh
service.name=MS-Vanilla
Expand Down
6 changes: 6 additions & 0 deletions src/kubernetes/Yamls/vanilla-configmap-active.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: vanilla-configmap-active
data:
spring.profiles.active: prod
2 changes: 1 addition & 1 deletion src/kubernetes/Yamls/vanilla-configmap-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data:
service.license=Apache 2 License
service.license.url=https://github.com/arafkarsh/ms-springboot-334-vanilla?tab=Apache-2.0-1-ov-file
server.port=9334
server.version=0.3.4
server.version=3.4.0
server.restart=false
server.leak.test=3
server.resources.url=${service.url}${service.api.path}
Expand Down
7 changes: 7 additions & 0 deletions src/kubernetes/Yamls/vanilla-database-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: database-service
spec:
type: ExternalName
externalName: 192.168.5.1
22 changes: 18 additions & 4 deletions src/kubernetes/Yamls/vanilla-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@ spec:
# Only for testing purpose - use Always
imagePullPolicy: Always
args:
- "-APP_PROFILE=prod"
- "-SPRING_PROFILES_ACTIVE=prod"
- "-SPRING_DATASOURCE_URL=jdbc:postgresql://192.168.5.1:5433/ms_vanilla_334"
- "-APP_PROFILE=$(SPRING_PROFILES_ACTIVE)""
- "-SPRING_DATASOURCE_URL=jdbc:postgresql://database-service:5433/ms_vanilla_334"
ports:
- containerPort: 9334
hostPort: 9334
volumeMounts:
- name: config-volume
mountPath: /config
readOnly: true
env:
- name: JASYPT_ENCRYPTOR_PASSWORD
valueFrom:
secretKeyRef:
name: vanilla-secret
key: JASYPT_ENCRYPTOR
- name: SPRING_CONFIG_LOCATION
value: "file:/config/application.properties"
- name: SPRING_PROFILES_ACTIVE
valueFrom:
configMapKeyRef:
name: vanilla-configmap-active # Shared ConfigMap for all environments
key: spring.profiles.active
livenessProbe:
httpGet:
path: /ms-vanilla/api/v1/service/live
Expand All @@ -47,4 +57,8 @@ spec:
memory: 1536Mi
requests:
cpu: 1000m
memory: 1536Mi
memory: 1536Mi
volumes:
- name: config-volume
configMap:
name: vanilla-configmap-default
12 changes: 12 additions & 0 deletions src/kubernetes/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#---------------------------------------------------------------
# Vanilla Microservice Kubernetes Utils
# Araf Karsh Hamid, (c) Copyright 2025
# License: Apache 2.0
# Version 0.01
#---------------------------------------------------------------

source utils/colimaStatus

echo "Deploy the App..."
kubectl create -f Yamls/vanilla-deploy.yaml
12 changes: 12 additions & 0 deletions src/kubernetes/describe
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#---------------------------------------------------------------
# Vanilla Microservice Kubernetes Utils
# Araf Karsh Hamid, (c) Copyright 2025
# License: Apache 2.0
# Version 0.01
#---------------------------------------------------------------

source utils/colimaStatus

echo "Describe $1 and the component $2"
kubectl describe $1 $2
12 changes: 12 additions & 0 deletions src/kubernetes/events
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#---------------------------------------------------------------
# Vanilla Microservice Kubernetes Utils
# Araf Karsh Hamid, (c) Copyright 2025
# License: Apache 2.0
# Version 0.01
#---------------------------------------------------------------

source utils/colimaStatus

echo "Check Events"
kubectl get events --sort-by='.metadata.creationTimestamp'
6 changes: 4 additions & 2 deletions src/kubernetes/logs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@

source utils/colimaStatus

echo "Check the Logs of the Pod..."
kubectl logs -f $1
podName=`kubectl get pods | awk 'NR>1 {print $1}'`

echo "Check the Logs of the Pod=$podName"
kubectl logs -f $podName
12 changes: 12 additions & 0 deletions src/kubernetes/restart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#---------------------------------------------------------------
# Vanilla Microservice Kubernetes Utils
# Araf Karsh Hamid, (c) Copyright 2025
# License: Apache 2.0
# Version 0.01
#---------------------------------------------------------------

source utils/colimaStatus

echo "Restart all the pods of Vanilla Deployment"
kubectl rollout restart deployment vanilla-deployment
14 changes: 14 additions & 0 deletions src/kubernetes/vanillaInstall
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@

source utils/colimaStatus

echo "---------------------------------------------------------------"
echo "Deploy the Vanilla Service in Kubernetes cluster"
echo "---------------------------------------------------------------"
echo "1. Deploy the Vanilla Service Config/Secrets in Kubernetes cluster"
kubectl create -f Yamls/vanilla-configmaps-active.yaml
kubectl create -f Yamls/vanilla-configmaps-default.yaml
kubectl create -f Yamls/vanilla-configmaps-dev.yaml
kubectl create -f Yamls/vanilla-configmaps-staging.yaml
kubectl create -f Yamls/vanilla-configmaps-prod.yaml
kubectl create -f Yamls/vanilla-secret.yaml
echo "---------------------------------------------------------------"
echo "2. Deploy the External Database Service"
kubectl create -f Yamls/vanilla-database-service.yaml
echo "---------------------------------------------------------------"
echo "3. Deploy the Pods/Services/Ingress in Kubernetes cluster"
kubectl create -f Yamls/vanilla-deploy.yaml
kubectl create -f Yamls/vanilla-service.yaml
kubectl create -f Yamls/vanilla-ingress.yaml
echo "---------------------------------------------------------------"
4 changes: 2 additions & 2 deletions src/main/resources/app.props.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =======================================================================
# MS-Vanilla Service Properties
# =======================================================================
build.number=211
build.date=Tue Jan 21 10:05:58 IST 2025
build.number=212
build.date=Tue Jan 21 18:03:47 IST 2025
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# =======================================================================
# MS-Vanilla Service Properties
# =======================================================================
build.number=211
build.date=Tue Jan 21 10:05:58 IST 2025
build.number=212
build.date=Tue Jan 21 18:03:47 IST 2025
# ------------------------------------------------------------------------
# Spring Profile
# ------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 9d7946f

Please sign in to comment.