Skip to content

Commit

Permalink
feature: PaaS 容器部署适配 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon committed Sep 17, 2021
1 parent a955790 commit 61e4094
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ celerybeat-schedule
# Environments
.env
.venv
env/
venv/
ENV/

Expand Down Expand Up @@ -177,3 +176,5 @@ tests/postman/bkman
# Thumbnails
._*


.helm
2 changes: 1 addition & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from blueapps.conf.default_settings import * # noqa
from blueapps.conf.log import get_logging_config_dict

import env
from apps.utils.enum import EnhanceEnum
from apps.utils.env import get_type_env
from config import env

# pipeline 配置
from pipeline.celery.settings import CELERY_QUEUES as PIPELINE_CELERY_QUEUES
Expand Down
12 changes: 12 additions & 0 deletions env/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available.
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at https://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from .paas_version_diff import * # noqa
15 changes: 1 addition & 14 deletions config/env/__init__.py → env/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
specific language governing permissions and limitations under the License.
"""


from enum import Enum
from typing import Dict

from apps.utils.enum import EnhanceEnum
from apps.utils.env import get_type_env


class BkPaaSVersion(EnhanceEnum):
Expand All @@ -23,16 +23,3 @@ class BkPaaSVersion(EnhanceEnum):
@classmethod
def _get_member__alias_map(cls) -> Dict[Enum, str]:
return {cls.V2: "V2", cls.V3: "V3具备容器及二进制配置差异"}


BKPAAS_MAJOR_VERSION = get_type_env(key="BKPAAS_MAJOR_VERSION", default=BkPaaSVersion.V2.value, _type=int)
BKAPP_IS_V3_CONTAINER = get_type_env(key="BKAPP_IS_V3_CONTAINER", default=False, _type=bool)


if BKPAAS_MAJOR_VERSION == BkPaaSVersion.V3.value:
if BKAPP_IS_V3_CONTAINER:
from .env_v3_container import * # noqa
else:
from .env_v3 import * # noqa
else:
from .env_v2 import * # noqa
38 changes: 38 additions & 0 deletions env/paas_version_diff/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available.
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at https://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from apps.utils.env import get_type_env

from .. import constants

__all__ = [
"ENVIRONMENT",
"BK_BACKEND_CONFIG",
"BKAPP_IS_PAAS_DEPLOY",
"BK_COMPONENT_API_URL",
"BK_NODEMAN_HOST",
"BK_NODEMAN_BACKEND_HOST",
"BK_IAM_APP_CODE",
"BK_IAM_SAAS_HOST",
"BK_IAM_RESOURCE_API_HOST",
]


BKPAAS_MAJOR_VERSION = get_type_env(key="BKPAAS_MAJOR_VERSION", default=constants.BkPaaSVersion.V2.value, _type=int)
BKAPP_IS_V3_CONTAINER = get_type_env(key="BKAPP_IS_V3_CONTAINER", default=False, _type=bool)


if BKPAAS_MAJOR_VERSION == constants.BkPaaSVersion.V3.value:
if BKAPP_IS_V3_CONTAINER:
from env.paas_version_diff.paas_v3_container import * # noqa
else:
from env.paas_version_diff.paas_v3 import * # noqa
else:
from env.paas_version_diff.paas_v2 import * # noqa
File renamed without changes.
2 changes: 1 addition & 1 deletion config/env/env_v3.py → env/paas_version_diff/paas_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
specific language governing permissions and limitations under the License.
"""

from .env_v2 import * # noqa
from .paas_v2 import * # noqa

# PaaS 二进制版本 v2 v3 主要的差异配置
ENVIRONMENT = get_type_env(key="BKPAAS_ENVIRONMENT", default="dev", _type=str)
File renamed without changes.
1 change: 1 addition & 0 deletions pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ cp -R bk_nodeman/script_tools ${NODEMAN_DIST_DIR}
cp -R bk_nodeman/config ${NODEMAN_DIST_DIR}
cp -R bk_nodeman/iam ${NODEMAN_DIST_DIR}
cp -R bk_nodeman/upgrade ${NODEMAN_DIST_DIR}
cp -R bk_nodeman/env ${NODEMAN_DIST_DIR}

cp bk_nodeman/manage.py ${NODEMAN_DIST_DIR}
cp bk_nodeman/settings.py ${NODEMAN_DIST_DIR}
Expand Down

0 comments on commit 61e4094

Please sign in to comment.