2017-04-05 63 views
0

我试图处理kubernetes(openshift起源)autodeploy。下面是ci-config。gitlab自动部署到kubernetes/openshift:错误:不匹配“:master”

据我了解CI应该得到的代码,检查dockerfile,如果它不存在(它不是) - 建立herokuish容器并推送到kubernetes。但是,我得到一个错误:

$ command deploy 
Generating kubeconfig... 
Cluster "gitlab-deploy" set. 
User "gitlab-deploy" set. 
Context "gitlab-deploy" set. 
Switched to context "gitlab-deploy". 

Running on OpenShift. 
Deleting old application... 
No resources found 

Creating application... 
error: no match for ":master" 

CI:

# Explanation on the scripts: 
# https://gitlab.com/gitlab-examples/openshift-deploy/blob/master/README.md 
image: registry.gitlab.com/gitlab-examples/openshift-deploy 
services: 
    - mysql:5.7 
variables: 
    # Application deployment domain 
    KUBE_DOMAIN: kub.kub.myopenshift.com 
    MYSQL_DATABASE: database 
    MYSQL_ROOT_PASSWORD: secret 
cache: 
    key: "$CI_BUILD_REF_NAME" 
    untracked: true 
    paths: 
    - vendor/ 
    - .env 
stages: 
    #- build 
    #- test 
    - review 
    - staging 
    - production 
    - cleanup 
#build: 
# stage: build 
# script: 
# - composer install --ignore-platform-reqs 
# - cp .env.testing .env 
# only: 
# - branches 
#test: 
# stage: test 
# script: 
# - php vendor/bin/phpunit --colors 
# only: 
# - branches 
production: 
    stage: production 
    variables: 
    CI_ENVIRONMENT_URL: http://$CI_PROJECT_NAME.$KUBE_DOMAIN 
    script: 
    - command deploy 
    environment: 
    name: production 
    url: http://$CI_PROJECT_NAME.$KUBE_DOMAIN 
    when: manual 
    only: 
    - master 
staging: 
    stage: staging 
    variables: 
    CI_ENVIRONMENT_URL: http://$CI_PROJECT_NAME-staging.$KUBE_DOMAIN 
    script: 
    - command deploy 
    environment: 
    name: staging 
    url: http://$CI_PROJECT_NAME-staging.$KUBE_DOMAIN 
    only: 
    - master 
review: 
    stage: review 
    variables: 
    CI_ENVIRONMENT_URL: http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$KUBE_DOMAIN 
    script: 
    - command deploy 
    environment: 
    name: review/$CI_COMMIT_REF_NAME 
    url: http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$KUBE_DOMAIN 
    on_stop: stop_review 
    only: 
    - branches 
    except: 
    - master 
stop_review: 
    stage: cleanup 
    variables: 
    GIT_STRATEGY: none 
    script: 
    - command destroy 
    environment: 
    name: review/$CI_COMMIT_REF_NAME 
    action: stop 
    when: manual 
    only: 
    - branches 
    except: 
    - master 

我在做什么错?是否应该在openshift中额外设置一些内容?

回答

0

没有在这里做所有的步骤,我只是尝试从step where命令它失败了,你在deploy script

oc new-app "--name=${CI_ENVIRONMENT_SLUG}" "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG" 

我在OpenShift环境跑类似的命令,我猜你的环境变量CI_REGISTRY_IMAGE没有设置,所以脚本正在它是空值。

我跑

$ oc new-app :master 
error: no match for ":master" 

The 'oc new-app' command will match arguments to the following types: 

    1. Images tagged into image streams in the current project or the 'openshift' project 
    - if you don't specify a tag, we'll add ':latest' 
    2. Images in the Docker Hub, on remote registries, or on the local Docker engine 
    3. Templates in the current project or the 'openshift' project 
    4. Git repository URLs or local paths that point to Git repositories 

--allow-missing-images can be used to point to an image that does not exist yet. 

See 'oc new-app -h' for examples. 

结帐这类似于你得到了一个错误:

error: no match for ":master" 

因此,尝试导出一个环境变量。