博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
阿里云容器服务Kubernetes之Jenkins X(1)-安装部署实践篇
阅读量:6464 次
发布时间:2019-06-23

本文共 6716 字,大约阅读时间需要 22 分钟。

本文的部署实践过程参考了云栖文章 并记录了更详细的过程及日志输出。

下面我们开始介绍如何在阿里云容器服务Kubernetes上快速安装部署Jenkins X。

1. 首先,需要在 创建一个Kubernetes集群,本次实践使用的环境信息如下:

master1 192.168.0.134

master2 192.168.0.135
master3 192.168.0.136
worker1 192.168.0.137

2. 登录worker1节点(也可以使用集群外的任意ecs环境)并初始化helm client
# mkdir $HOME/.kube# scp root@192.168.0.134:/etc/kubernetes/kube.conf $HOME/.kube/configroot@192.168.0.134's password:kube.conf                                                                                                                                       100% 5472     8.4MB/s   00:00# scp root@192.168.0.134:/usr/local/bin/helm /usr/local/bin/helmroot@192.168.0.134's password:helm                                                                                                                                            100%   29MB 104.0MB/s   00:00
# helm init --client-onlyCreating /root/.helmCreating /root/.helm/repositoryCreating /root/.helm/repository/cacheCreating /root/.helm/repository/localCreating /root/.helm/pluginsCreating /root/.helm/startersCreating /root/.helm/cache/archiveCreating /root/.helm/repository/repositories.yamlAdding stable repo with URL: https://kubernetes-charts.storage.googleapis.comAdding local repo with URL: http://127.0.0.1:8879/charts$HELM_HOME has been configured at /root/.helm.Not installing Tiller due to 'client-only' flag having been setHappy Helming!
3. 安装 git。
yum install git -y
4. 安装jx客户端
# curl -L https://github.com/jenkins-x/jx/releases/download/v1.3.464/jx-linux-amd64.tar.gz | tar xzv# mv jx /usr/local/bin
# jx versionUsing helmBinary helm with feature flag: noneNAME               VERSIONjx                 1.3.464Kubernetes cluster v1.11.2kubectl            v1.11.2helm client        v2.9.1+g20adb27helm server        v2.9.1+g20adb27git                git version 1.8.3.1A new jx version is available: 1.3.470? Would you like to upgrade to the new jx version? No
5. 下载 cloud-environments 云环境配置文件
# mkdir -p ~/.jx# cd ~/.jx# git clone https://github.com/haoshuwei/cloud-environments.git正克隆到 'cloud-environments'...remote: Enumerating objects: 526, done.remote: Total 526 (delta 0), reused 0 (delta 0), pack-reused 526接收对象中: 100% (526/526), 229.61 KiB | 261.00 KiB/s, done.处理 delta 中: 100% (263/263), done.
6. 安装jenkins-x-platform到Kubernetes集群
# jx install --provider=kubernetes --domain aliyunk8s.com

image

访问日志中提示的GitHub URL 并生成API Token:

https://github.com/settings/tokens/new?scopes=repo,read:user,read:org,user:email,write:repo_hook,delete_repo

image

新打开一个终端窗口查看jenkins-x-platform各个组件的安装情况:

# kubectl get ing -n jxNAME              HOSTS                              ADDRESS         PORTS     AGEchartmuseum       chartmuseum.jx.aliyunk8s.com       xx.xx.xxx.xxx   80        49sdocker-registry   docker-registry.jx.aliyunk8s.com   xx.xx.xxx.xxx   80        49sjenkins           jenkins.jx.aliyunk8s.com           xx.xx.xxx.xxx   80        48smonocular         monocular.jx.aliyunk8s.com         xx.xx.xxx.xxx   80        49snexus             nexus.jx.aliyunk8s.com             xx.xx.xxx.xxx   80        49s

绑定hosts:

# cat /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6xx.xx.xxx.xxx chartmuseum.jx.aliyunk8s.comxx.xx.xxx.xxx docker-registry.jx.aliyunk8s.comxx.xx.xxx.xxx jenkins.jx.aliyunk8s.comxx.xx.xxx.xxx monocular.jx.aliyunk8s.comxx.xx.xxx.xxx nexus.jx.aliyunk8s.com

查看jenkins-x-platform组件的安装情况:

[root@iZj6cbxzol17fruawjffz1Z ~]# kubectl get pod -n jxNAME                                             READY     STATUS             RESTARTS   AGEjenkins-67d7cc5fcd-x6686                         1/1       Running            0          8mjenkins-x-chartmuseum-84b895f4c5-d2dgc           1/1       Running            0          8mjenkins-x-docker-registry-6b6f6d67b6-kn9ml       1/1       Running            0          8mjenkins-x-heapster-65fd697bb-4czvz               2/2       Running            0          8mjenkins-x-mongodb-784f66c466-zz429               0/1       Pending            0          8mjenkins-x-monocular-api-58796c57c9-xk8rs         0/1       CrashLoopBackOff   5          8mjenkins-x-monocular-prerender-5848c74fdc-48ppm   1/1       Running            0          8mjenkins-x-monocular-ui-c4467bdc5-ttbr6           1/1       Running            0          8mjenkins-x-nexus-b7454965d-nvlqb                  1/1       Running            0          8mpipelinecontroller-6b5b8d9f47-457xx              1/1       Running            0          8m

发现jenkins-x-mongodb和jenkins-x-monocular-api组件启动异常,这是因为jenkins-x-monocular-api依赖jenkins-x-mongodb, 而jenkins-x-mongodb在创建pvc资源时找不到default storage class而导致的;编辑mongodb-pvc.yaml创建新pvc:

# cat mongodb-pvc.yamlkind: PersistentVolumeClaimapiVersion: v1metadata:  name: jenkins-x-mongodb  namespace: jxspec:  accessModes:    - ReadWriteOnce  storageClassName: alicloud-disk-available  resources:    requests:      storage: 20Gi
# kubectl get pvc -n jxNAME                        STATUS    VOLUME                   CAPACITY   ACCESS MODES   STORAGECLASS              AGEjenkins                     Bound     d-j6c8mnao06oovpk0vy4h   30Gi       RWO            alicloud-disk-available   18mjenkins-x-chartmuseum       Bound     d-j6c9szfy8smf4ak05hm9   20Gi       RWO            alicloud-disk-available   18mjenkins-x-docker-registry   Bound     d-j6cc913ulnzfa7drkru9   100Gi      RWO            alicloud-disk-available   18mjenkins-x-mongodb           Pending                                                                                18mjenkins-x-nexus             Bound     d-j6cfrymuj8lrj2pvz3v0   20Gi       RWO            alicloud-disk-available   18m
# kubectl delete pvc jenkins-x-mongodb -n jxpersistentvolumeclaim "jenkins-x-mongodb" deleted
# kubectl create -f mongodb-pvc.yamlpersistentvolumeclaim/jenkins-x-mongodb created
# kubectl delete  pods jenkins-x-mongodb-784f66c466-zz429 -n jxpod "jenkins-x-mongodb-784f66c466-zz429" deleted# kubectl delete  pods jenkins-x-monocular-api-58796c57c9-xk8rs -n jxpod "jenkins-x-monocular-api-58796c57c9-xk8rs" deleted

全部组件运行正常后可以看到jenkins-x-platform的安装进程进入下一步jenkins CLI API Token的配置:

image
根据提示获取token填入后, 安装部署完成:
image
image

7. 查看ingress暴露出来的服务url
# jx get urlsName                      URLjenkins                   http://jenkins.jx.aliyunk8s.comjenkins-x-chartmuseum     http://chartmuseum.jx.aliyunk8s.comjenkins-x-docker-registry http://docker-registry.jx.aliyunk8s.comjenkins-x-monocular-api   http://monocular.jx.aliyunk8s.comjenkins-x-monocular-ui    http://monocular.jx.aliyunk8s.comnexus                     http://nexus.jx.aliyunk8s.com

访问:

image
访问:
image
访问:
image
docker-registry服务的访问有问题(暂时未花过多时间调试), 但我们会在下一篇中演示如何让jenkins x使用阿里云容器镜像服务来管理容器镜像; 中也会使用jenkins x创建一个spring应用并演示如何使用GitOps的理念管理和发布一个云原生应用。

转载地址:http://hnezo.baihongyu.com/

你可能感兴趣的文章
==与equals()的区别
查看>>
基本分类方法——KNN(K近邻)算法
查看>>
在XenCenter6.2中构建CentOS7虚拟机的启动错误
查看>>
.NET Framework3.0/3.5/4.0/4.5新增功能摘要
查看>>
php中表单提交复选框与下拉列表项
查看>>
熟悉常用的Linux操作
查看>>
WordPress 前端投稿/编辑发表文章插件 DJD Site Post(支持游客和已注册用户)汉化版 免费下载...
查看>>
C# 自定义事件整理项目 - EventDemo
查看>>
面象过程与面象对象
查看>>
用CSS实现图片水印效果代码
查看>>
谷歌设置支持webgl
查看>>
P3402 【模板】可持久化并查集
查看>>
js的AJAX请求有关知识总结
查看>>
Eclipse添加新server时无法选择Tomcat7的问题
查看>>
L207
查看>>
nginx 配置https 负载均衡
查看>>
双拓扑排序 HDOJ 5098 Smart Software Installer
查看>>
三分 POJ 2420 A Star not a Tree?
查看>>
36.Node.js 工具模块--OS模块系统操作
查看>>
存储过程报错行提示
查看>>