diff --git a/.gitignore b/.gitignore index d8fe0c5..5f3acb0 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ venv.bak/ # mypy .mypy_cache/ + +.idea diff --git a/Dockerfile-online b/Dockerfile-online index d9419f0..045d1ed 100644 --- a/Dockerfile-online +++ b/Dockerfile-online @@ -5,4 +5,4 @@ COPY . /code WORKDIR /code/src RUN pip install /code/pkgs/base/* -ENTRYPOINT python manage.py runserver 0.0.0.0:8000 \ No newline at end of file +ENTRYPOINT python manage.py runserver 0.0.0.0:8080 diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 8678511..775fe6e 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -8,7 +8,7 @@ pipeline { DOCKER_CREDENTIAL_ID = 'dockerhub' KUBECONFIG_CREDENTIAL_ID = 'kubeconfig' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'shaowenchen' + DOCKERHUB_NAMESPACE = 'kubespheredev' APP_NAME = 'devops-python-sample' SONAR_CREDENTIAL_ID = 'sonar-token' } @@ -20,7 +20,7 @@ pipeline { stage('拉取代码') { steps { container('base') { - checkout([$class: 'GitSCM', branches: [[name: '*/$BRANCH_NAME']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/shaowenchen/devops-python-sample.git']]]) + checkout([$class: 'GitSCM', branches: [[name: '*/$BRANCH_NAME']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/kubesphere/devops-python-sample.git']]]) } /* if in scm, you can use: checkout scm */ } @@ -32,11 +32,11 @@ pipeline { withCredentials([string(credentialsId : "$SONAR_CREDENTIAL_ID" ,variable : 'SONAR_TOKEN' ,)]) { withSonarQubeEnv('sonar') { sh '''pip install pkgs/base/* & pip install pkgs/extra/* - coverage erase - cd ./src/ - coverage run --source='.' manage.py test - coverage xml -i - ''' + coverage erase + cd ./src/ + coverage run --source='.' manage.py test + coverage xml -i + ''' sh "sonar-scanner -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN" } @@ -63,7 +63,12 @@ pipeline { stage('部署') { steps { - kubernetesDeploy(enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID", configs: 'deploy/**') + container ('base') { + withCredentials([kubeconfigFile(credentialsId: env.KUBECONFIG_CREDENTIAL_ID, variable: 'KUBECONFIG')]) { + sh 'envsubst < deploy/devops-sample.yaml | kubectl apply -f -' + sh 'envsubst < deploy/devops-sample-svc.yaml | kubectl apply -f -' + } + } } } diff --git a/README.md b/README.md index 4d5db55..0e947cf 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## 部署步骤 -1. 在 Kubesphere 平台,创建命名为 django-proj 的工程。 +1. 在 Kubesphere 平台,创建命名为 django-proj 的项目。 在 Kubesphere 中,项目对应 namespace 。如果不使用 django-proj 命名空间,则需要修改 Jenkinsfile 文件,保持一致。