k8s部署gitlab
k8s部署gitlab
·
Gitlab以容器方式运行,需要持久化如下几个目录中的数据:
持久化本地位置 | 容器位置 | 使用 |
${sc}/data | /var/opt/gitlab | 用于存储应用程序数据。 |
${sc}/logs | /var/log/gitlab | 用于存储日志。 |
${sc}/config | /etc/gitlab | 用于存储 GitLab 配置 文件。 |
1、下载镜像
docker pull gitlab/gitlabce:14.6.0-ce.0
2、创建Service
这个用于对接jenkins使用,因为我没有正式的公网域名,如果有就不用配置了
kind: Service
apiVersion: v1
metadata:
name: gitlab-svc
namespace: ops
labels:
app: gitlab
spec:
ports:
- name: http
port: 80
targetPort: 80
nodePort: 30999
- name: https
port: 443
targetPort: 443
nodePort: 30443
selector:
app: gitlab
type: NodePort
3、创建存储,采用storageclass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: gitlab-storageclass
provisioner: nfs-storage-01
allowVolumeExpansion: true
reclaimPolicy: Retain
4、创建StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: gitlab
namespace: ops
spec:
serviceName: "gitlab-svc"
selector:
matchLabels:
app: gitlab
template:
metadata:
labels:
app: gitlab
spec:
imagePullSecrets:
- name: harbor-admin
containers:
- name: gitlab-ce
image: gitlab/gitlab-ce:14.6.0-ce.0
imagePullPolicy: IfNotPresent
env:
- name: GITLAB_ROOT_PASSWORD
value: "admin123"
- name: GITLAB_OMNIBUS_CONFIG
value: |
external_url "http://gitlab.ws.net"
gitlab_rails['time_zone'] = 'Asia/Shanghai'
node_exporter['enable'] = false
redis_exporter['enable'] = false
postgres_exporter['enable'] = false
gitlab_exporter['enable'] = false
grafana['enable'] = false
grafana['reporting_enabled'] = false
prometheus['enable'] = false
prometheus['monitor_kubernetes'] = false
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
volumeMounts:
- name: data
mountPath: /etc/gitlab
subPath: config
- name: data
mountPath: /var/opt/gitlab
subPath: data
- name: data
mountPath: /var/log/gitlab
subPath: logs
volumeClaimTemplates: # pvc
- metadata:
name: data
spec:
accessModes: ["ReadWriteMany"]
storageClassName: "gitlab-storageclass"
resources:
requests:
storage: 5Gi
5、创建Ingress
在本地绑定ip 和域名之后就能直接访问了,这个用于日常登录使用
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitlab-ingress
namespace: ops
spec:
ingressClassName: "nginx"
rules:
- host: "gitlab.ws.net"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gitlab-svc
port:
name: http
6、访问Gitlab
账号密码
root/admin123
更多推荐
已为社区贡献6条内容
所有评论(0)