当前位置:   article > 正文

云原生Kubernetes: K8S 1.29版本 部署GitLab

云原生Kubernetes: K8S 1.29版本 部署GitLab

目录

一、实验

1.环境

2.搭建NFS

3.K8S 1.29版本 部署Redis

4.K8S 1.29版本 部署Postgresql

5.K8S 1.29版本 部署GitLab

6.K8S 部署istio微服务

7.K8S 部署ingress应用路由

二、问题

1.K8S部署gitlab报错

2.gitlab创建失败

3.生成网关资源报错

4.安装istio 报错

5.istio-ingressgateway 一直处于pending状态

6.istio如何实现自动注入 sidecar

7.K8S容器从公钥接收失败​​​​​​​


一、实验

1.环境

(1)主机

表1 主机

主机架构版本IP备注
masterK8S master节点1.29.0192.168.204.8

node1K8S node节点1.29.0192.168.204.9
node2K8S node节点1.29.0192.168.204.10已部署Kuboard

(2)master节点查看集群

  1. 1)查看node
  2. kubectl get node
  3. 2)查看node详细信息
  4. kubectl get node -o wide

(3)查看pod

[root@master ~]# kubectl get pod -A

(4) 访问Kuboard

http://192.168.204.10:30080/kuboard/cluster

查看节点

2.搭建NFS

(1)检查并安装rpcbind和nfs-utils软件包

[root@master ~]# rpm -q rpcbind nfs-utils

(2)创建目录并授权

[root@master ~]# mkdir -p /opt/k8s

[root@master ~]# chmod 777 k8s/

(3)打开nfs的配置文件

[root@master opt]# vim /etc/exports

(4)配置文件

给所有网段用户赋予读写权限、同步内容、不压缩共享对象root用户权限

/opt/k8s *(rw,sync,no_root_squash)

(5)先后开启rpcbind、nfs服务并热加载配置文件内容,查看本机发布的nfs共享目录

  1. [root@master opt]# systemctl start rpcbind
  2. [root@master opt]# systemctl start nfs

(6)监听端口

[root@master opt]# ss -antp | grep rpcbind

(7)查看共享

[root@master opt]# showmount -e

其他节点查看

[root@node1 ~]# showmount -e master

3.K8S 1.29版本 部署Redis

(1)查阅

第三方镜像仓库

https://hub.docker.com/u/sameersbn

镜像(Gitlab主要涉及到3个应用:Redis、Postgresql、Gitlab 核心程序,实际上只要将这3个应用分别启动起来,然后加上对应的配置就可以方便快速的安装 Gitlab )

  1. 1)redis
  2. sameersbn/redis
  3. 2)postgresql
  4. sameersbn/postgresql
  5. 3)gitlab
  6. sameersbn/gitlab

(2)创建redis的pv

[root@master ~]# vim pv-redis.yaml

  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4. name: pv-redis
  5. spec:
  6. capacity:
  7. storage: 2Gi
  8. volumeMode: Filesystem
  9. accessModes:
  10. - ReadWriteMany
  11. persistentVolumeReclaimPolicy: Retain
  12. storageClassName: "pv-redis"
  13. nfs:
  14. path: /opt/k8s
  15. server: 192.168.204.8

(3)生成资源

[root@master ~]# kubectl apply -f pv-redis.yaml 

(4)查看pv

[root@master ~]# kubectl get pv

(5)拉取镜像

 node1

[root@node1 ~]# docker pull sameersbn/redis:latest

(6) 导出镜像

[root@node1 ~]# docker save -o redis.tar sameersbn/redis:latest

(7)复制Docker镜像到node2节点

[root@node1 ~]# scp redis.tar  root@node2:~

(8)node2节点导入Docker镜像

[root@node2 ~]# docker load -i redis.tar 

(9)创建名称空间

[root@master ~]# kubectl create ns devops

(10)部署redis

[root@master ~]# vim redis.yaml
  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. name: redis-pvc
  5. namespace: devops
  6. spec:
  7. accessModes:
  8. - ReadWriteMany
  9. storageClassName: "pv-redis"
  10. resources:
  11. requests:
  12. storage: 2Gi
  13. ---
  14. apiVersion: apps/v1
  15. kind: Deployment
  16. metadata:
  17. name: redis
  18. namespace: devops
  19. labels:
  20. name: redis
  21. spec:
  22. replicas: 1
  23. selector:
  24. matchLabels:
  25. name: redis
  26. template:
  27. metadata:
  28. name: redis
  29. labels:
  30. name: redis
  31. spec:
  32. containers:
  33. - name: redis
  34. image: sameersbn/redis:latest
  35. imagePullPolicy: IfNotPresent
  36. ports:
  37. - name: redis
  38. containerPort: 6379
  39. volumeMounts:
  40. - mountPath: /var/lib/redis
  41. name: data
  42. subPath: redis
  43. livenessProbe:
  44. exec:
  45. command:
  46. - redis-cli
  47. - ping
  48. initialDelaySeconds: 30
  49. timeoutSeconds: 5
  50. readinessProbe:
  51. exec:
  52. command:
  53. - redis-cli
  54. - ping
  55. initialDelaySeconds: 5
  56. timeoutSeconds: 1
  57. volumes:
  58. - name: data
  59. persistentVolumeClaim:
  60. claimName: redis-pvc
  61. ---
  62. apiVersion: v1
  63. kind: Service
  64. metadata:
  65. name: redis
  66. namespace: devops
  67. labels:
  68. name: redis
  69. spec:
  70. ports:
  71. - name: redis
  72. port: 6379
  73. targetPort: redis
  74. selector:
  75. name: redis

(11)生成资源

[root@master ~]# kubectl apply -f redis.yaml 

(12)查看pv,pvc

[root@master ~]# kubectl get pv

[root@master ~]# kubectl get pvc -n devops

4.K8S 1.29版本 部署Postgresql

(1)创建postgresql的pv

[root@master ~]# vim pv-postgresql.yaml

 

  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4. name: pv-postgresql
  5. spec:
  6. capacity:
  7. storage: 2Gi
  8. volumeMode: Filesystem
  9. accessModes:
  10. - ReadWriteMany
  11. persistentVolumeReclaimPolicy: Retain
  12. storageClassName: "pv-postgresql"
  13. nfs:
  14. path: /opt/k8s
  15. server: 192.168.204.8

(2)生成资源

[root@master ~]# kubectl apply -f pv-postgresql.yaml

(3)拉取镜像

node1

[root@node1 ~]# docker pull sameersbn/postgresql:12-20200524

 (4) 导出镜像

[root@node1 ~]# docker save -o postgresql.tar sameersbn/postgresql:12-20200524

(7)复制Docker镜像到node2节点

[root@node1 ~]# scp postgresql.tar  root@node2:~

(8)node2节点导入Docker镜像

[root@node2 ~]# docker load -i postgresql.tar 

(9)部署postgresql

[root@master ~]# vim postgresql.yaml

  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. name: postgresql-pvc
  5. namespace: devops
  6. spec:
  7. accessModes:
  8. - ReadWriteMany
  9. storageClassName: "pv-postgresql"
  10. resources:
  11. requests:
  12. storage: 2Gi
  13. ---
  14. apiVersion: apps/v1
  15. kind: Deployment
  16. metadata:
  17. name: postgresql
  18. namespace: devops
  19. labels:
  20. name: postgresql
  21. spec:
  22. replicas: 1
  23. selector:
  24. matchLabels:
  25. name: postgresql
  26. template:
  27. metadata:
  28. name: postgresql
  29. labels:
  30. name: postgresql
  31. spec:
  32. containers:
  33. - name: postgresql
  34. image: sameersbn/postgresql:12-20200524
  35. imagePullPolicy: IfNotPresent
  36. env:
  37. - name: DB_USER
  38. value: gitlab
  39. - name: DB_PASS
  40. value: passw0rd
  41. - name: DB_NAME
  42. value: gitlab_production
  43. - name: DB_EXTENSION
  44. value: pg_trgm,btree_gist
  45. ports:
  46. - name: postgres
  47. containerPort: 5432
  48. volumeMounts:
  49. - mountPath: /var/lib/postgresql
  50. name: data
  51. subPath: postgresql
  52. livenessProbe:
  53. exec:
  54. command:
  55. - pg_isready
  56. - -h
  57. - localhost
  58. - -U
  59. - postgres
  60. initialDelaySeconds: 5
  61. timeoutSeconds: 1
  62. readinessProbe:
  63. exec:
  64. command:
  65. - pg_isready
  66. - -h
  67. - localhost
  68. - -U
  69. - postgres
  70. initialDelaySeconds: 5
  71. timeoutSeconds: 1
  72. startupProbe:
  73. exec:
  74. command:
  75. - pg_isready
  76. - -h
  77. - localhost
  78. - -U
  79. - postgres
  80. initialDelaySeconds: 90
  81. periodSeconds: 5
  82. failureThreshold: 100
  83. timeoutSeconds: 1
  84. volumes:
  85. - name: data
  86. persistentVolumeClaim:
  87. claimName: postgresql-pvc
  88. ---
  89. apiVersion: v1
  90. kind: Service
  91. metadata:
  92. name: postgresql
  93. namespace: devops
  94. labels:
  95. name: postgresql
  96. spec:
  97. ports:
  98. - name: postgres
  99. port: 5432
  100. targetPort: 5432
  101. selector:
  102. name: postgresql

(10) 生成资源

[root@master ~]# kubectl apply -f postgresql.yaml 

(11)查看pv,pvc

[root@master ~]# kubectl get pv -n devops

[root@master ~]# kubectl get pvc -n devops

5.K8S 1.29版本 部署GitLab

(1)创建gitlab的pv

[root@master ~]# vim pv-gitlab.yaml 

  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4. name: pv-gitlab
  5. spec:
  6. capacity:
  7. storage: 2Gi
  8. volumeMode: Filesystem
  9. accessModes:
  10. - ReadWriteMany
  11. persistentVolumeReclaimPolicy: Retain
  12. storageClassName: "pv-gitlab"
  13. nfs:
  14. path: /opt/k8s
  15. server: 192.168.204.8

(2)生成资源

[root@master ~]# kubectl apply -f pv-gitlab.yaml 

 (3)拉取镜像

node2

[root@node1 ~]# docker pull sameersbn/gitlab:15.6.0

 (4) 导出镜像

[root@node2 ~]# docker save -o gitlab.tar sameersbn/gitlab:15.6.0

(7)复制Docker镜像到node1节点

[root@node2 ~]# scp gitlab.tar  root@node1:~

(8)node1节点导入Docker镜像

[root@node1 ~]# docker load -i gitlab.tar 

(9) 部署gitlab

[root@master ~]# vim gitlab.yaml

  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. name: gitlab-pvc
  5. namespace: devops
  6. spec:
  7. accessModes:
  8. - ReadWriteMany
  9. storageClassName: "pv-gitlab"
  10. resources:
  11. requests:
  12. storage: 2Gi
  13. ---
  14. apiVersion: v1
  15. kind: ServiceAccount
  16. metadata:
  17. namespace: devops
  18. name: gitlab-sa
  19. labels:
  20. account: gitlab
  21. ---
  22. apiVersion: apps/v1
  23. kind: Deployment
  24. metadata:
  25. name: gitlab
  26. namespace: devops
  27. labels:
  28. app: gitlab
  29. version: v1
  30. spec:
  31. replicas: 1
  32. selector:
  33. matchLabels:
  34. app: gitlab
  35. version: v1
  36. template:
  37. metadata:
  38. labels:
  39. app: gitlab
  40. version: v1
  41. spec:
  42. serviceAccountName: gitlab-sa
  43. containers:
  44. - name: gitlab
  45. image: sameersbn/gitlab:15.6.0
  46. imagePullPolicy: IfNotPresent
  47. env:
  48. - name: TZ
  49. value: Asia/Shanghai
  50. - name: GITLAB_TIMEZONE
  51. value: Beijing
  52. - name: GITLAB_SECRETS_DB_KEY_BASE
  53. value: long-and-random-alpha-numeric-string
  54. - name: GITLAB_SECRETS_SECRET_KEY_BASE
  55. value: long-and-random-alpha-numeric-string
  56. - name: GITLAB_SECRETS_OTP_KEY_BASE
  57. value: long-and-random-alpha-numeric-string
  58. - name: GITLAB_ROOT_PASSWORD
  59. value: admin123
  60. - name: GITLAB_ROOT_EMAIL
  61. value: 7jjw@163.com
  62. - name: GITLAB_HOST
  63. value: gitlab.site
  64. - name: GITLAB_PORT
  65. value: "80"
  66. - name: GITLAB_SSH_PORT
  67. value: "31022"
  68. - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS
  69. value: "true"
  70. - name: GITLAB_NOTIFY_PUSHER
  71. value: "false"
  72. - name: GITLAB_BACKUP_SCHEDULE
  73. value: daily
  74. - name: GITLAB_BACKUP_TIME
  75. value: 01:00
  76. - name: DB_TYPE
  77. value: postgres
  78. - name: DB_HOST
  79. value: postgresql
  80. - name: DB_PORT
  81. value: "5432"
  82. - name: DB_USER
  83. value: gitlab
  84. - name: DB_PASS
  85. value: passw0rd
  86. - name: DB_NAME
  87. value: gitlab_production
  88. - name: REDIS_HOST
  89. value: redis
  90. - name: REDIS_PORT
  91. value: "6379"
  92. ports:
  93. - name: http
  94. containerPort: 80
  95. - name: ssh
  96. containerPort: 22
  97. volumeMounts:
  98. - mountPath: /home/git/data
  99. name: data
  100. subPath: gitlab
  101. livenessProbe:
  102. httpGet:
  103. path: /
  104. port: 80
  105. initialDelaySeconds: 180
  106. timeoutSeconds: 5
  107. readinessProbe:
  108. httpGet:
  109. path: /
  110. port: 80
  111. initialDelaySeconds: 5
  112. timeoutSeconds: 1
  113. startupProbe:
  114. httpGet:
  115. path: /
  116. port: 80
  117. initialDelaySeconds: 90
  118. periodSeconds: 5
  119. failureThreshold: 100
  120. timeoutSeconds: 1
  121. volumes:
  122. - name: data
  123. persistentVolumeClaim:
  124. claimName: gitlab-pvc
  125. ---
  126. apiVersion: v1
  127. kind: Service
  128. metadata:
  129. name: gitlab
  130. namespace: devops
  131. labels:
  132. app: gitlab
  133. service: gitlab
  134. spec:
  135. type: ClusterIP
  136. ports:
  137. - name: http
  138. port: 80
  139. targetPort: http
  140. - name: ssh
  141. port: 22
  142. targetPort: ssh
  143. selector:
  144. app: gitlab

(10) 生成资源

[root@master ~]# kubectl apply -f gitlab.yaml 

(11)查看pv,pvc

[root@master ~]# kubectl get pv -n devops

[root@master ~]# kubectl get pvc -n devops

(12) 查看pod,svc

[root@master ~]# kubectl get pod,svc -n devops

(13)Kuboard查看

工作负载

容器组

服务

存储

6.K8S 部署istio微服务

(1)查阅

https://github.com/istio/istio/releases

(2)选择版本

https://github.com/istio/istio/releases/tag/1.18.2

(3)master节点解压

[root@master ~]# tar zxvf istio-1.18.2-linux-amd64.tar.gz

(4)切换到istio包所在目录

  1. [root@master ~]# cd istio-1.18.2/
  2. [root@master istio-1.18.2]# ls

samples/目录下,有示例应用程序;

 bin/目录下,有istioctl客户端文件。istioctl工具用于手动注入Envoy sidecar代理。

(5)把istioctl这个可执行文件拷贝到/bin目录

[root@master istio-1.18.2]# cp /root/istio-1.18.2/bin/istioctl /bin/

(6)node节点导入镜像

node1

[root@node1 ~]# docker load -i istio1.18.tar.gz 

node2

[root@node2 ~]# docker load -i istio1.18.tar.gz

(7)  安装istio

  1. [root@master istio-1.18.2]# istioctl install --set profile=demo -y
  2. ? Istio core installed
  3. ? Istiod installed
  4. ? Ingress gateways installed
  5. ? Egress gateways installed
  6. ? Installation complete Making this installation the default for injection and validation.

(8)验证

[root@master istio-1.18.2]# kubectl get pods -n istio-system

(9)Kuboard查看

(10)创建网关

[root@master ~]# vim gitlab-gateway.yaml 

  1. apiVersion: networking.istio.io/v1alpha3
  2. kind: Gateway
  3. metadata:
  4. name: gitlab-gateway
  5. namespace: devops
  6. spec:
  7. selector:
  8. istio: ingressgateway # use istio default controller
  9. servers:
  10. - port:
  11. number: 80
  12. name: http
  13. protocol: HTTP
  14. hosts:
  15. - "gitlab.site"

[root@master ~]#  kubectl apply -f gitlab-gateway.yaml

(11)创建虚拟服务

[root@master ~]# vim gitlab-vs.yaml 

  1. apiVersion: networking.istio.io/v1alpha3
  2. kind: VirtualService
  3. metadata:
  4. name: gitlab-vs
  5. namespace: devops
  6. spec:
  7. hosts:
  8. - "gitlab.site"
  9. gateways:
  10. - gitlab-gateway
  11. http:
  12. - match:
  13. - uri:
  14. prefix: /
  15. route:
  16. - destination:
  17. host: gitlab
  18. port:
  19. number: 80

[root@master ~]# kubectl apply -f gitlab-vs.yaml

(12)查看网关

[root@master ~]# kubectl get gateway -n devops

(13)查看虚拟服务

[root@master ~]# kubectl get virtualservice -n devops

(14)通过istio提供的入口网关访问pod

[root@master ~]# kubectl get svc -n istio-system

(15)查看关联

[root@master ~]# kubectl get pods -n istio-system -owide

istio-ingressgateway是service资源,关联的pod是istio-system名称空间叫做iistio-ingressgateway-6d9f6c64cb-nldhf的pod

(16)查看istio-ingressgateway这个service的详细信息

  1. [root@master ~]# kubectl describe svc istio-ingressgateway -n istio-system
  2. Name: istio-ingressgateway
  3. Namespace: istio-system
  4. Labels: app=istio-ingressgateway
  5. install.operator.istio.io/owning-resource=unknown
  6. install.operator.istio.io/owning-resource-namespace=istio-system
  7. istio=ingressgateway
  8. istio.io/rev=default
  9. operator.istio.io/component=IngressGateways
  10. operator.istio.io/managed=Reconcile
  11. operator.istio.io/version=1.18.2
  12. release=istio
  13. Annotations: <none>
  14. Selector: app=istio-ingressgateway,istio=ingressgateway
  15. Type: LoadBalancer
  16. IP Family Policy: SingleStack
  17. IP Families: IPv4
  18. IP: 10.97.137.224
  19. IPs: 10.97.137.224
  20. Port: status-port 15021/TCP
  21. TargetPort: 15021/TCP
  22. NodePort: status-port 30820/TCP
  23. Endpoints: 10.244.166.162:15021
  24. Port: http2 80/TCP
  25. TargetPort: 8080/TCP
  26. NodePort: http2 31447/TCP
  27. Endpoints: 10.244.166.162:8080
  28. Port: https 443/TCP
  29. TargetPort: 8443/TCP
  30. NodePort: https 31205/TCP
  31. Endpoints: 10.244.166.162:8443
  32. Port: tcp 31400/TCP
  33. TargetPort: 31400/TCP
  34. NodePort: tcp 30086/TCP
  35. Endpoints: 10.244.166.162:31400
  36. Port: tls 15443/TCP
  37. TargetPort: 15443/TCP
  38. NodePort: tls 32071/TCP
  39. Endpoints: 10.244.166.162:15443
  40. Session Affinity: None
  41. External Traffic Policy: Cluster
  42. Events: <none>

(17)Kuboard查看

工作负载

容器组

服务

7.K8S 部署ingress应用路由

(1)K8S进入容器查看

[root@master ~]# kubectl exec -it gitlab-84d7ff8cc6-k2kh9 -n devops /bin/bash

安装net-tools

root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# apt-get install net-tools

安装lsof

root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# apt-get install lsof     

(2)监听端口

root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# netstat -antlp 

curl测试

curl 127.0.0.1

lsof

lsof -i

 lsof -i:80

(3)master节点查看svc

ingress-nginx-controller 默认是LoadBalancer,一直为pending状态

[root@master ~]# kubectl get svc -n ingress-nginx

(4)修改svc

[root@master ~]# kubectl edit svc ingress-nginx-controller -n ingress-nginx

修改前:

修改后:

(5)Kuboard查看

(6)部署ingress

[root@master ~]# vim ingress-gitlab.yaml 

  1. apiVersion: networking.k8s.io/v1
  2. kind: Ingress
  3. metadata:
  4. name: ingress-gitlab
  5. namespace: devops
  6. spec:
  7. ingressClassName: "nginx"
  8. rules:
  9. - host: gitlab.site
  10. http:
  11. paths:
  12. - path: /
  13. pathType: Prefix
  14. backend:
  15. service:
  16. name: gitlab
  17. port:
  18. number: 80

​​​​​​​

(7)生成资源

[root@master ~]# kubectl apply -f ingress-gitlab.yaml 

(8)查看ingress

[root@master ~]# kubectl get ingress -n devops

(9)详细查看

  1. [root@master ~]# kubectl describe ingress ingress-gitlab -n devops
  2. Name: ingress-gitlab
  3. Labels: <none>
  4. Namespace: devops
  5. Address: 10.101.23.182
  6. Ingress Class: nginx
  7. Default backend: <default>
  8. Rules:
  9. Host Path Backends
  10. ---- ---- --------
  11. gitlab.site
  12. / gitlab:80 (10.244.166.159:80)
  13. Annotations: <none>
  14. Events:
  15. Type Reason Age From Message
  16. ---- ------ ---- ---- -------
  17. Normal Sync 17m (x2 over 17m) nginx-ingress-controller Scheduled for sync
  18. Normal Sync 17m (x2 over 17m) nginx-ingress-controller Scheduled for sync

(10)Kuboard查看

应用路由

详细信息

(11)master节点修改hosts

[root@master ~]# vim /etc/hosts

(11)curl测试

[root@master ~]# curl gitlab.site:31820

(12)物理机修改hosts

(13)访问系统

http://gitlab.site:31820

(14)输入用户名和密码

  1. 账号:root
  2. 密码:admin123

(15)成功进入系统

二、问题

1.K8S部署gitlab报错

(1)报错

  1. Warning Unhealthy 2m43s (x15 over 3m53s) kubelet Startup probe failed: Get "http://10.244.166.144:80/": dial tcp 10.244.166.144:80: connect: connection refused
  2. Warning Unhealthy 23s (x28 over 2m38s) kubelet Startup probe failed: HTTP probe failed with statuscode: 502

(2)原因分析

gitlab镜像版本的问题,使用的版本有问题导致启动失败。

  1. 1)修改sameersbn仓库镜像:
  2. sameersbn/gitlab:15.6.0
  3. 2)其他支持的gitlab仓库镜像:
  4. gitlab/gitlab-ce:14.0.0-ce.0或者gitlab/gitlab-ce:15.6.0-ce.0

(3)解决方法

删除资源

修改部署文件的gitlab镜像版本:

换了镜像后,启动pod成功,但用describe命令查看描述日志,仍然出现了开始的警告内容
此时可尝试修改readinessProbe参数中的initialDelaySeconds和timeoutSeconds
分别修改为180和5。

修改前:

修改后:(此举用意在于增加初始化延迟时间和超时时间来避免时间过短导致步骤未成功走完就报错。)

2.gitlab创建失败

(1)报错

gitlab的pod启动失败

(2)原因分析

查看日志

  1. [root@master ~]# kubectl logs -f gitlab-84d7ff8cc6-k2kh9 -n devops
  2. Loading /etc/docker-gitlab/runtime/env-defaults
  3. Initializing logdir...
  4. Initializing datadir...
  5. Generating OpenSSH host keys... RSA DSA ECDSA ED25519
  6. Container TimeZone -> Asia/Shanghai
  7. Installing configuration templates...
  8. Configuring gitlab...
  9. Configuring gitlab::database....
  10. Configuring gitlab::redis..
  11. Configuring gitlab::actioncable
  12. Configuring gitlab::secrets...
  13. Configuring gitlab::sidekiq...
  14. Configuring gitlab::gitaly...
  15. Configuring gitlab::monitoring...
  16. Configuring gitlab::gitlab-workhorse...
  17. Configuring gitlab::puma...
  18. Configuring gitlab::timezone...
  19. Configuring gitlab::rack_attack...
  20. Configuring gitlab::ci...
  21. Configuring gitlab::artifacts...
  22. Configuring gitlab::packages...
  23. Configuring gitlab::terraform_state...
  24. Configuring gitlab::lfs...
  25. Configuring gitlab::uploads...
  26. Configuring gitlab::mattermost...
  27. Configuring gitlab::project_features...
  28. Configuring gitlab::oauth...
  29. Configuring gitlab::ldap...
  30. Configuring gitlab::cron_jobs...
  31. Configuring gitlab::backups...
  32. Configuring gitlab::backups::schedule...
  33. Configuring gitlab::registry...
  34. Configuring gitlab::pages...
  35. Configuring gitlab::sentry...
  36. Configuring gitlab::content_security_policy...
  37. Configuring gitlab-shell...
  38. Configuring nginx...
  39. Configuring nginx::gitlab...
  40. 2024-04-23 21:25:23,390 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in tu intend to run as root, you can set user=root in the config file to avoid this message.
  41. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  42. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/gitaly.conf" during parsing
  43. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/gitlab-workhorse.conf" during parsing
  44. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/groups.conf" during parsing
  45. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/mail_room.conf" during parsing
  46. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  47. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/puma.conf" during parsing
  48. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
  49. 2024-04-23 21:25:23,390 INFO Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
  50. 2024-04-23 21:25:23,397 INFO RPC interface 'supervisor' initialized
  51. 2024-04-23 21:25:23,398 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  52. 2024-04-23 21:25:23,398 INFO supervisord started with pid 753
  53. 2024-04-23 21:25:24,402 INFO spawned: 'gitaly' with pid 763
  54. 2024-04-23 21:25:24,405 INFO spawned: 'puma' with pid 764
  55. 2024-04-23 21:25:24,409 INFO spawned: 'gitlab-workhorse' with pid 765
  56. 2024-04-23 21:25:24,412 INFO spawned: 'sidekiq' with pid 766
  57. 2024-04-23 21:25:24,415 INFO spawned: 'sshd' with pid 772
  58. 2024-04-23 21:25:24,418 INFO spawned: 'nginx' with pid 773
  59. 2024-04-23 21:25:24,421 INFO spawned: 'cron' with pid 778
  60. 2024-04-23 21:25:25,911 INFO success: gitaly entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  61. 2024-04-23 21:25:25,911 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  62. 2024-04-23 21:25:25,911 INFO success: gitlab-workhorse entered RUNNING state, process has stayed up for > than 1 seconds (
  63. 2024-04-23 21:25:25,911 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  64. 2024-04-23 21:25:25,911 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  65. 2024-04-23 21:25:25,911 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  66. 2024-04-23 21:25:25,912 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  67. psql: error: could not translate host name "postgresql" to address: Temporary failure in name resolution

重点是最后一行:

psql: error: could not translate host name "postgresql" to address: Temporary failure in name resolution

(3)解决方法

查看容器地址

  1. [root@master ~]# kubectl get pod -o wide -n devops
  2. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  3. gitlab-84d7ff8cc6-k2kh9 0/1 Running 4 (66s ago) 14m 10.244.166.159 node1 <none> <none>
  4. postgresql-6d7dfcf685-nhmw5 1/1 Running 0 26m 10.244.166.157 node1 <none> <none>
  5. redis-6948bd4c7f-gp2ml 1/1 Running 0 49m 10.244.166.151 node1 <none> <none>

K8S 进入容器添加hosts

  1. [root@master ~]# kubectl exec -it gitlab-84d7ff8cc6-k2kh9 -n devops /bin/bash
  2. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  3. root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# cat /etc/hosts
  4. # Kubernetes-managed hosts file.
  5. 127.0.0.1 localhost
  6. ::1 localhost ip6-localhost ip6-loopback
  7. fe00::0 ip6-localnet
  8. fe00::0 ip6-mcastprefix
  9. fe00::1 ip6-allnodes
  10. fe00::2 ip6-allrouters
  11. 10.244.166.159 gitlab-84d7ff8cc6-k2kh9
  12. root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# echo "10.244.166.157 postgresql" >> /etc/hosts
  13. root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# echo "10.244.166.151 redis" >> /etc/hosts

查看

  1. root@gitlab-84d7ff8cc6-k2kh9:/home/git/gitlab# cat /etc/hosts
  2. # Kubernetes-managed hosts file.
  3. 127.0.0.1 localhost
  4. ::1 localhost ip6-localhost ip6-loopback
  5. fe00::0 ip6-localnet
  6. fe00::0 ip6-mcastprefix
  7. fe00::1 ip6-allnodes
  8. fe00::2 ip6-allrouters
  9. 10.244.166.159 gitlab-84d7ff8cc6-k2kh9
  10. 10.244.166.157 postgresql
  11. 10.244.166.151 redis

再次查看日志

  1. [root@master ~]# kubectl logs -f gitlab-84d7ff8cc6-k2kh9 -n devops
  2. Loading /etc/docker-gitlab/runtime/env-defaults
  3. Initializing logdir...
  4. Initializing datadir...
  5. Container TimeZone -> Asia/Shanghai
  6. Installing configuration templates...
  7. Configuring gitlab...
  8. Configuring gitlab::database..
  9. Configuring gitlab::redis...
  10. Configuring gitlab::actioncable
  11. Configuring gitlab::secrets...
  12. Configuring gitlab::sidekiq...
  13. Configuring gitlab::gitaly...
  14. Configuring gitlab::monitoring...
  15. Configuring gitlab::gitlab-workhorse...
  16. Configuring gitlab::puma...
  17. Configuring gitlab::timezone...
  18. Configuring gitlab::rack_attack...
  19. Configuring gitlab::ci...
  20. Configuring gitlab::artifacts...
  21. Configuring gitlab::packages...
  22. Configuring gitlab::terraform_state...
  23. Configuring gitlab::lfs...
  24. Configuring gitlab::uploads...
  25. Configuring gitlab::mattermost...
  26. Configuring gitlab::project_features...
  27. Configuring gitlab::oauth...
  28. Configuring gitlab::ldap...
  29. Configuring gitlab::cron_jobs...
  30. Configuring gitlab::backups...
  31. Configuring gitlab::backups::schedule...
  32. Configuring gitlab::registry...
  33. Configuring gitlab::pages...
  34. Configuring gitlab::sentry...
  35. Configuring gitlab::content_security_policy...
  36. Configuring gitlab-shell...
  37. Configuring nginx...
  38. Configuring nginx::gitlab...
  39. Setting up GitLab for firstrun. Please be patient, this could take a while...
  40. 2024-04-23 21:39:06,958 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in tu intend to run as root, you can set user=root in the config file to avoid this message.
  41. 2024-04-23 21:39:06,958 INFO Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  42. 2024-04-23 21:39:06,958 INFO Included extra file "/etc/supervisor/conf.d/gitaly.conf" during parsing
  43. 2024-04-23 21:39:06,958 INFO Included extra file "/etc/supervisor/conf.d/gitlab-workhorse.conf" during parsing
  44. 2024-04-23 21:39:06,958 INFO Included extra file "/etc/supervisor/conf.d/groups.conf" during parsing
  45. 2024-04-23 21:39:06,958 INFO Included extra file "/etc/supervisor/conf.d/mail_room.conf" during parsing
  46. 2024-04-23 21:39:06,959 INFO Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  47. 2024-04-23 21:39:06,959 INFO Included extra file "/etc/supervisor/conf.d/puma.conf" during parsing
  48. 2024-04-23 21:39:06,959 INFO Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
  49. 2024-04-23 21:39:06,959 INFO Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
  50. 2024-04-23 21:39:06,966 INFO RPC interface 'supervisor' initialized
  51. 2024-04-23 21:39:06,966 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  52. 2024-04-23 21:39:06,966 INFO supervisord started with pid 755
  53. 2024-04-23 21:39:07,970 INFO spawned: 'gitaly' with pid 768
  54. 2024-04-23 21:39:07,974 INFO spawned: 'puma' with pid 769
  55. 2024-04-23 21:39:07,977 INFO spawned: 'gitlab-workhorse' with pid 770
  56. 2024-04-23 21:39:07,980 INFO spawned: 'sidekiq' with pid 771
  57. 2024-04-23 21:39:07,983 INFO spawned: 'sshd' with pid 777
  58. 2024-04-23 21:39:07,986 INFO spawned: 'nginx' with pid 778
  59. 2024-04-23 21:39:07,989 INFO spawned: 'cron' with pid 782
  60. 2024-04-23 21:39:09,462 INFO success: gitaly entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  61. 2024-04-23 21:39:09,463 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  62. 2024-04-23 21:39:09,463 INFO success: gitlab-workhorse entered RUNNING state, process has stayed up for > than 1 seconds (
  63. 2024-04-23 21:39:09,463 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  64. 2024-04-23 21:39:09,463 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  65. 2024-04-23 21:39:09,463 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  66. 2024-04-23 21:39:09,463 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  67. 2024-04-23 21:39:40,078 INFO exited: puma (exit status 1; not expected)
  68. 2024-04-23 21:39:40,081 INFO spawned: 'puma' with pid 886
  69. /home/git/gitlab/lib/gitlab/instrumentation/redis.rb:9: warning: already initialized constant Gitlab::Instrumentation::Red
  70. /home/git/gitlab/lib/gitlab/instrumentation/redis.rb:9: warning: previous definition of ActionCable was here
  71. 2024-04-23 21:39:41,387 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  72. 2024-04-23 21:39:41,388 INFO exited: sidekiq (exit status 1; not expected)
  73. 2024-04-23 21:39:41,620 INFO spawned: 'sidekiq' with pid 887
  74. 2024-04-23 21:39:43,017 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  75. Database 'gitlab_production' already exists
  76. psql:/home/git/gitlab/db/structure.sql:9: NOTICE: extension "btree_gist" already exists, skipping
  77. psql:/home/git/gitlab/db/structure.sql:11: NOTICE: extension "pg_trgm" already exists, skipping
  78. 2024-04-23 21:40:10,686 INFO exited: puma (exit status 1; not expected)
  79. 2024-04-23 21:40:10,689 INFO spawned: 'puma' with pid 919
  80. 2024-04-23 21:40:11,692 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  81. 2024-04-23 21:40:12,042 INFO exited: sidekiq (exit status 1; not expected)
  82. 2024-04-23 21:40:12,213 INFO spawned: 'sidekiq' with pid 920
  83. 2024-04-23 21:40:13,217 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  84. 2024-04-23 21:40:40,234 INFO exited: puma (exit status 1; not expected)
  85. 2024-04-23 21:40:41,236 INFO spawned: 'puma' with pid 929
  86. 2024-04-23 21:40:42,140 INFO exited: sidekiq (exit status 1; not expected)
  87. 2024-04-23 21:40:42,832 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  88. 2024-04-23 21:40:42,835 INFO spawned: 'sidekiq' with pid 930
  89. 2024-04-23 21:40:43,837 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  90. 2024-04-23 21:41:33,889 INFO exited: puma (exit status 1; not expected)
  91. 2024-04-23 21:41:34,767 INFO spawned: 'puma' with pid 942
  92. 2024-04-23 21:41:34,854 INFO exited: sidekiq (exit status 1; not expected)
  93. 2024-04-23 21:41:34,857 INFO spawned: 'sidekiq' with pid 943
  94. 2024-04-23 21:41:35,859 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  95. 2024-04-23 21:41:35,859 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  96. Migrating database...
  97. /home/git/gitlab/lib/gitlab/instrumentation/redis.rb:9: warning: already initialized constant Gitlab::Instrumentation::Red
  98. /home/git/gitlab/lib/gitlab/instrumentation/redis.rb:9: warning: previous definition of ActionCable was here
  99. Clearing cache...
  100. 2024-04-23 21:43:41,207 WARN received SIGTERM indicating exit request
  101. 2024-04-23 21:43:41,208 INFO waiting for gitaly, puma, gitlab-workhorse, sidekiq, sshd, nginx, cron to die
  102. 2024-04-23 21:43:41,209 INFO stopped: cron (terminated by SIGTERM)
  103. 2024-04-23 21:43:41,209 INFO stopped: sshd (exit status 0)
  104. 2024-04-23 21:43:41,214 INFO stopped: nginx (exit status 0)
  105. 2024-04-23 21:43:44,231 INFO stopped: sidekiq (exit status 0)
  106. 2024-04-23 21:43:44,232 INFO waiting for gitaly, puma, gitlab-workhorse to die
  107. 2024-04-23 21:43:44,234 INFO stopped: gitlab-workhorse (exit status 1)
  108. 2024-04-23 21:43:47,238 INFO stopped: puma (terminated by SIGQUIT (core dumped))
  109. 2024-04-23 21:43:47,238 INFO waiting for gitaly to die
  110. 2024-04-23 21:43:47,274 INFO stopped: gitaly (exit status 1)
  111. 2024-04-23 21:43:47,533 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in tu intend to run as root, you can set user=root in the config file to avoid this message.
  112. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  113. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/gitaly.conf" during parsing
  114. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/gitlab-workhorse.conf" during parsing
  115. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/groups.conf" during parsing
  116. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/mail_room.conf" during parsing
  117. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  118. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/puma.conf" during parsing
  119. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
  120. 2024-04-23 21:43:47,534 INFO Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
  121. 2024-04-23 21:43:47,541 INFO RPC interface 'supervisor' initialized
  122. 2024-04-23 21:43:47,541 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  123. 2024-04-23 21:43:47,542 INFO supervisord started with pid 1
  124. 2024-04-23 21:43:48,545 INFO spawned: 'gitaly' with pid 1093
  125. 2024-04-23 21:43:48,548 INFO spawned: 'puma' with pid 1094
  126. 2024-04-23 21:43:48,551 INFO spawned: 'gitlab-workhorse' with pid 1095
  127. 2024-04-23 21:43:48,555 INFO spawned: 'sidekiq' with pid 1096
  128. 2024-04-23 21:43:48,557 INFO spawned: 'sshd' with pid 1099
  129. 2024-04-23 21:43:48,560 INFO spawned: 'nginx' with pid 1103
  130. 2024-04-23 21:43:48,563 INFO spawned: 'cron' with pid 1108
  131. 2024-04-23 21:43:50,020 INFO success: gitaly entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  132. 2024-04-23 21:43:50,020 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  133. 2024-04-23 21:43:50,020 INFO success: gitlab-workhorse entered RUNNING state, process has stayed up for > than 1 seconds (
  134. 2024-04-23 21:43:50,020 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  135. 2024-04-23 21:43:50,020 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  136. 2024-04-23 21:43:50,021 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  137. 2024-04-23 21:43:50,021 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  138. 2024-04-23 21:44:08,020 WARN received SIGTERM indicating exit request
  139. 2024-04-23 21:44:08,020 INFO waiting for gitaly, puma, gitlab-workhorse, sidekiq, sshd, nginx, cron to die
  140. 2024-04-23 21:44:08,021 INFO stopped: cron (terminated by SIGTERM)
  141. 2024-04-23 21:44:08,022 INFO stopped: sshd (exit status 0)
  142. 2024-04-23 21:44:08,024 INFO stopped: nginx (exit status 0)
  143. 2024-04-23 21:44:08,066 INFO stopped: sidekiq (terminated by SIGTERM)
  144. 2024-04-23 21:44:08,068 INFO stopped: gitlab-workhorse (exit status 1)
  145. 2024-04-23 21:44:08,718 INFO stopped: puma (terminated by SIGQUIT (core dumped))
  146. 2024-04-23 21:44:08,752 INFO stopped: gitaly (exit status 1)
  147. [root@master ~]# kubectl logs -f gitlab-84d7ff8cc6-k2kh9 -n devops
  148. Loading /etc/docker-gitlab/runtime/env-defaults
  149. Initializing logdir...
  150. Initializing datadir...
  151. Container TimeZone -> Asia/Shanghai
  152. Installing configuration templates...
  153. Configuring gitlab...
  154. Configuring gitlab::database...
  155. Configuring gitlab::redis...
  156. Configuring gitlab::actioncable...
  157. Configuring gitlab::secrets...
  158. Configuring gitlab::sidekiq...
  159. Configuring gitlab::gitaly...
  160. Configuring gitlab::monitoring...
  161. Configuring gitlab::gitlab-workhorse...
  162. Configuring gitlab::puma...
  163. Configuring gitlab::timezone...
  164. Configuring gitlab::rack_attack...
  165. Configuring gitlab::ci...
  166. Configuring gitlab::artifacts...
  167. Configuring gitlab::packages...
  168. Configuring gitlab::terraform_state...
  169. Configuring gitlab::lfs...
  170. Configuring gitlab::uploads...
  171. Configuring gitlab::mattermost...
  172. Configuring gitlab::project_features...
  173. Configuring gitlab::oauth...
  174. Configuring gitlab::ldap...
  175. Configuring gitlab::cron_jobs...
  176. Configuring gitlab::backups...
  177. Configuring gitlab::backups::schedule...
  178. Configuring gitlab::registry...
  179. Configuring gitlab::pages...
  180. Configuring gitlab::sentry...
  181. Configuring gitlab::content_security_policy...
  182. Configuring gitlab-shell...
  183. Configuring nginx...
  184. Configuring nginx::gitlab...
  185. 2024-04-23 21:48:22,675 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in tu intend to run as root, you can set user=root in the config file to avoid this message.
  186. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  187. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/gitaly.conf" during parsing
  188. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/gitlab-workhorse.conf" during parsing
  189. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/groups.conf" during parsing
  190. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/mail_room.conf" during parsing
  191. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  192. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/puma.conf" during parsing
  193. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
  194. 2024-04-23 21:48:22,675 INFO Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
  195. 2024-04-23 21:48:22,683 INFO RPC interface 'supervisor' initialized
  196. 2024-04-23 21:48:22,683 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  197. 2024-04-23 21:48:22,683 INFO supervisord started with pid 1
  198. 2024-04-23 21:48:23,688 INFO spawned: 'gitaly' with pid 772
  199. 2024-04-23 21:48:23,691 INFO spawned: 'puma' with pid 773
  200. 2024-04-23 21:48:23,695 INFO spawned: 'gitlab-workhorse' with pid 774
  201. 2024-04-23 21:48:23,698 INFO spawned: 'sidekiq' with pid 775
  202. 2024-04-23 21:48:23,701 INFO spawned: 'sshd' with pid 781
  203. 2024-04-23 21:48:23,704 INFO spawned: 'nginx' with pid 782
  204. 2024-04-23 21:48:23,707 INFO spawned: 'cron' with pid 785
  205. 2024-04-23 21:48:25,192 INFO success: gitaly entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  206. 2024-04-23 21:48:25,192 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  207. 2024-04-23 21:48:25,192 INFO success: gitlab-workhorse entered RUNNING state, process has stayed up for > than 1 seconds (
  208. 2024-04-23 21:48:25,192 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  209. 2024-04-23 21:48:25,192 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  210. 2024-04-23 21:48:25,192 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  211. 2024-04-23 21:48:25,192 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  212. 2024-04-23 21:51:20,541 INFO exited: sidekiq (exit status 1; not expected)
  213. 2024-04-23 21:51:21,546 INFO spawned: 'sidekiq' with pid 911
  214. 2024-04-23 21:51:23,016 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs
  215. ^C

成功:

3.生成网关资源报错

(1)报错

  1. error: resource mapping not found for name: "gitlab-gateway" namespace: "devops" from "gitlab-gateway.yaml": no matches for kind "Gateway" in version "networking.istio.io/v1alpha3"
  2. ensure CRDs are installed first

(2)原因分析

未安装istio。

(3)解决方法

安装istio:

成功:

4.安装istio 报错

(1)报错

  1. ? Egress gateways encountered an error: failed to wait for resource: resources not ready after 5m0s: context deadline exce
  2. Deployment/istio-system/istio-egressgateway (containers with unready status: [istio-proxy])
  3. - Pruning removed resources

(2)原因分析

Egress的pod还未完全启动。

(3)解决方法

重新安装,等待egress加载完成。

5.istio-ingressgateway 一直处于pending状态

(1)报错

(2)原因分析

因为istio-ingressgateway的默认类型为LoadBalancer,没有公有云的话,可以修改为NodePort.

(3)解决方法

istio-ingressgateway的类型修改为NodePort:

[root@master ~]# kubectl edit svc istio-ingressgateway -n istio-system

修改前:

修改后:

成功:

[root@master ~]# kubectl get pods -n istio-system -owide

查看:

  1. [root@master ~]# kubectl describe svc istio-ingressgateway -n istio-system
  2. Name: istio-ingressgateway
  3. Namespace: istio-system
  4. Labels: app=istio-ingressgateway
  5. install.operator.istio.io/owning-resource=unknown
  6. install.operator.istio.io/owning-resource-namespace=istio-system
  7. istio=ingressgateway
  8. istio.io/rev=default
  9. operator.istio.io/component=IngressGateways
  10. operator.istio.io/managed=Reconcile
  11. operator.istio.io/version=1.18.2
  12. release=istio
  13. Annotations: <none>
  14. Selector: app=istio-ingressgateway,istio=ingressgateway
  15. Type: NodePort
  16. IP Family Policy: SingleStack
  17. IP Families: IPv4
  18. IP: 10.97.137.224
  19. IPs: 10.97.137.224
  20. Port: status-port 15021/TCP
  21. TargetPort: 15021/TCP
  22. NodePort: status-port 30820/TCP
  23. Endpoints: 10.244.166.162:15021
  24. Port: http2 80/TCP
  25. TargetPort: 8080/TCP
  26. NodePort: http2 31447/TCP
  27. Endpoints: 10.244.166.162:8080
  28. Port: https 443/TCP
  29. TargetPort: 8443/TCP
  30. NodePort: https 31205/TCP
  31. Endpoints: 10.244.166.162:8443
  32. Port: tcp 31400/TCP
  33. TargetPort: 31400/TCP
  34. NodePort: tcp 30086/TCP
  35. Endpoints: 10.244.166.162:31400
  36. Port: tls 15443/TCP
  37. TargetPort: 15443/TCP
  38. NodePort: tls 32071/TCP
  39. Endpoints: 10.244.166.162:15443
  40. Session Affinity: None
  41. External Traffic Policy: Cluster
  42. Events: <none>

6.istio如何实现自动注入 sidecar

(1)命令

需要­­为default命名空间打上标签istio-injection=enabled

[root@master ~]# kubectl label namespace default istio-injection=enabled

7.K8S容器从公钥接收失败

(1)报错

进入容器

[root@master ~]# kubectl exec -it gitlab-84d7ff8cc6-k2kh9 -n devops /bin/bash

更新源报错

W: GPG error: https://dl.yarnpkg.com/debian stable InRelease: The following signatures were invalid: EXPKEYSIG 23E7166788B63E1E Yarn Packaging <yarn@dan.cx>

(2)原因分析

无法检查签名:找不到公钥

(3)解决方法

备份更换源

  1. cp sources.list source.list.bak
  2. sudo sed -i 's/cn.archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
  3. sudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

更新还是报错

清空源

echo > /etc/apt/source.list

更新源

  1. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted" >> /etc/apt/sources.list
  2. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted" >> /etc/apt/sources.list
  3. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic universe" >> /etc/apt/sources.list
  4. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe" >> /etc/apt/sources.list
  5. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse" >> /etc/apt/sources.list
  6. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse" >> /etc/apt/sources.list
  7. echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
  8. echo "deb http://security.ubuntu.com/ubuntu bionic-security main restricted" >> /etc/apt/sources.list
  9. echo "deb http://security.ubuntu.com/ubuntu bionic-security universe" >> /etc/apt/sources.list
  10. echo "deb http://security.ubuntu.com/ubuntu bionic-security multiverse" >> /etc/apt/sources.list
  11. echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse" >> /etc/apt/sources.list
  12. echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list
  13. echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list
  14. echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse" >> /etc/apt/sources.list
  15. echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list
  16. echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse" >> /etc/apt/sources.list
  17. echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list
  18. echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list
  19. echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse" >> /etc/apt/sources.list
  20. echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list

修改DNS服务器

  1. echo "nameserver 8.8.8.8" >> /etc/resolv.conf
  2. echo "nameserver 8.8.4.4" >> /etc/resolv.conf

导入

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 23E7166788B63E1E

加入

sudo gpg --armor --export 23E7166788B63E1E | sudo apt-key add -

软件源更新成功:

apt-get update

软件更新(输入Y)

apt-get upgrade

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/484505
推荐阅读
相关标签
  

闽ICP备14008679号