RD: Added sidecar MongoDB. Added related configuration in values.yaml

Change-Id: I9f1c1ecf560c5f3f153dcf9efea53f6e875de419
This commit is contained in:
ipatini 2024-04-19 14:56:56 +03:00
parent a465f2e6ce
commit 184b45e5f2
5 changed files with 78 additions and 8 deletions

View File

@ -33,6 +33,11 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- range .Values.env }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
ports:
- name: http
containerPort: 8080
@ -47,6 +52,22 @@ spec:
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
- name: {{ .Chart.Name }}-mongodb
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "docker.io/library/mongo:7.0.2"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- range .Values.env }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
ports:
- name: mongo-port
containerPort: 27017
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}

View File

@ -80,3 +80,19 @@ nodeSelector: {}
tolerations: []
affinity: {}
env:
# ===== MongoDB configuration =====
- name: MONGO_INITDB_ROOT_USERNAME
value: 'root'
- name: MONGO_INITDB_ROOT_PASSWORD
value: 'example'
# ===== Resource Manager configuration =====
- name: SPRING_DATA_MONGODB_URI
value: 'mongodb://root:example@localhost:27017/admin'
- name: DISCOVERY_BROKER_USERNAME
value: 'aaa'
- name: DISCOVERY_BROKER_PASSWORD
value: '111'
- name: DISCOVERY_BROKERURL
value: 'tcp://nebulous-monitoring:61616?daemon=true&trace=false&useInactivityMonitor=false&connectionTimeout=0&keepAlive=true'

View File

@ -5,7 +5,6 @@ ENV BASEDIR /app
WORKDIR ${BASEDIR}
COPY src ${BASEDIR}/src
COPY pom.xml ${BASEDIR}/
COPY run.sh ${BASEDIR}/
RUN mvn -f ${BASEDIR}/pom.xml -DskipTests clean install && \
java -Djarmode=layertools -jar ${BASEDIR}/target/resource-discovery-*.jar extract
@ -22,11 +21,21 @@ RUN wget --progress=dot:giga -O /usr/local/bin/dumb-init \
chmod +x /usr/local/bin/dumb-init
# Add RD user
ARG RD_USER=rd
RUN mkdir ${RD_HOME} && \
addgroup ${RD_USER} && \
adduser --home ${RD_HOME} --no-create-home --ingroup ${RD_USER} --disabled-password ${RD_USER} && \
chown ${RD_USER}:${RD_USER} ${RD_HOME}
ARG RD_USER=root
#ARG RD_USER=rd
#RUN mkdir ${RD_HOME} && \
# addgroup ${RD_USER} && \
# adduser --home ${RD_HOME} --no-create-home --ingroup ${RD_USER} --disabled-password ${RD_USER} && \
# chown ${RD_USER}:${RD_USER} ${RD_HOME}
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
netcat=1.218-4ubuntu1 \
iputils-ping=3:20211215-1 \
telnet=0.17-44build1 \
vim=2:8.2.3995-1ubuntu2.16 \
net-tools=1.60+git20181103.0eebece-1ubuntu5 \
&& rm -rf /var/lib/apt/lists/*
# Set User and Workdir
USER ${RD_USER}
@ -37,8 +46,11 @@ COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/dependencies
COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/spring-boot-loader ${BASEDIR}
COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/snapshot-dependencies ${BASEDIR}
COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/application ${BASEDIR}
COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/run.sh ${BASEDIR}
RUN chmod +x run.sh
#COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/run.sh ${BASEDIR}
COPY --chown=${RD_USER}:${RD_USER} run.sh ${BASEDIR}
COPY --chown=${RD_USER}:${RD_USER} wait_for_mongodb.sh ${BASEDIR}
RUN chmod +x run.sh wait_for_mongodb.sh
EXPOSE 8080

View File

@ -5,6 +5,9 @@ PREVWORKDIR=`pwd`
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${BASEDIR}
# Wait for MongoDB to start
./wait_for_mongodb.sh
# Read JASYPT password (decrypts encrypted configuration settings)
#if [[ -z "$JASYPT_PASSWORD" ]]; then
# printf "Configuration Password: "

View File

@ -0,0 +1,18 @@
#!/bin/bash
# Define MongoDB connection details
MONGODB_HOST="localhost"
MONGODB_PORT="27017"
# Function to check if MongoDB is ready
wait_for_mongodb() {
echo "Waiting for MongoDB to be ready..."
until nc -z $MONGODB_HOST $MONGODB_PORT
do
sleep 1
done
echo "MongoDB is up and running!"
}
# Call the function to wait for MongoDB
wait_for_mongodb