博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
k8s分布式存储,使用rancher将jenkins workspace部署在nfs上
阅读量:6003 次
发布时间:2019-06-20

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

安装nfs服务器

systemctl stop rpcbind.socketsystemctl stop rpcbindsystemctl disable rpcbind.socket systemctl disable rpcbindmkdir -p ~/nfs/fileschmod -R 777 ~/nfs/filesecho "/files *(rw,sync,no_subtree_check,fsid=0,no_root_squash)" > ~/nfs/exports.txtdocker run --name nfs -d --rm\  -v ~/nfs/files:/files\  -v ~/nfs/exports.txt:/etc/exports:ro\  --cap-add SYS_ADMIN\  -p 2049:2049   -p 2049:2049/udp   \  -p 111:111     -p 111:111/udp     \  -p 32765:32765 -p 32765:32765/udp \  -p 32767:32767 -p 32767:32767/udp \  erichough/nfs-server复制代码

使用showmount命令查看效果

使用rancher把nfs挂载到k8s上

查看效果

部署jenkins

在rancher上创建一个新的部署

指定workspace路径为nfs

查看效果

核对rancher生成的配置文件

pv

{
"kind": "PersistentVolume", "apiVersion": "v1", "metadata": {
"name": "jenkins", "selfLink": "/api/v1/persistentvolumes/jenkins", "uid": "218fb160-5f63-11e9-9904-00505627dade", "resourceVersion": "26862", "creationTimestamp": "2019-04-15T09:44:58Z", "labels": {
"cattle.io/creator": "norman" }, "annotations": {
"field.cattle.io/creatorId": "user-c4qsr", "pv.kubernetes.io/bound-by-controller": "yes" }, "finalizers": [ "kubernetes.io/pv-protection" ] }, "spec": {
"capacity": {
"storage": "100Gi" }, "nfs": {
"server": "172.16.67.160", "path": "/files/jenkins" }, "accessModes": [ "ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany" ], "claimRef": {
"kind": "PersistentVolumeClaim", "namespace": "default", "name": "jenkins", "uid": "b202f7a7-5f63-11e9-9904-00505627dade", "apiVersion": "v1", "resourceVersion": "26859" }, "persistentVolumeReclaimPolicy": "Retain" }, "status": {
"phase": "Bound" }}复制代码

pvc

apiVersion: v1kind: PersistentVolumeClaimmetadata:  annotations:    field.cattle.io/creatorId: user-c4qsr    pv.kubernetes.io/bind-completed: "yes"  creationTimestamp: 2019-04-15T09:49:00Z  finalizers:  - kubernetes.io/pvc-protection  labels:    cattle.io/creator: norman  name: jenkins  namespace: default  resourceVersion: "26864"  selfLink: /api/v1/namespaces/default/persistentvolumeclaims/jenkins  uid: b202f7a7-5f63-11e9-9904-00505627dadespec:  accessModes:  - ReadWriteOnce  resources:    requests:      storage: 100Gi  storageClassName: ""  volumeName: jenkinsstatus:  accessModes:  - ReadWriteOnce  - ReadOnlyMany  - ReadWriteMany  capacity:    storage: 100Gi  phase: Bound复制代码

jenkins

apiVersion: apps/v1beta2kind: Deploymentmetadata:  annotations:    deployment.kubernetes.io/revision: "1"    field.cattle.io/creatorId: user-c4qsr    field.cattle.io/publicEndpoints: '[{"addresses":["172.16.67.150"],"port":33031,"protocol":"TCP","serviceName":"default:jenkins-nodeport","allNodes":true}]'  creationTimestamp: 2019-04-15T09:49:00Z  generation: 2  labels:    cattle.io/creator: norman    workload.user.cattle.io/workloadselector: deployment-default-jenkins  name: jenkins  namespace: default  resourceVersion: "27005"  selfLink: /apis/apps/v1beta2/namespaces/default/deployments/jenkins  uid: b20e4501-5f63-11e9-9904-00505627dadespec:  progressDeadlineSeconds: 600  replicas: 1  revisionHistoryLimit: 10  selector:    matchLabels:      workload.user.cattle.io/workloadselector: deployment-default-jenkins  strategy:    rollingUpdate:      maxSurge: 1      maxUnavailable: 0    type: RollingUpdate  template:    metadata:      annotations:        cattle.io/timestamp: 2019-04-15T09:48:59Z        field.cattle.io/ports: '[[{"containerPort":8080,"dnsName":"jenkins-nodeport","kind":"NodePort","name":"8080tcp01","protocol":"TCP","sourcePort":0}]]'      creationTimestamp: null      labels:        workload.user.cattle.io/workloadselector: deployment-default-jenkins    spec:      containers:      - image: jenkins/jenkins:lts-jdk11        imagePullPolicy: Always        name: jenkins        ports:        - containerPort: 8080          name: 8080tcp01          protocol: TCP        resources: {}        securityContext:          allowPrivilegeEscalation: false          capabilities: {}          privileged: false          readOnlyRootFilesystem: false          runAsNonRoot: false        stdin: true        terminationMessagePath: /dev/termination-log        terminationMessagePolicy: File        tty: true        volumeMounts:        - mountPath: /var/jenkins_home          name: jenkins      dnsPolicy: ClusterFirst      restartPolicy: Always      schedulerName: default-scheduler      securityContext: {}      terminationGracePeriodSeconds: 30      volumes:      - name: jenkins        persistentVolumeClaim:          claimName: jenkinsstatus:  availableReplicas: 1  conditions:  - lastTransitionTime: 2019-04-15T09:50:21Z    lastUpdateTime: 2019-04-15T09:50:21Z    message: Deployment has minimum availability.    reason: MinimumReplicasAvailable    status: "True"    type: Available  - lastTransitionTime: 2019-04-15T09:49:00Z    lastUpdateTime: 2019-04-15T09:50:21Z    message: ReplicaSet "jenkins-5d7cd689bf" has successfully progressed.    reason: NewReplicaSetAvailable    status: "True"    type: Progressing  observedGeneration: 2  readyReplicas: 1  replicas: 1  updatedReplicas: 1复制代码

转载于:https://juejin.im/post/5cb46f44e51d456e303db86b

你可能感兴趣的文章
条件变量的陷阱与思考
查看>>
循序渐进的敏捷-每日例会
查看>>
图片标注工具LabelImg使用教程
查看>>
VMware12.0下安装CentOS-6.9-x86_64-bin-DVD.iso
查看>>
Solr Facet 搜索时,facet.missing = true 的真正含义
查看>>
对于Ian的访谈,不少关于GAN的内容
查看>>
011 递归
查看>>
南京建邺、秦淮等7个区公布校外培训机构白名单
查看>>
python 全局变量与局部变量
查看>>
011 pandas的常见操作
查看>>
WPF在3D Cad模型中利用TextureCoordinates实现颜色渐变显示偏差值的变化
查看>>
Linux 安装 Docker
查看>>
Python3下基于bs4和sqlalchemy的爬虫实现
查看>>
centos7 在docker swarm中运行Jenkins,利用gitlab的webhook触发自动部署脚本
查看>>
Idea下Python开发平台的搭建
查看>>
token令牌和jwt
查看>>
I2S接口介绍
查看>>
【转】Web前端性能优化——如何提高页面加载速度
查看>>
(原創) 如何設計一個數位相框? (SOC) (Quartus II) (SOPC Builder) (Nios II) (TRDB-LTM) (DE2-70)...
查看>>
/etc/profile文件内容
查看>>