一、使用服务介绍


存储: 阿里云NAS

k8s网络插件: calico

 k8s版本: 1.15.2

二、helm安装

https://www.cnblogs.com/zhangb8042/p/10205551.html

 

三、安装gitlab(名字命名为mygitlab)

1、下载gitlab的helm的配置清单

helm  fetch stable/gitlab-ce
tar xf gitlab-ce-0.2.2.tgz 
cd gitlab-ce

 

2、修改values.yaml配置清单中的存储内容(不修改存储、提前创建好pv也行,node节点记得下载nfs-utils)

查看与修改values.yaml配置清单中的pvc内容,创建相应的NAS的pv,并修改资源清单中的pvc配置,改成挂载nas创建的pv,(redis和postgresql中的配置清单也要改)

修改例子:

 

persistence:
  gitlabEtc:
    enabled: true
    #size: 1Gi
    # storageClass:
    accessMode: ReadWriteMany
    resources:
      requests:
        storage: 1Gi
#例子2、postgresql
persistence:
  enabled: true
  # storageClass:
  accessMode: ReadWriteOnce
  resources:
      requests:
        storage: 10Gi
  #size: 8Gi
  subPath: "postgresql-db"

 

 

3、创建对应的pv

创建PV的模板

 

apiVersion: v1
kind: PersistentVolume
metadata:
   name: nas
spec:
   capacity:
     storage: 8Gi
   accessModes:
     - ReadWriteMany
   persistentVolumeReclaimPolicy: Retain
   nfs:
     path: /
     server: 055f84ad83-ixxxx.cn-hangzhou.nas.aliyuncs.com 

 

 

4、helm指定资源清单安装

helm  install stable/gitlab-ce --name mygitlab -f values.yaml   -f charts/postgresql/values.yaml   -f charts/redis/values.yaml 

 

5、查看PV、PVC

[root@k8s-m gitlab-ce]# kubectl get pv
NAME                      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                             STORAGECLASS   REASON   AGE
mygitlab-gitlab-ce-data   10Gi       RWX            Retain           Bound    default/mygitlab-gitlab-ce-data                           32s
mygitlab-gitlab-ce-etc    1Gi        RWX            Retain           Bound    default/mygitlab-gitlab-ce-etc                            32s
mygitlab-postgresql       10Gi       RWO            Retain           Bound    default/mygitlab-postgresql                               32s
mygitlab-redis            10Gi       RWO            Retain           Bound    default/mygitlab-redis                                    32s
[root@k8s-m gitlab-ce]# kubectl get pvc 
NAME                      STATUS   VOLUME                    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
mygitlab-gitlab-ce-data   Bound    mygitlab-gitlab-ce-data   10Gi       RWX                           15s
mygitlab-gitlab-ce-etc    Bound    mygitlab-gitlab-ce-etc    1Gi        RWX                           15s
mygitlab-postgresql       Bound    mygitlab-postgresql       10Gi       RWO                           15s
mygitlab-redis            Bound    mygitlab-redis            10Gi       RWO                           15s

 

6、设访问地址

helm upgrade mygitlab --set externalUrl=http://your-domain.com stable/gitlab-ce

 

7、将gitlab的svc改成nodeport(毕竟没有使用SLB服务)

kubectl  patch svc  mygitlab-gitlab-ce  -p  '{"spec":{"type":"NodePort"}}'

 

8、配置gitlab的ingress

vim my-nginx-deploy
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      name: nginx
  template:
    metadata:
      labels:
        name: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:alpine 
        ports:
        - name: http
          containerPort: 80 
#ingress文件
[root@k8s-m ~]# cat git-ingress.yaml 
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-nginx
spec:
  rules:
  - host: git.test.com
    http:
      paths:
      - backend:
          serviceName: mygitlab-gitlab-ce
          servicePort: 80

9、导入与测试

[root@k8s-m ~]# kubectl get ingress
NAME            HOSTS          ADDRESS   PORTS   AGE
ingress-nginx   git.test.com             80      3m18s

 

 

四、helm安装jenkins

1、下载资源清单文件

helm  fetch stable/jenkins

2、修改资源清单(主要还是查看与修改存储)

tar xf jenkins-1.5.1.tgz 
cd jenkins/
vim values.yaml
persistence:
  enabled: true
  storageClass:
  annotations: {}
  accessMode: "ReadWriteOnce"
  resources:
      requests:
        storage: 10Gi

 

3、创建jenkins使用的PV

[root@k8s-m jenkins]# cat jenkins-pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
   name: myjenkins
spec:
   capacity:
     storage: 10Gi
   accessModes:
     - ReadWriteOnce
   persistentVolumeReclaimPolicy: Retain
   nfs:
     path: /
     server: 055f84ad83-ixxxx.cn-hangzhou.nas.aliyuncs.com 

4、创建jenkins服务

helm  install stable/jenkins  --name myjenkins  -f values.yaml 

 

5、查看

[root@k8s-m jenkins]# kubectl get pvc  myjenkins    
NAME        STATUS   VOLUME      CAPACITY   ACCESS MODES   STORAGECLASS   AGE
myjenkins   Bound    myjenkins   10Gi       RWO                           21s
[root@k8s-m jenkins]# kubectl get deploy  myjenkins    
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
myjenkins   1/1     1            1           2m8s
##查看myjenkins的svc(使用外网ip的31638端口能直接访问)
[root@k8s-m jenkins]# kubectl get  svc  myjenkins   
NAME        TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
myjenkins   LoadBalancer   10.97.245.156   <pending>     8080:31638/TCP   6m42s

6、查看jenkins的密码等

helm  status myjenkins

 

 

 

五、配置gitlab与jenkins的连接(连接的url使用名称空间,不要用ip)

 1、配置地址

https://www.cnblogs.com/zhangb8042/p/9278819.html

2、差异截图

 

 

 

3、最后结果

 

转载于:https://www.cnblogs.com/zhangb8042/p/11357584.html

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐