Skip to content

Commit 8fa6386

Browse files
Lucian-Constantinescuidirze
authored andcommitted
feat: Integrate log4shell & jmx metrics exporter
1 parent cf568af commit 8fa6386

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

docker/config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
########################################
2+
###### ######
3+
###### Prometheus standard config ######
4+
###### ######
5+
########################################
6+
7+
rules:
8+
- pattern: ".*"

docker/metastore.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ if [ -z "${HADOOP_VERSION}" ]; then echo "HADOOP_VERSION env variable must be de
2626
#if [ -z "${S3_ENDPOINT}" ]; then echo "S3_ENDPOINT env variable must be defined!"; exit 1; fi
2727
#if [ -z "${S3_ACCESS_KEY}" ]; then echo "S3_ACCESS_KEY env variable must be defined!"; exit 1; fi
2828
#if [ -z "${S3_SECRET_KEY}" ]; then echo "S3_SECRET_KEY env variable must be defined!"; exit 1; fi
29+
#if [ -z "${S3_WAREHOUSE_DIRECTORY}" ]; then echo "S3_WAREHOUSE_DIRECTORY env variable must be defined!"; exit 1; fi
30+
#if [ -z "${S3_PROXY_HOST}" ]; then echo "S3_PROXY_HOST env variable must be defined!"; exit 1; fi
31+
#if [ -z "${S3_PROXY_PORT}" ]; then echo "S3_PROXY_PORT env variable must be defined!"; exit 1; fi
2932

3033
if [ -z "${JAVA_HOME}" ]; then export JAVA_HOME=/usr/local/openjdk-8; fi
3134
if [ -z "${BASEDIR}" ]; then export BASEDIR=/opt; fi
@@ -154,6 +157,31 @@ cat >>${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/conf/metastore-s
154157
EOF
155158
fi
156159

160+
if [ ! -z "${S3_WAREHOUSE_DIRECTORY}" ]
161+
then
162+
cat >>${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/conf/metastore-site.xml <<-EOF
163+
<property>
164+
<name>metastore.warehouse.dir</name>
165+
<value>s3a://${S3_WAREHOUSE_DIRECTORY}/hive-warehouse/</value>
166+
</property>
167+
EOF
168+
fi
169+
170+
if [ ! -z "${S3_PROXY_HOST}" ]
171+
then
172+
cat >>${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/conf/metastore-site.xml <<-EOF
173+
<property>
174+
<name>fs.s3a.proxy.host</name>
175+
<value>${S3_PROXY_HOST}</value>
176+
</property>
177+
<property>
178+
<name>fs.s3a.proxy.port</name>
179+
<value>${S3_PROXY_PORT}</value>
180+
</property>
181+
EOF
182+
fi
183+
184+
157185
if [ ! -z "${ASSUME_ROLE_ARN}" ]
158186
then
159187
cat >>${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/conf/metastore-site.xml <<-EOF
@@ -198,7 +226,7 @@ if [ "$MODE" = "init" ]; then
198226
echo "Initialize schema if DBS table does not exist"
199227
if [ "$DB_DRIVER_NAME" = "mysql" ]; then
200228
mysql --host=${DB_HOST} --port=${DB_PORT} -u ${HIVEMS_USER} -p${HIVEMS_PASSWORD} -D ${HIVEMS_DB} -e 'SELECT "DB_ID" FROM "DBS"' >/dev/null 2>&1;
201-
if [ $? -ne 0 ]; then echo "Will initialize the DB"; ${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/bin/schematool -initSchema -dbType ${DB_DRIVER_NAME}; fi
229+
if [ $? -ne 0 ]; then echo "Will initialize the DB"; ${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/bin/schematool -initSchema -dbType ${DB_DRIVER_NAME} -userName ${HIVEMS_USER} -passWord ${HIVEMS_PASSWORD} -url "jdbc:mysql://${DB_HOST}:${DB_PORT}/${HIVEMS_DB}?createDatabaseIfNotExist=true&connectTimeout=1000"; fi
202230
else
203231
psql --host=${DB_HOST} --port=${DB_PORT} -U ${HIVEMS_USER} -d ${HIVEMS_DB} -c 'SELECT "DB_ID" FROM "DBS"' >/dev/null 2>&1;
204232
if [ $? -ne 0 ]; then echo "Will initialize the DB"; ${BASEDIR}/apache-hive-metastore-${METASTORE_VERSION}-bin/bin/schematool -initSchema -dbType ${DB_DRIVER_NAME}; fi
@@ -211,7 +239,7 @@ fi
211239

212240
echo "Will wait for database schema to be ready...."
213241
if [ "$DB_DRIVER_NAME" = "mysql" ]; then
214-
while ! mysql --host=${DB_HOST} --port=${DB_PORT} -u ${HIVEMS_USER} -p${HIVEMS_PASSWORD} -D ${HIVEMS_DB} -e 'SELECT "SCHEMA_VERSION" FROM "VERSION"' >/dev/null 2>&1; do echo "Waiting for ${HIVEMS_DB} schema to be ready..."; sleep 2; done;
242+
while ! mysql --host=${DB_HOST} --port=${DB_PORT} -u ${HIVEMS_USER} -p${HIVEMS_PASSWORD} -D ${HIVEMS_DB} -e "SELECT "SCHEMA_VERSION" FROM "VERSION"" >/dev/null 2>&1; do echo "Waiting for ${HIVEMS_DB} schema to be ready..."; sleep 2; done;
215243
else
216244
while ! psql --host=${DB_HOST} --port=${DB_PORT} -U ${HIVEMS_USER} -d ${HIVEMS_DB} -c 'SELECT "SCHEMA_VERSION" FROM "VERSION"' >/dev/null 2>&1; do echo "Waiting for ${HIVEMS_DB} schema to be ready..."; sleep 2; done;
217245
fi

helm/hive-metastore/templates/deployment.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ spec:
5656
- name: S3_ENDPOINT
5757
value: "{{ .Values.s3.url }}"
5858
{{- end }}
59+
{{- if .Values.s3.warehouseDirectory }}
60+
- name: S3_WAREHOUSE_DIRECTORY
61+
value: "{{ .Values.s3.warehouseDirectory }}"
62+
{{- end }}
5963
{{- if .Values.s3.accessKey.secretName }}
6064
- name: S3_ACCESS_KEY
6165
valueFrom:
@@ -70,6 +74,12 @@ spec:
7074
name: {{ .Values.s3.secretKey.secretName }}
7175
key: {{ .Values.s3.secretKey.propertyName }}
7276
{{- end }}
77+
{{ if .Values.s3.proxy }}
78+
- name: S3_PROXY_HOST
79+
value: "{{ .Values.s3.proxy.host }}"
80+
- name: S3_PROXY_PORT
81+
value: "{{ .Values.s3.proxy.port }}"
82+
{{- end }}
7383
{{ if .Values.aws.s3AssumeRoleArn }}
7484
- name: ASSUME_ROLE_ARN
7585
value: {{ .Values.aws.s3AssumeRoleArn }}
@@ -80,7 +90,7 @@ spec:
8090
- name: DB_DRIVER_REF
8191
value: {{ .Values.db.driverRef }}
8292
- name: DB_DRIVER_NAME
83-
value: {{ .Values.db.driverName }}
93+
value: {{ .Values.db.driverName }}
8494
- name: DB_HOST
8595
value: {{ .Values.db.host }}
8696
- name: DB_PORT

helm/hive-metastore/templates/job.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ spec:
3030
- name: metastore
3131
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
3232
imagePullPolicy: {{ .Values.image.pullPolicy }}
33-
command:
34-
- /metastore.sh
35-
args:
36-
- init
3733
{{- with .Values.containerSecurityContext }}
3834
securityContext:
3935
{{- toYaml . | nindent 12 }}
@@ -61,6 +57,14 @@ spec:
6157
secretKeyRef:
6258
name: {{ .Values.db.user.password.secretName }}
6359
key: {{ .Values.db.user.password.propertyName }}
60+
command: ["/bin/sh","-c"]
61+
args:
62+
- |
63+
TABLE_EXISTS=$(mysql -h $DB_HOST -u$HIVEMS_USER -p$HIVEMS_PASSWORD -D $HIVEMS_DB -sN -e "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${HIVEMS_DB}' AND table_name = 'METASTORE_DB_PROPERTIES';")
64+
echo "TABLE_EXISTS: $TABLE_EXISTS"
65+
if [ "$TABLE_EXISTS" != "" ] && [ "$TABLE_EXISTS" -eq 0 ]; then
66+
/metastore.sh init
67+
fi
6468
restartPolicy: Never
6569
{{- with .Values.podSecurityContext }}
6670
securityContext:

helm/hive-metastore/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ db:
2424
s3:
2525
# -- S3 endpoint
2626
url:
27+
# -- S3 warehouse directory/bucket name
28+
warehouseDirectory:
2729
accessKey:
2830
# -- S3 access key existing kubernetes secret name
2931
secretName:
@@ -34,6 +36,10 @@ s3:
3436
secretName:
3537
# -- S3 secret key kubernetes secret key containing the secretName
3638
propertyName:
39+
# -- Proxy configuration (if needed)
40+
proxy:
41+
host:
42+
port:
3743
requestTimeout: 0
3844

3945
aws:

0 commit comments

Comments
 (0)