Skip to content

Commit 3278468

Browse files
ldmingapecloud-bot
authored andcommitted
chore: minio support tls (#2484)
(cherry picked from commit 35ea77a)
1 parent 1089651 commit 3278468

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

addons/minio/scripts/startup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
replicas_history_file="/minio-config/MINIO_REPLICAS_HISTORY"
44
bucket_dir="/data"
55

6+
setup_tls_certs() {
7+
if [ "$TLS_ENABLED" = "true" ] && [ -f ${CERTS_PATH}/ca.pem ]; then
8+
echo "Setting up TLS CA certificate for MinIO..."
9+
mkdir -p ${CERTS_PATH}/CAs
10+
cp -L ${CERTS_PATH}/ca.pem ${CERTS_PATH}/CAs/ca.crt
11+
echo "TLS CA certificate setup completed"
12+
fi
13+
}
14+
615
init_buckets() {
716
local buckets=$1
817
IFS=',' read -ra BUCKET_ARRAY <<< "$buckets"
@@ -62,6 +71,14 @@ build_startup_cmd() {
6271
}
6372

6473
startup() {
74+
if [ "$TLS_ENABLED" = "true" ]; then
75+
export HTTP_PROTOCOL="https"
76+
else
77+
export HTTP_PROTOCOL="http"
78+
fi
79+
80+
setup_tls_certs
81+
6582
cmd=$(build_startup_cmd)
6683
status=$?
6784
if [ $status -ne 0 ]; then

addons/minio/templates/cmpd.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,18 @@ spec:
9595
value: {{ .Values.minioAPIPort | quote }}
9696
- name: MINIO_CONSOLE_PORT
9797
value: {{ .Values.minioConsolePort | quote}}
98-
- name: HTTP_PROTOCOL
99-
value: {{ .Values.tls.enabled | ternary "https" "http" | quote }}
10098
- name: SERVICE_PORT
10199
value: "9000"
100+
- name: TLS_ENABLED
101+
valueFrom:
102+
tlsVarRef:
103+
enabled: Optional
104+
tls:
105+
volumeName: tls
106+
mountPath: {{ .Values.certsPath | quote }}
107+
caFile: ca.pem
108+
certFile: public.crt
109+
keyFile: private.key
102110
roles:
103111
- name: readwrite
104112
updatePriority: 1
@@ -123,8 +131,14 @@ spec:
123131
- -c
124132
- |
125133
# Set alias and check MinIO readiness using mc command
126-
mc alias set local http://127.0.0.1:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD >/dev/null 2>&1
127-
if mc admin info local >/dev/null 2>&1; then
134+
PROTOCOL="http"
135+
MC_INSECURE=""
136+
if [ "$TLS_ENABLED" = "true" ]; then
137+
PROTOCOL="https"
138+
MC_INSECURE="--insecure"
139+
fi
140+
mc alias set local ${PROTOCOL}://127.0.0.1:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD ${MC_INSECURE} >/dev/null 2>&1
141+
if mc admin info local ${MC_INSECURE} >/dev/null 2>&1; then
128142
echo -n "readwrite"
129143
else
130144
echo -n "notready"

0 commit comments

Comments
 (0)