Openshift E02 部署Jenkins服务

OpenShift 项目默认提供了两个Jenkins部署模板, Jenkins-ephemeral 和 Jenkins-persistent

  • Jenkins-ephemeral 模板部署的Jenkins服务的数据在容器退出后将丢失,适合测试使用;

  • Jenkins-persistent 模板部署需要持久化卷的支持,其部署的Jenkins 服务的数据可以被持久化。

这里有很多官方的案例源码: https://github.com/openshift/origin/tree/v1.3.0/examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
oc login -u developer https://192.168.99.109:8443

# create a new project, name: ci
oc new-project ci

# Create a template,
oc create -f https://raw.githubusercontent.com/openshift/origin/v1.3.0/examples/jenkins/jenkins-ephemeral-template.json

# Get template
oc get template
NAME DESCRIPTION PARAMETERS OBJECTS
jenkins-ephemeral Jenkins service, without persistent storage.... 6 (1 generated) 6

#
➜ ~ oc policy add-role-to-user edit -z default
role "edit" added: "default"

#
➜ ~ oc new-app --template=jenkins-ephemeral --param=JENKINS_PASSWORD=welcome123
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--> Deploying template "ci/jenkins-ephemeral" to project ci

jenkins-ephemeral
---------
Jenkins service, without persistent storage.
WARNING: Any data stored will be lost upon pod destruction. Only use this template for testing

A Jenkins service has been created in your project. The username/password are admin/welcome. The tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template.

* With parameters:
* Jenkins Service Name=jenkins
* Jenkins JNLP Service Name=jenkins-jnlp
* Jenkins Password=welcome
* Memory Limit=512Mi
* Jenkins ImageStream Namespace=openshift
* Jenkins ImageStreamTag=jenkins:latest

--> Creating resources ...
route.route.openshift.io "jenkins" created
deploymentconfig.apps.openshift.io "jenkins" created
serviceaccount "jenkins" created
rolebinding.authorization.openshift.io "jenkins_edit" created
service "jenkins-jnlp" created
service "jenkins" created
--> Success
Access your application via route 'jenkins-ci.192.168.99.109.nip.io'
Run 'oc status' to view your app.

部署失败了,💔

1
2
3
4
5
6
7
oc delete all -l app=jenkins-ephemeral
pod "jenkins-1-6k7s6" deleted
replicationcontroller "jenkins-1" deleted
service "jenkins" deleted
service "jenkins-jnlp" deleted
deploymentconfig.apps.openshift.io "jenkins" deleted
route.route.openshift.io "jenkins" deleted

不能删除 serviceaccounts

1
2
oc delete serviceaccounts -l app=jenkins-ephemeral
oc delete rolebindings.authorization.openshift.io jenkins_edit

删除干净后,可以用命令 oc get all -o wide 验证

再来一次

oc new-app --template=jenkins-ephemeral --param=JENKINS_PASSWORD=welcome123

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2019-2024 John Doe
  • Visitors: | Views:

请我喝杯咖啡吧~