install gitlab-ce k8s version : v1.16.2
- create storageClass use nas
rbac.yaml:
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-client-provisioner
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-client-provisioner-runner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: run-nfs-client-provisioner
subjects:
- kind: ServiceAccount
name: nfs-client-provisioner
namespace: default
roleRef:
kind: ClusterRole
name: nfs-client-provisioner-runner
apiGroup: rbac.authorization.k8s.io
deploy-mgr-gitlab.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
name: nfs-gitlab
namespace: default
labels:
app: nfs-gitlab
spec:
replicas: 1
selector:
matchLabels:
app: nfs-gitlab
release: base
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-gitlab
release: base
spec:
serviceAccount: nfs-client-provisioner
containers:
- name: nfs-gitlab
image: nfs/nfs-client-provisioner:v1.1
imagePullPolicy: IfNotPresent
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
resources:
limits:
cpu: 2
memory: 4096Mi
requests:
cpu: 500m
memory: 512Mi
env:
- name: PROVISIONER_NAME
value: fuseim.pri/ifs-gitlab
- name: NFS_SERVER
value: xx.xx.xx.xx
- name: NFS_PATH
value: /vol/nas_gitlab
volumes:
- name: nfs-client-root
nfs:
server: xx.xx.xx.xx
path: /vol/nas_gitlab
nfs-mgr-gitlab.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: nfs-gitlab
provisioner: fuseim.pri/ifs-gitlab
reclaimPolicy: Retain
apply to k8s cluster with namespace default
kubectl apply -f rbac.yaml
kubectl apply -f deploy-mgr-gitlab.yaml
kubectl apply -f nfs-mgr-gitlab.yaml
PS: please notice storageclass name must same with env of PROVISIONER_NAME's value
- get the charts of gitlab-ce:
helm fetch stable/gitlab-ce
tar -zxvf gitlab-ce-0.2.1.tgz
- modify the template ,and selector info ,and apiVersion. another modify too.
{{- if default "" .Values.externalUrl }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "gitlab-ce.fullname" . }}
labels:
app: {{ template "gitlab-ce.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "gitlab-ce.fullname" . }}
4.create new values.yaml
image: gitlab/gitlab-ce:9.4.1-ce.0
imagePullPolicy: IfNotPresent
externalUrl: http://code.XXXX.com.cn/
gitlabRootPassword: "XXXX"
serviceType: LoadBalancer
##
ingress:
annotations:
kubernetes.io/ingress.class: mgr
kubernetes.io/tls-acme: "true"
enabled: true
url: code.XXXX.com.cn
resources:
requests:
memory: 4Gi
cpu: 2
limits:
memory: 4Gi
cpu: 4
persistence:
gitlabEtc:
enabled: true
size: 5Gi
storageClass: "nfs-gitlab"
accessMode: ReadWriteOnce
gitlabData:
enabled: true
size: 300Gi
storageClass: "nfs-gitlab"
accessMode: ReadWriteOnce
postgresql:
# 9.6 is the newest supported version for the GitLab container
image: "postgres"
imageTag: "9.6"
cpu: 2
memory: 4Gi
postgresUser: gitlab
postgresPassword: gitlab
postgresDatabase: gitlab
persistence:
storageClass: "nfs-gitlab"
size: 50Gi
redis:
image: "bitnami/redis:3.2.9-r2"
redisPassword: "gitlab"
resources:
requests:
memory: 3Gi
persistence:
storageClass: "nfs-gitlab"
size: 50Gi
- create gitlab namespace
kubectl create namespace gitlab
helm install --name gitlab --namespace gitlab stable/nginx-ingress -f values.yaml
- get the pods info:
[root@k8s-mgr-01 gitlab-ce]# kubectl get pods
NAME READY STATUS RESTARTS AGE
gitlab-gitlab-ce-d5dd48f4c-k4qv8 1/1 Running 0 65m
gitlab-postgresql-7d67dd4f86-lrz9p 1/1 Running 0 23h
gitlab-redis-64bd9f877b-84q96 1/1 Running 0 23h
- sign in web with root and password