标签:存储 https har http 开发者 cat 其他 request mem
前言应对敏捷开发的需求,对CI(持续集成))/CD(持续交付)的提出了更高的标准,今天来讨论下,如何基于开源组件(gitlab/jenkins/harbor/kubernetes)使用CI/CD,赋能团队的开发、运维。
组件名称 | 版本 | 备注 |
---|---|---|
kubernetes | v1.15.3 | 10.0.0.182:6443 |
jenkins | 2.176.2 | 集群内部署/ namespace: devops |
gitlab | 11.8 | 主机部署 |
harbor | v1.7.4 | docker-compose部署 |
注:
注: 本文主要说明下jenkins的部署及配置,其他组件如果你部署有问题,欢迎留言。
说明:
nodeName ipaddress
, ipaddress 请确认其为一个有效的ip./var/jenkins_home
是直接挂载到host_path, 如果你有条件,建议替换为共享存储。jenkins/jenkins:lts-alpine
推送至自己的内网镜像仓库。jenkins.dev.hanker.net
, 改为有效的域名地址,或是你也可以通过NodePort
的形式声明 service,就可以直接通过ip:port
的形式访问jenkins了。apiVersion: v1
kind: Namespace
metadata:
name: devops
# Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: jenkins
namespace: devops
spec:
replicas: 1
revisionHistoryLimit: 3
template:
metadata:
labels:
app: jenkins
spec:
nodeName: 1.1.1.1
serviceAccountName: jenkins-admin
containers:
- image: jenkins/jenkins:lts-alpine
imagePullPolicy: IfNotPresent
name: jenkins
volumeMounts:
- name: jenkins-volume
mountPath: /var/jenkins_home
- name: jenkins-localtime
mountPath: /etc/localtime
env:
- name: JAVA_OPTS
value: ‘-Xms256m -Xmx1024m -Duser.timezone=Asia/Shanghai‘
- name: TRY_UPGRADE_IF_NO_MARKER
value: ‘true‘
ports:
- name: http
containerPort: 8080
- name: agent
containerPort: 50000
resources:
requests:
cpu: 1000m
memory: 1Gi
limits:
cpu: 1200m
memory: 2Gi
volumes:
- name: jenkins-localtime
hostPath:
path: /etc/localtime
- name: jenkins-volume
hostPath:
path: /home/jenkins/jenkins_home
---
apiVersion: v1
kind: Service
metadata:
name: jenkins-service
namespace: devops
spec:
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
- port: 50000
targetPort: 50000
name: agent
selector:
app: jenkins
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: jenkins
name: jenkins-admin
namespace: devops
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: jenkins-rbac
namespace: devops
rules:
- apiGroups: ["","extensions","app"]
resources: ["pods","pods/exec","deployments","replicasets"]
verbs: ["get","list","watch","create","update","patch","delete"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: jenkins-admin
namespace: devops
labels:
k8s-app: jenkins
subjects:
- kind: ServiceAccount
name: jenkins-admin
namespace: devops
roleRef:
kind: ClusterRole
name: jenkins-rbac
apiGroup: rbac.authorization.k8s.io
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: jenkins-ingress
namespace: devops
spec:
rules:
- host: jenkins.dev.hanker.net
http:
paths:
- backend:
serviceName: jenkins-service
servicePort: 8080
path: /
$ pwd
$ /home/jenkins_deploy
$ kubectl apply -f *.yaml
[root@node0 jenkins_deploy]# kubectl -n devops get deployment jenkins
NAME READY UP-TO-DATE AVAILABLE AGE
jenkins 1/1 1 1 51d
[root@node0 jenkins_deploy]#
注: 步骤1 声明的域名 jenkins.dev.hanker.net
已经解析至ingress,故可直接访问; 如果你也想通过自定义域名访问jenkins,麻请解析至正确的ingress服务节点,即可。
操作指引: 【Manage Jenkins】 -> 【Manage Plugins】
你应该可以通过类似的指令获取jenkins-master的密码
$ kubectl -n devops exec jenkins-pod-name cat /var/jenkins_home/secrets/initialAdminPassword
操作指引: 【Manage Jenkins】->【Configure System】
图中标注:
图中标注:
标签:存储 https har http 开发者 cat 其他 request mem
原文地址:https://blog.51cto.com/14459446/2445002