1. 01-namespace.yaml
    1. apiVersion: v1
    2. kind: Namespace
    3. metadata:
    4. name: gitlab
    1. 02-redis.yaml
    1. ---
    2. apiVersion: v1
    3. kind: PersistentVolumeClaim
    4. metadata:
    5. name: redis
    6. namespace: gitlab
    7. annotations:
    8. volume.beta.kubernetes.io/storage-class: "gitops-data"
    9. spec:
    10. accessModes:
    11. - ReadWriteMany
    12. resources:
    13. requests:
    14. storage: 10Gi
    15. ---
    16. kind: Service
    17. apiVersion: v1
    18. metadata:
    19. name: gitlab-redis
    20. namespace: gitlab
    21. labels:
    22. app: gitlab-redis
    23. spec:
    24. type: ClusterIP
    25. ports:
    26. - name: redis
    27. protocol: TCP
    28. port: 6379
    29. targetPort: redis
    30. selector:
    31. app: gitlab-redis
    32. ---
    33. kind: Deployment
    34. apiVersion: apps/v1
    35. metadata:
    36. name: gitlab-redis
    37. namespace: gitlab
    38. labels:
    39. app: gitlab-redis
    40. spec:
    41. replicas: 1
    42. selector:
    43. matchLabels:
    44. app: gitlab-redis
    45. template:
    46. metadata:
    47. name: gitlab-redis
    48. labels:
    49. app: gitlab-redis
    50. spec:
    51. containers:
    52. - name: gitlab-redis
    53. image: 'sameersbn/redis:4.0.9-3'
    54. ports:
    55. - name: redis
    56. containerPort: 6379
    57. protocol: TCP
    58. resources:
    59. limits:
    60. cpu: 500m
    61. memory: 1Gi
    62. requests:
    63. cpu: 200m
    64. memory: 1Gi
    65. livenessProbe:
    66. exec:
    67. command:
    68. - redis-cli
    69. - ping
    70. initialDelaySeconds: 5
    71. timeoutSeconds: 5
    72. periodSeconds: 10
    73. successThreshold: 1
    74. failureThreshold: 3
    75. readinessProbe:
    76. exec:
    77. command:
    78. - redis-cli
    79. - ping
    80. initialDelaySeconds: 5
    81. timeoutSeconds: 5
    82. periodSeconds: 10
    83. successThreshold: 1
    84. failureThreshold: 3
    85. volumeMounts:
    86. - name: data
    87. mountPath: /var/lib/redis
    88. volumes:
    89. - name: data
    90. persistentVolumeClaim:
    91. claimName: redis
    1. 03-postgresql.yaml
    1. ---
    2. ## PVC
    3. apiVersion: v1
    4. kind: PersistentVolumeClaim
    5. metadata:
    6. name: pgsql
    7. namespace: gitlab
    8. annotations:
    9. volume.beta.kubernetes.io/storage-class: "gitops-data"
    10. spec:
    11. accessModes:
    12. - ReadWriteMany
    13. resources:
    14. requests:
    15. storage: 10Gi
    16. ---
    17. ## Service
    18. kind: Service
    19. apiVersion: v1
    20. metadata:
    21. name: gitlab-postgresql
    22. namespace: gitlab
    23. labels:
    24. app: gitlab-postgresql
    25. spec:
    26. ports:
    27. - name: postgres
    28. protocol: TCP
    29. port: 5432
    30. targetPort: postgres
    31. selector:
    32. app: postgresql
    33. type: ClusterIP
    34. ---
    35. ## Deployment
    36. kind: Deployment
    37. apiVersion: apps/v1
    38. metadata:
    39. name: gitlab-pgsql
    40. namespace: gitlab
    41. labels:
    42. app: postgresql
    43. spec:
    44. replicas: 1
    45. selector:
    46. matchLabels:
    47. app: postgresql
    48. template:
    49. metadata:
    50. name: postgresql
    51. labels:
    52. app: postgresql
    53. spec:
    54. containers:
    55. - name: postgresql
    56. image: sameersbn/postgresql:12-20200524
    57. ports:
    58. - name: postgres
    59. containerPort: 5432
    60. env:
    61. - name: DB_USER
    62. value: gitlab
    63. - name: DB_PASS
    64. value: passwOrd
    65. - name: DB_NAME
    66. value: gitlabhq_production
    67. - name: DB_EXTENSION
    68. value: 'pg_trgm,btree_gist'
    69. resources:
    70. requests:
    71. cpu: 200m
    72. memory: 256Mi
    73. limits:
    74. cpu: 2
    75. memory: 2Gi
    76. livenessProbe:
    77. exec:
    78. command: ["pg_isready","-h","localhost","-U","postgres"]
    79. initialDelaySeconds: 30
    80. timeoutSeconds: 5
    81. periodSeconds: 10
    82. successThreshold: 1
    83. failureThreshold: 3
    84. readinessProbe:
    85. exec:
    86. command: ["pg_isready","-h","localhost","-U","postgres"]
    87. initialDelaySeconds: 5
    88. timeoutSeconds: 1
    89. periodSeconds: 10
    90. successThreshold: 1
    91. failureThreshold: 3
    92. volumeMounts:
    93. - name: data
    94. mountPath: /var/lib/postgresql
    95. volumes:
    96. - name: data
    97. persistentVolumeClaim:
    98. claimName: pgsql
    1. 04-gitlab.yaml
    1. ---
    2. ## PVC
    3. apiVersion: v1
    4. kind: PersistentVolumeClaim
    5. metadata:
    6. name: gitlab
    7. namespace: gitlab
    8. annotations:
    9. volume.beta.kubernetes.io/storage-class: "gitops-data"
    10. spec:
    11. accessModes:
    12. - ReadWriteMany
    13. resources:
    14. requests:
    15. storage: 20Gi
    16. ---
    17. ## Service
    18. kind: Service
    19. apiVersion: v1
    20. metadata:
    21. name: gitlab
    22. namespace: gitlab
    23. labels:
    24. app: gitlab
    25. spec:
    26. ports:
    27. - name: http
    28. protocol: TCP
    29. port: 80
    30. targetPort: http
    31. - name: ssh
    32. protocol: TCP
    33. port: 22
    34. targetPort: ssh
    35. nodePort: 30022
    36. type: NodePort
    37. selector:
    38. app: gitlab
    39. ---
    40. kind: Deployment
    41. apiVersion: apps/v1
    42. metadata:
    43. name: gitlab
    44. namespace: gitlab
    45. labels:
    46. app: gitlab
    47. spec:
    48. replicas: 1
    49. selector:
    50. matchLabels:
    51. app: gitlab
    52. template:
    53. metadata:
    54. name: gitlab
    55. labels:
    56. app: gitlab
    57. spec:
    58. containers:
    59. - name: gitlab
    60. image: 'sameersbn/gitlab:13.10.2'
    61. ports:
    62. - name: ssh
    63. containerPort: 22
    64. - name: http
    65. containerPort: 80
    66. - name: https
    67. containerPort: 443
    68. env:
    69. - name: GITLAB_TIMEZONE
    70. value: Asia/Shanghai
    71. - name: GITLAB_SECRETS_OTP_KEY_BASE
    72. # Be used to encrypt 2FA secrets in the database. "long-and-random-alpha-numeric-string"
    73. value: long-and-random-alpha-numeric-string
    74. - name: GITLAB_SECRETS_DB_KEY_BASE
    75. # Be used to encrypt CI secret variables, as well as import credentials, in the database.
    76. value: long-and-random-alpha-numeric-string
    77. - name: GITLAB_SECRETS_SECRET_KEY_BASE
    78. # Be used for password reset links, and other 'standard' auth features.
    79. value: long-and-random-alpha-numeric-string
    80. - name: GITLAB_ROOT_PASSWORD
    81. value: admin321
    82. - name: GITLAB_ROOT_EMAIL
    83. value: test@test.com
    84. - name: GITLAB_HOST
    85. value: 'gitlab-test.datagrand.com'
    86. - name: GITLAB_PORT
    87. value: '80'
    88. - name: GITLAB_SSH_PORT
    89. value: '30022'
    90. - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS
    91. value: 'true'
    92. - name: GITLAB_NOTIFY_PUSHER
    93. value: 'false'
    94. - name: DB_TYPE
    95. value: postgres
    96. - name: DB_HOST
    97. value: gitlab-postgresql
    98. - name: DB_PORT
    99. value: '5432'
    100. - name: DB_USER
    101. value: gitlab
    102. - name: DB_PASS
    103. value: passwOrd
    104. - name: DB_NAME
    105. value: gitlabhq_production
    106. - name: REDIS_HOST
    107. value: gitlab-redis
    108. - name: REDIS_PORT
    109. value: '6379'
    110. resources:
    111. requests:
    112. cpu: 1
    113. memory: 1Gi
    114. limits:
    115. cpu: 2
    116. memory: 4Gi
    117. livenessProbe:
    118. httpGet:
    119. path: /
    120. port: 80
    121. scheme: HTTP
    122. initialDelaySeconds: 300
    123. timeoutSeconds: 5
    124. periodSeconds: 10
    125. successThreshold: 1
    126. failureThreshold: 3
    127. readinessProbe:
    128. httpGet:
    129. path: /
    130. port: 80
    131. scheme: HTTP
    132. initialDelaySeconds: 5
    133. timeoutSeconds: 30
    134. periodSeconds: 10
    135. successThreshold: 1
    136. failureThreshold: 3
    137. volumeMounts:
    138. - name: data
    139. mountPath: /home/git/data
    140. - name: localtime
    141. mountPath: /etc/localtime
    142. volumes:
    143. - name: data
    144. persistentVolumeClaim:
    145. claimName: gitlab
    146. - name: localtime
    147. hostPath:
    148. path: /etc/localtime
    1. 05-ingress.yaml
    1. apiVersion: extensions/v1beta1
    2. kind: Ingress
    3. metadata:
    4. name: gitlab
    5. namespace: gitlab
    6. annotations:
    7. kubernetes.io/ingress.class: "nginx"
    8. spec:
    9. rules:
    10. - host: gitlab-test.test.com
    11. http:
    12. paths:
    13. - backend:
    14. serviceName: gitlab
    15. servicePort: 80