curl -L https://github.com/jenkins-x/jx/releases/download/v1.3.1119/jx-linux-amd64.tar.gz | tar xzv
mv jx /usr/local/bin
查看版本:
jx version
NAME VERSION
jx 1.3.1119
jenkins x platform 2.0.2375
Kubernetes cluster v1.16.13
kubectl v1.16.13
helm client v2.16.10+gbceca24
helm server v2.16.10+gbceca24
git git version 2.24.1
Operating System CentOS Linux release 7.6.1810 (Core)
安装 Git 2.x:
如果使用 Git 1.x 的版本,可能会遇到类似下面的错误:
FATAL: initialise build packs failed: there was a problem ensuring the branch master has tracking info: git output: error: pathspec 'master' did not match any file(s) known to git.: failed to run 'git checkout master' command in directory '/root/.jx/draft/packs/github.com/jenkins-x-buildpacks/jenkins-x-kubernetes', output: 'error
解决办法是,进入提示目录,手工拉取。
cd /root/.jx/draft/packs/github.com/jenkins-x-buildpacks/jenkins-x-kubernetes
git pull
更好的方法是,升级 Git 的版本至 2.x ,下面以 CentOS 7 为例:
yum remove git*
yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
yum install -y git
git version
git version 2.24.1
测试集群是否满足要求
在安装完 jx 命令之后,可以使用下面的命令进行检测:
jx compliance run
jx compliance status
大约需要运行几十分钟,运行下面的命令可以看到最终的执行结果:
jx compliance results
最后删掉相关负载:
jx compliance delete
安装 Jenkins X 服务端
Jenkins X 内置的服务组件依赖 Ingress ,可以根据文档使用 Helm 安装 Ingress 提前安装。
开始安装:
jx install --verbose
接着会有一系列交互:
? Cloud Provider kubernetes
...
> [x] helm
[x] kubectl
...
? Please enter the name you wish to use with git: shaowenchen
? Please enter the email address you wish to use with git: mail@chenshaowen.com
...
? Would you like wait and resolve this address to an IP address and use it for the domain? Yes
...
? Domain dev.chenshaowen.com
...
? github.com username: shaowenchen
...
Please click this URL and generate a token
https://github.com/settings/tokens/new?scopes=repo,read:user,read:org,user:email,write:repo_hook,delete_repo
? API Token: *****************************************
? Select Jenkins installation type: Serverless Jenkins
? Pick default workload build pack: Kubernetes Workloads: Automated CI+CD with GitOps Promotion
Jenkins X installation completed successfully
INFO[0094]
********************************************************
NOTE: Your admin password is: Sr5!8LZz!QfMD84KBZWR
********************************************************
jx get env
NAME LABEL KIND PROMOTE NAMESPACE ORDER CLUSTER SOURCE REF PR
dev Development Development Never jx 0
staging Staging Permanent Auto jx-staging 100 https://github.com/shaowenchen/environment-antdisco-staging.git
production Production Permanent Manual jx-production 200 https://github.com/shaowenchen/environment-antdisco-production.git
Jenkins X 在 Git Repo 中对基础设置进行存储,通过 PR 进行修改管理。
删除环境:
jx delete env dev
创建环境:
jx create env env-name
应用开发
创建应用:
jx create quickstart
? Do you wish to use shaowenchen as the Git user name? Yes
? Which organisation do you want to use? shaowenchen
? Enter the new repository name: jx-quickstart-demo
? select the quickstart you wish to create jx-quickstart-demo
INFO[0035] Pushed Git repository to https://github.com/shaowenchen/jx-quickstart-demo
INFO[0051] Creating GitHub webhook for shaowenchen/jx-quickstart-demo for url http://hook.jx.dev.chenshaowen.com/hook