Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
infrastructure
提交
c07cf7ac
I
infrastructure
项目概览
openeuler
/
infrastructure
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
infrastructure
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c07cf7ac
编写于
1月 02, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
1月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
!9 使用华为云数据库提供mailman web数据存储能力
Merge pull request !9 from TommyLike/feature/support-rds
上级
07580a40
4bdb2703
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
120 deletion
+33
-120
README.md
README.md
+1
-1
mail/dockerfile/web/docker-entrypoint.sh
mail/dockerfile/web/docker-entrypoint.sh
+25
-58
mail/openeuler.org/maildatabase.yaml
mail/openeuler.org/maildatabase.yaml
+0
-42
mail/openeuler.org/storage.yaml
mail/openeuler.org/storage.yaml
+0
-16
mail/openeuler.org/webservice.yaml
mail/openeuler.org/webservice.yaml
+7
-3
未找到文件。
README.md
浏览文件 @
c07cf7ac
# infrastructure
# infrastructure
2222
### Brief Introduction
### Brief Introduction
...
...
mail/dockerfile/web/docker-entrypoint.sh
浏览文件 @
c07cf7ac
...
@@ -3,85 +3,52 @@ set -e
...
@@ -3,85 +3,52 @@ set -e
function
wait_for_postgres
()
{
function
wait_for_postgres
()
{
# Check if the postgres database is up and accepting connections before
# Check if the
default
postgres database is up and accepting connections before
# moving forward.
# moving forward.
# TODO: Use python's psycopg2 module to do this in python instead of
# TODO: Use python's psycopg2 module to do this in python instead of
# installing postgres-client in the image.
# installing postgres-client in the image.
until
psql
$D
ATABASE
_URL
-c
'\l'
;
do
until
psql
$D
EFAULT
_URL
-c
'\l'
;
do
>
&2
echo
"Postgres is unavailable - sleeping"
>
&2
echo
"Postgres is unavailable - sleeping"
sleep
1
sleep
1
done
done
>
&2
echo
"Postgres is up - continuing"
>
&2
echo
"Postgres is up - continuing"
}
}
function
wait_for_mysql
()
{
function
create_default_database
()
{
# Check if MySQL is up and accepting connections.
if
[[
"
$(
psql
$DEFAULT_URL
-tAc
"SELECT 1 FROM pg_database WHERE datname='
$DB_NAME
'"
)
"
=
'1'
]]
;
then
HOSTNAME
=
$(
python3
<<
EOF
echo
"Database already exists, skipping creating"
try:
else
from urllib.parse import urlparse
echo
"creating new database for mailman web"
except ImportError:
psql
$DEFAULT_URL
-c
"CREATE DATABASE
$DB_NAME
;"
from urlparse import urlparse
fi
o = urlparse('
$DATABASE_URL
')
print(o.hostname)
EOF
)
until
mysqladmin ping
--host
"
$HOSTNAME
"
--silent
;
do
>
&2
echo
"MySQL is unavailable - sleeping"
sleep
1
done
>
&2
echo
"MySQL is up - continuing"
}
}
function
check_or_create
()
{
# Check if the path exists, if not, create the directory.
if
[[
!
-e
dir
]]
;
then
echo
"
$1
does not exist, creating ..."
mkdir
"
$1
"
fi
}
# function postgres_ready(){
# python << END
# import sys
# import psycopg2
# try:
# conn = psycopg2.connect(dbname="$POSTGRES_DB", user="$POSTGRES_USER", password="$POSTGRES_PASSWORD", host="postgres")
# except psycopg2.OperationalError:
# sys.exit(-1)
# sys.exit(0)
# END
# }
# Check if $SECRET_KEY is defined, if not, bail out.
if
[[
!
-v
SECRET_KEY
]]
;
then
if
[[
!
-v
SECRET_KEY
]]
;
then
echo
"SECRET_KEY is not defined. Aborting."
echo
"SECRET_KEY is not defined. Aborting."
exit
1
exit
1
fi
fi
# Check if $DATABASE_URL is defined, if not, use a standard sqlite database.
if
[[
!
-v
DATABASE_URL_PREFIX
]]
;
then
#
echo
"DATABASE_URL_PREFIX is not defined. Aborting..."
# If the $DATABASE_URL is defined and is postgres, check if it is available
exit
1
# yet. Do not start the container before the postgresql boots up.
#
# If the $DATABASE_URL is defined and is mysql, check if the database is
# available before the container boots up.
#
# TODO: Check the database type and detect if it is up based on that. For now,
# assume that postgres is being used if DATABASE_URL is defined.
if
[[
!
-v
DATABASE_URL
]]
;
then
echo
"DATABASE_URL is not defined. Using sqlite database..."
export
DATABASE_URL
=
sqlite://mailmanweb.db
export
DATABASE_TYPE
=
'sqlite'
fi
fi
if
[[
!
-v
DB_NAME
]]
;
then
echo
"DB_NAME is not defined. Aborting..."
exit
1
fi
export
DATABASE_URL
=
"
$DATABASE_URL_PREFIX
/
$DB_NAME
"
# this is the default database that will exist on a new created Postgres service on huaweicloud.
export
DEFAULT_URL
=
"
$DATABASE_URL_PREFIX
/postgres"
if
[[
"
$DATABASE_TYPE
"
=
'postgres'
]]
if
[[
"
$DATABASE_TYPE
"
=
'postgres'
]]
then
then
wait_for_postgres
wait_for_postgres
elif
[[
"
$DATABASE_TYPE
"
=
'mysql'
]]
create_default_database
then
else
wait_for_mysql
echo
"Entrypoint.sh only support postgres, please check and update"
exit
1
fi
fi
# Check if we are in the correct directory before running commands.
# Check if we are in the correct directory before running commands.
...
...
mail/openeuler.org/maildatabase.yaml
已删除
100644 → 0
浏览文件 @
07580a40
# StatefulSet for postgres database service
---
kind
:
StatefulSet
apiVersion
:
apps/v1beta1
metadata
:
name
:
mailman-database
namespace
:
mail
labels
:
app
:
mail-suit-service
spec
:
serviceName
:
mail-suit-service
replicas
:
1
selector
:
matchLabels
:
app
:
mail-suit-service
template
:
metadata
:
labels
:
app
:
mail-suit-service
spec
:
containers
:
-
name
:
mailman-database
image
:
postgres:9.6-alpine
imagePullPolicy
:
"
IfNotPresent"
volumeMounts
:
-
mountPath
:
/var/lib/postgresql/data
name
:
mailman-database-volume
subPath
:
postgres
env
:
-
name
:
POSTGRES_DB
value
:
mailmandb
-
name
:
POSTGRES_USER
value
:
mailman
-
name
:
POSTGRES_PASSWORD
value
:
mailmanpass
-
name
:
PGDATA
value
:
/var/lib/postgresql/data/postgres
#NOTE: Empty dir can't be used in a production dir. Please upgrade it before using.
volumes
:
-
name
:
mailman-database-volume
persistentVolumeClaim
:
claimName
:
db-data-vol
mail/openeuler.org/storage.yaml
浏览文件 @
c07cf7ac
## define the postgros volume
---
apiVersion
:
v1
kind
:
PersistentVolumeClaim
metadata
:
name
:
db-data-vol
namespace
:
mail
spec
:
accessModes
:
-
ReadWriteMany
resources
:
requests
:
storage
:
100Gi
storageClassName
:
ssd
volumeMode
:
Filesystem
## define the config volume for both mail-core & exim4
## define the config volume for both mail-core & exim4
---
---
apiVersion
:
v1
apiVersion
:
v1
...
...
mail/openeuler.org/webservice.yaml
浏览文件 @
c07cf7ac
...
@@ -58,7 +58,7 @@ spec:
...
@@ -58,7 +58,7 @@ spec:
containers
:
containers
:
-
name
:
mailman-web
-
name
:
mailman-web
# We modified the mail-web image to add static folder.
# We modified the mail-web image to add static folder.
image
:
swr.cn-north-1.myhuaweicloud.com/openeuler/mail-web:v1.0.
0
image
:
swr.cn-north-1.myhuaweicloud.com/openeuler/mail-web:v1.0.
1
imagePullPolicy
:
"
IfNotPresent"
imagePullPolicy
:
"
IfNotPresent"
volumeMounts
:
volumeMounts
:
-
mountPath
:
/opt/mailman-web-config
-
mountPath
:
/opt/mailman-web-config
...
@@ -73,8 +73,12 @@ spec:
...
@@ -73,8 +73,12 @@ spec:
env
:
env
:
-
name
:
DATABASE_TYPE
-
name
:
DATABASE_TYPE
value
:
postgres
value
:
postgres
-
name
:
DATABASE_URL
-
name
:
DATABASE_URL_PREFIX
value
:
postgres://mailman:mailmanpass@mailman-database-0.mail-suit-service.mail.svc.cluster.local/mailmandb
#NOTE: Replace Postgres-Service-ConnectionURL with real connection info.
#For instance postgres://username:password@internal_ip_address:5432
value
:
<Postgres-Service-ConnectionURL>
-
name
:
DB_NAME
value
:
mailmandb
-
name
:
HYPERKITTY_API_KEY
-
name
:
HYPERKITTY_API_KEY
valueFrom
:
valueFrom
:
secretKeyRef
:
secretKeyRef
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录