前言
本片文章都是使用這個yaml做建立及佈署。
正文
Step 1.
先參考上篇 [[GKE pvc還原]],建立好PVC。
主要複製Gitlab的位置為
- name: config
mountPath: /etc/gitlab
- name: gitlab-data
mountPath: /var/opt/gitlab/git-data
- name: postgres-data
mountPath: /var/opt/gitlab/postgresql
由於我之前建立的image為 last版本(應該是快一年前的事),
這次我用last版本的話,版本超前太多,導致一直重開機。
後來查我的gitlab版本為 14.0.1,
但裝上去後一直碰到這個錯誤
relation “services” does not exist after upgrade to 14.2.0
解決方式:
後來將版本升級到 14.1.1 後就好了。
ref.
Step 2.
用本來的帳號密碼能登入,沒問題。
增加新的git remote 位置,
然後試著推一個版本上去時,又出現錯誤了。這次比較好理解。
remote: HTTP Basic: Access denied
解決方式:
跑去另一個空目錄,git clone ,會要輸入帳號密碼,輸入後就好了。
Step 3.
如果看過之前的文章,可能知道我有在用istio,
會碰到要用一個ip暴露不同的服務。
解決方式:
external_url “http://{ip}/gitlab”
virtualservice直接改
spec:
hosts: []
http:
- match:
- uri:
prefix: /gitlab
name: gitlab
route:
- destination:
host: gitlab-svc.default.svc.cluster.local
port:
number: 80
ref.
Gitlab yaml
現在也有gitlab operator跟 helm 可以做,有興趣的可以參考一下官方文件。
apiVersion: v1
kind: Service
metadata:
name: gitlab-svc
spec:
ports:
- name: "web"
port: 80
targetPort: 80
- name: "ssh"
port: 22
targetPort: 22
- name: "ssl"
port: 443
targetPort: 443
selector:
io.kompose.service: web
drone: gitlab
type: LoadBalancer
loadBalancerIP: 123.123.123.123
loadBalancerSourceRanges:
- 192.168.0.0/16
- 172.16.0.0/12
- 10.0.0.0/8
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitlab
labels:
io.kompose.service: web
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: web
template:
metadata:
labels:
io.kompose.service: web
spec:
containers:
- env:
- name: GITLAB_TIMEZONE
value: Taipei
- name: GITLAB_OMNIBUS_CONFIG
value: |
external_url "http://123.123.123.123/gitlab"
gitlab_rails['gitlab_default_projects_features_builds'] = false
image: gitlab/gitlab-ce:14.1.1-ce.0
name: web
ports:
- containerPort: 80
resources: {}
volumeMounts:
- name: config
mountPath: /etc/gitlab
- name: gitlab-data
mountPath: /var/opt/gitlab/git-data
- name: postgres-data
mountPath: /var/opt/gitlab/postgresql
restartPolicy: Always
serviceAccountName: ""
volumes:
- name: config
persistentVolumeClaim:
claimName: gke-drone-web-claim0
- name: gitlab-data
persistentVolumeClaim:
claimName: gke-drone-repository-data
- name: postgres-data
persistentVolumeClaim:
claimName: gke-drone-gitlab-postgresql
PVC的建立,請參考[[blog.70. GKE pvc還原]],如要建立空的,
參考下方yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: web-claim0
name: gke-drone-web-claim0
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
status: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
gitlab-data: gitlab
name: gke-drone-repository-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
gitlab-data: postgresql
name: gke-drone-gitlab-postgresql
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
0 意見:
張貼留言