開源DevOps平臺(tái)之CDS試用

Docker Compose

Run with Docker-Compose

The docker-compose.yml contains:

  • cds-db service with a PostgreSQL
  • cds-cache service with a Redis
  • elasticsearch service with an Elasticsearch
  • dockerhost allows cds-hatchery-swarm service to communicate with the local docker daemon
  • cds-migrate service to prepare databases for API and CDN
  • cds-api service
  • cds-ui service
  • cds-elasticsearch service
  • cds-hatchery-swarm service
  • cds-vcs service
  • cds-repositories service
  • cds-cdn service

Docker compose is very convenient to launch CDS for testing it. But this is not recommended for a Production Installation.

How to run

Windows平臺(tái)下,請(qǐng)使用git-bash操作

$ mkdir /tmp/cdstest && cd /tmp/cdstest && mkdir -p tools/smtpmock
$ curl https://raw.githubusercontent.com/ovh/cds/0.48.1/docker-compose.yml -o docker-compose.yml
# hostname需要注意一下,如需修改陆盘,請(qǐng)修改*HOSTNAME*變量,其他地方有用到
$ export HOSTNAME=$(hostname)
$ export CDS_DOCKER_IMAGE=ovhcom/cds-engine:0.48.1

# Get the latest version
$ docker pull ovhcom/cds-engine:0.48.1

# Create PostgreSQL database, redis and elasticsearch
$ docker-compose up --no-recreate -d cds-db cds-cache elasticsearch dockerhost

# check if database is up, the logs must contain "LOG: database system is ready to accept connections"
$ docker-compose logs| grep 'database system is ready to accept connections'
# you should have this line after few seconds: cds-db_1 | LOG:  database system is ready to accept connections

$ docker-compose up --no-recreate cds-db-init
$ docker-compose up --no-recreate cds-migrate
# You should have this log: "cdstest_cds-migrate_1 exited with code 0"

# prepare initial configuration.
$ docker-compose up cds-prepare

# disable the smtp server
$ export CDS_EDIT_CONFIG="api.smtp.disable=true"
$ docker-compose up cds-edit-config

# run API
$ docker-compose up -d cds-api

# the INIT_TOKEN variable will be used by cdsctl to create first admin user
$ TOKEN_CMD=$(docker logs cdstest_cds-prepare_1|grep TOKEN) && $TOKEN_CMD
# if you have this error:  "command too long: export INIT_TOKEN=....",
# you can manually execute the command "export INIT_TOKEN=...."
# docker logs應(yīng)該獲取不到日志的了,自己復(fù)制"export INIT_TOKEN=...."那段執(zhí)行就好
# 以下執(zhí)行cdsctl命令都需要有*INIT_TOKEN*變量支持

# create user
$ curl 'http://localhost:8081/download/cdsctl/linux/amd64?variant=nokeychain' -o cdsctl
# on OSX: $ curl 'http://localhost:8081/download/cdsctl/darwin/amd64?variant=nokeychain' -o cdsctl
# windows: $ curl 'http://localhost:8081/download/cdsctl/windows/amd64?variant=nokeychain' -o cdsctl.exe
$ chmod +x cdsctl
$ ./cdsctl signup --api-url http://localhost:8081 --email admin@localhost.local --username admin --fullname admin
# enter a strong password

# verify the user
$ VERIFY_CMD=$(docker-compose logs cds-api|grep 'cdsctl signup verify'|cut -d '$' -f2|xargs) && ./$VERIFY_CMD
# if you have this error:  "such file or directory: ./cdsctl signup verify --api-url...", 
# you can manually execute the command "./cdsctl signup verify --api-url..."

# run cdsctl 
$ ./cdsctl user me

# should returns something like:
#./cdsctl user me
#created   2019-12-18 14:25:53.089718 +0000 UTC
#fullname  admin
#id        vvvvv-dddd-eeee-dddd-fffffffff
#ring      ADMIN
#username  admin

# run others services
$ docker-compose up -d cds-ui cds-cdn cds-hooks cds-elasticsearch cds-hatchery-swarm

# create first worker model
$ ./cdsctl worker model import https://raw.githubusercontent.com/ovh/cds/0.48.1/contrib/worker-models/go-official-1.13.yml

# import Import a workflow template
$ ./cdsctl template push https://raw.githubusercontent.com/ovh/cds/0.48.1/contrib/workflow-templates/demo-workflow-hello-world/demo-workflow-hello-world.yml
Workflow template shared.infra/demo-workflow-hello-world has been created
Template successfully pushed !

# create project, then create a workflow from template
$ ./cdsctl project create DEMO FirstProject
$ ./cdsctl template apply DEMO MyFirstWorkflow shared.infra/demo-workflow-hello-world --force --import-push --quiet

# run CDS Workflow!
$ ./cdsctl workflow run DEMO MyFirstWorkflow
Workflow MyFirstWorkflow #1 has been launched
http://localhost:8080/project/DEMO/workflow/MyFirstWorkflow/run/1

  • Login on WebUI

Open a browser on http://localhost:8080/account/signup, then login with the user admin,

  • Check on UI

on http://localhost:8080/project/DEMO/workflow/MyFirstWorkflow/run/1 you will have

Workflow Generated

You see that the pipeline deploy in production was not launched automatically. There is a Run Condition on it cds.manual = true:

Run Condition

The build pipeline contains two stages, with only one job in each stage

Build Pipeline

Setup connection with a VCS

# READ THE section https://ovh.github.io/cds/docs/integrations/github/github_repository_manager/#create-a-cds-application-on-github to generate the clientId and clientSecret.
# Short version: 
# go on https://github.com/settings/applications/new
# Application name: cds-test-docker-compose
# Homepage URL: http://localhost:8080
# Authorization callback: http://localhost:8080/cdsapi/repositories_manager/oauth2/callback
# send click on register application.
$ export CDS_EDIT_CONFIG="vcs.servers.github.github.clientId=xxxxx vcs.servers.github.github.clientSecret=xxxxx " 
$ docker-compose up cds-edit-config
$ docker-compose up -d cds-vcs cds-repositories

Notice that here, you have the VCS and Repositories services up and running.

vcs: The aim of this μService is to communicate with Repository Manager as GitHub, GitLab, Bitbucket… But, as your CDS is not probably public, GitHub won’t be able to call your CDS to automatically run your workflow on each git push.

repositories: this μService is used to enable the as-code feature. Users can store CDS Files on their repositories. This service clones user repositories on local filesystem.

Then, next with Actions, Plugins

  • Import actions, example:
$ ./cdsctl action import https://raw.githubusercontent.com/ovh/cds/0.48.1/contrib/actions/cds-docker-package.yml

Go further

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末键菱,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子火焰,更是在濱河造成了極大的恐慌,老刑警劉巖胧沫,帶你破解...
    沈念sama閱讀 222,000評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件昌简,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡绒怨,警方通過查閱死者的電腦和手機(jī)纯赎,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,745評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來南蹂,“玉大人犬金,你說我怎么就攤上這事。” “怎么了晚顷?”我有些...
    開封第一講書人閱讀 168,561評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵峰伙,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我该默,道長(zhǎng)瞳氓,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,782評(píng)論 1 298
  • 正文 為了忘掉前任栓袖,我火速辦了婚禮匣摘,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘裹刮。我一直安慰自己音榜,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,798評(píng)論 6 397
  • 文/花漫 我一把揭開白布捧弃。 她就那樣靜靜地躺著囊咏,像睡著了一般。 火紅的嫁衣襯著肌膚如雪塔橡。 梳的紋絲不亂的頭發(fā)上梅割,一...
    開封第一講書人閱讀 52,394評(píng)論 1 310
  • 那天,我揣著相機(jī)與錄音葛家,去河邊找鬼户辞。 笑死,一個(gè)胖子當(dāng)著我的面吹牛癞谒,可吹牛的內(nèi)容都是我干的底燎。 我是一名探鬼主播,決...
    沈念sama閱讀 40,952評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼弹砚,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼双仍!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起桌吃,我...
    開封第一講書人閱讀 39,852評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤朱沃,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后茅诱,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體逗物,經(jīng)...
    沈念sama閱讀 46,409評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,483評(píng)論 3 341
  • 正文 我和宋清朗相戀三年瑟俭,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了翎卓。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,615評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡摆寄,死狀恐怖失暴,靈堂內(nèi)的尸體忽然破棺而出坯门,到底是詐尸還是另有隱情,我是刑警寧澤逗扒,帶...
    沈念sama閱讀 36,303評(píng)論 5 350
  • 正文 年R本政府宣布田盈,位于F島的核電站,受9級(jí)特大地震影響缴阎,放射性物質(zhì)發(fā)生泄漏允瞧。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,979評(píng)論 3 334
  • 文/蒙蒙 一蛮拔、第九天 我趴在偏房一處隱蔽的房頂上張望述暂。 院中可真熱鬧,春花似錦建炫、人聲如沸畦韭。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,470評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)艺配。三九已至,卻和暖如春衍慎,著一層夾襖步出監(jiān)牢的瞬間转唉,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,571評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工稳捆, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留赠法,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 49,041評(píng)論 3 377
  • 正文 我出身青樓乔夯,卻偏偏與公主長(zhǎng)得像砖织,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子末荐,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,630評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容