From b42e934d2b6d62608a7ca8d0c76d460fc5646f59 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 12 Jan 2017 16:30:04 -0500 Subject: [PATCH 1/6] Use .yml instead of .yaml so it's consistent --- ...ult-backend-deployment.yaml => default-backend-deployment.yml} | 0 ingress/{default-backend-svc.yaml => default-backend-svc.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename ingress/{default-backend-deployment.yaml => default-backend-deployment.yml} (100%) rename ingress/{default-backend-svc.yaml => default-backend-svc.yml} (100%) diff --git a/ingress/default-backend-deployment.yaml b/ingress/default-backend-deployment.yml similarity index 100% rename from ingress/default-backend-deployment.yaml rename to ingress/default-backend-deployment.yml diff --git a/ingress/default-backend-svc.yaml b/ingress/default-backend-svc.yml similarity index 100% rename from ingress/default-backend-svc.yaml rename to ingress/default-backend-svc.yml From f44d9f10c1db6526cf39894ffc1c68993baf480e Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 12 Jan 2017 17:19:06 -0500 Subject: [PATCH 2/6] Add persistentVolumeClaim to postgresql --- gitlab/postgresql-deployment.yml | 3 ++- gitlab/postgresql-storage.yml | 13 +++++++++++++ gitlab/storage.yml | 8 ++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gitlab/postgresql-storage.yml create mode 100644 gitlab/storage.yml diff --git a/gitlab/postgresql-deployment.yml b/gitlab/postgresql-deployment.yml index e2ccffa..473038f 100644 --- a/gitlab/postgresql-deployment.yml +++ b/gitlab/postgresql-deployment.yml @@ -51,4 +51,5 @@ spec: timeoutSeconds: 1 volumes: - name: data - emptyDir: {} + persistentVolumeClaim: + claimName: gitlab-postgresql-storage diff --git a/gitlab/postgresql-storage.yml b/gitlab/postgresql-storage.yml new file mode 100644 index 0000000..7bf71c2 --- /dev/null +++ b/gitlab/postgresql-storage.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: gitlab-postgresql-storage + namespace: gitlab + annotations: + volume.beta.kubernetes.io/storage-class: fast +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 30Gi diff --git a/gitlab/storage.yml b/gitlab/storage.yml new file mode 100644 index 0000000..0d5724c --- /dev/null +++ b/gitlab/storage.yml @@ -0,0 +1,8 @@ +apiVersion: storage.k8s.io/v1beta1 +kind: StorageClass +metadata: + name: fast + namespace: gitlab +provisioner: kubernetes.io/gce-pd +parameters: + type: pd-ssd From 34046eaf5bf8c5a82020543849f7bb9713535482 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 12 Jan 2017 17:51:43 -0500 Subject: [PATCH 3/6] Add storage for rails and redis --- gitlab/gitlab-deployment.yml | 3 ++- gitlab/gitlab-storage.yml | 13 +++++++++++++ gitlab/redis-deployment.yml | 3 ++- gitlab/redis-storage.yml | 13 +++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gitlab/gitlab-storage.yml create mode 100644 gitlab/redis-storage.yml diff --git a/gitlab/gitlab-deployment.yml b/gitlab/gitlab-deployment.yml index e4c4e0f..3a219bb 100644 --- a/gitlab/gitlab-deployment.yml +++ b/gitlab/gitlab-deployment.yml @@ -125,4 +125,5 @@ spec: timeoutSeconds: 1 volumes: - name: data - emptyDir: {} + persistentVolumeClaim: + claimName: gitlab-rails-storage diff --git a/gitlab/gitlab-storage.yml b/gitlab/gitlab-storage.yml new file mode 100644 index 0000000..21f0545 --- /dev/null +++ b/gitlab/gitlab-storage.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: gitlab-rails-storage + namespace: gitlab + annotations: + volume.beta.kubernetes.io/storage-class: fast +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 30Gi diff --git a/gitlab/redis-deployment.yml b/gitlab/redis-deployment.yml index 185788f..f8aa9a6 100644 --- a/gitlab/redis-deployment.yml +++ b/gitlab/redis-deployment.yml @@ -35,4 +35,5 @@ spec: timeoutSeconds: 1 volumes: - name: data - emptyDir: {} + persistentVolumeClaim: + claimName: gitlab-redis-storage diff --git a/gitlab/redis-storage.yml b/gitlab/redis-storage.yml new file mode 100644 index 0000000..5cd4b54 --- /dev/null +++ b/gitlab/redis-storage.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: gitlab-redis-storage + namespace: gitlab + annotations: + volume.beta.kubernetes.io/storage-class: fast +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi From 77ae6f8f0cdbed0f5ddf80cdd5b3167dfdd2d1bc Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 12 Jan 2017 18:12:13 -0500 Subject: [PATCH 4/6] Use ReadWriteMany for rails because we have many nodes --- gitlab/gitlab-storage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab/gitlab-storage.yml b/gitlab/gitlab-storage.yml index 21f0545..c4c1263 100644 --- a/gitlab/gitlab-storage.yml +++ b/gitlab/gitlab-storage.yml @@ -7,7 +7,7 @@ metadata: volume.beta.kubernetes.io/storage-class: fast spec: accessModes: - - ReadWriteOnce + - ReadWriteMany resources: requests: storage: 30Gi From 85a5e174de21f99c72ffafd41602a9083780a58e Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Thu, 12 Jan 2017 14:56:33 -0500 Subject: [PATCH 5/6] Switch to using the official postgres and GitLab container images --- gitlab/gitlab-deployment.yml | 106 ++++--------------------------- gitlab/postgresql-deployment.yml | 8 +-- 2 files changed, 17 insertions(+), 97 deletions(-) diff --git a/gitlab/gitlab-deployment.yml b/gitlab/gitlab-deployment.yml index 3a219bb..6246017 100644 --- a/gitlab/gitlab-deployment.yml +++ b/gitlab/gitlab-deployment.yml @@ -13,113 +13,33 @@ spec: spec: containers: - name: gitlab - image: sameersbn/gitlab:8.12.7 + image: gitlab/gitlab-ce:8.15.4-ce.1 imagePullPolicy: Always env: - - name: TZ - value: Europe/Stockholm - - name: GITLAB_TIMEZONE - value: Stockholm - - name: DEBUG - value: "false" - - - name: GITLAB_SECRETS_DB_KEY_BASE - value: P26qS5+Csz50Dkd0DLM2oN9owVBFg0PB - - name: GITLAB_SECRETS_SECRET_KEY_BASE - value: KVaMTKLAIElEp0s4L02c1O9JCP0Rfapb - - name: GITLAB_SECRETS_OTP_KEY_BASE - value: nXJJ358Qnci0yF9qpAsLrF2vImaoFR03 - - - name: GITLAB_ROOT_PASSWORD - value: root - - name: GITLAB_ROOT_EMAIL - value: root@example.com - - - name: GITLAB_HOST - value: git.example.com - - name: GITLAB_PORT - value: "80" - - name: GITLAB_SSH_HOST - value: "ssh-git.example.com" - - name: GITLAB_SSH_PORT - value: "1022" - - - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS - value: "true" - - name: GITLAB_NOTIFY_PUSHER - value: "false" - - - name: GITLAB_BACKUP_SCHEDULE - value: daily - - name: GITLAB_BACKUP_TIME - value: 01:00 - - - name: DB_TYPE - value: postgres - - name: DB_HOST - value: gitlab-postgresql - - name: DB_PORT - value: "5432" - - name: DB_USER - value: gitlab - - name: DB_PASS - value: +BP52QIxpT/flVCMpL3KXA== - - name: DB_NAME - value: gitlab_production - - - name: REDIS_HOST - value: gitlab-redis - - name: REDIS_PORT - value: "6379" - - - name: SMTP_ENABLED - value: "false" - - name: SMTP_DOMAIN - value: "" - - name: SMTP_HOST - value: "" - - name: SMTP_PORT - value: "" - - name: SMTP_USER - value: "" - - name: SMTP_PASS - value: "" - - name: SMTP_STARTTLS - value: "true" - - name: SMTP_AUTHENTICATION - value: login - - - name: IMAP_ENABLED - value: "false" - - name: IMAP_HOST - value: imap.gmail.com - - name: IMAP_PORT - value: "993" - - name: IMAP_USER - value: mailer@example.com - - name: IMAP_PASS - value: password - - name: IMAP_SSL - value: "true" - - name: IMAP_STARTTLS - value: "false" + - name: GITLAB_OMNIBUS_CONFIG + value: | + external_url "http://gitlab.example.com" + postgresql['enable']=false + gitlab_rails['db_host'] = 'gitlab-postgresql' + gitlab_rails['db_password']='+BP52QIxpT/flVCMpL3KXA==' + gitlab_rails['db_username']='gitlab' + gitlab_rails['db_database']='gitlab_production' + redis['enable'] = false + gitlab_rails['redis_host']='gitlab-redis' ports: - name: http containerPort: 80 - name: ssh containerPort: 22 - volumeMounts: - - mountPath: /home/git/data - name: data livenessProbe: httpGet: - path: /users/sign_in + path: /help port: 80 initialDelaySeconds: 180 timeoutSeconds: 15 readinessProbe: httpGet: - path: /users/sign_in + path: /help port: 80 initialDelaySeconds: 15 timeoutSeconds: 1 diff --git a/gitlab/postgresql-deployment.yml b/gitlab/postgresql-deployment.yml index 473038f..4bf378e 100644 --- a/gitlab/postgresql-deployment.yml +++ b/gitlab/postgresql-deployment.yml @@ -12,14 +12,14 @@ spec: spec: containers: - name: postgresql - image: sameersbn/postgresql:9.5-3 + image: postgres:9.5.3 imagePullPolicy: Always env: - - name: DB_USER + - name: POSTGRES_USER value: gitlab - - name: DB_PASS + - name: POSTGRES_PASSWORD value: +BP52QIxpT/flVCMpL3KXA== - - name: DB_NAME + - name: POSTGRES_DB value: gitlab_production - name: DB_EXTENSION value: pg_trgm From e13963643c931b04faa5abf8ba0caaac7ca01d23 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Thu, 12 Jan 2017 20:32:05 -0500 Subject: [PATCH 6/6] Add new mountpoints for persistent storage --- README.md | 11 +++++++++-- gitlab/gitlab-config-storage.yml | 13 +++++++++++++ gitlab/gitlab-deployment.yml | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 gitlab/gitlab-config-storage.yml diff --git a/README.md b/README.md index 31ea3d8..df8471b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # kubernetes-gitlab -Manifests to deploy GitLab on Kubernetes +Manifests to deploy GitLab on Kubernetes Installation process described in [blog](http://blog.lwolf.org/post/how-to-easily-deploy-gitlab-on-kubernetes/) @@ -16,7 +16,7 @@ Installation process described in [blog](http://blog.lwolf.org/post/how-to-easil * SSH is now available through 1022 service post. * NGINX settings is now configurable with configmap nginx-settings-configmap.yml. - Which currently sets body-size to 0 and increases timeouts to avoid timeouts. + Which currently sets body-size to 0 and increases timeouts to avoid timeouts. # TL;DR @@ -26,17 +26,24 @@ Installation process described in [blog](http://blog.lwolf.org/post/how-to-easil # create gitlab namespace > $ kubectl create -f gitlab-ns.yml +# create storage +> $ kubectl create -f gitlab/storage.yml + # deploy redis > $ kubectl create -f gitlab/redis-svc.yml +> $ kubectl create -f gitlab/redis-storage.yml > $ kubectl create -f gitlab/redis-deployment.yml # deploy postgres > $ kubectl create -f gitlab/postgresql-svc.yml +> $ kubectl create -f gitlab/postgresql-storage.yml > $ kubectl create -f gitlab/postgresql-deployment.yml # deploy gitlab itself > $ kubectl create -f gitlab/gitlab-svc.yml > $ kubectl create -f gitlab/gitlab-svc-nodeport.yml +> $ kubectl create -f gitlab/gitlab-storage.yml +> $ kubectl create -f gitlab/gitlab-config-storage.yml > $ kubectl create -f gitlab/gitlab-deployment.yml # deploy ingress controller diff --git a/gitlab/gitlab-config-storage.yml b/gitlab/gitlab-config-storage.yml new file mode 100644 index 0000000..7b53580 --- /dev/null +++ b/gitlab/gitlab-config-storage.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: gitlab-config-storage + namespace: gitlab + annotations: + volume.beta.kubernetes.io/storage-class: fast +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi diff --git a/gitlab/gitlab-deployment.yml b/gitlab/gitlab-deployment.yml index 6246017..d373bde 100644 --- a/gitlab/gitlab-deployment.yml +++ b/gitlab/gitlab-deployment.yml @@ -26,11 +26,23 @@ spec: gitlab_rails['db_database']='gitlab_production' redis['enable'] = false gitlab_rails['redis_host']='gitlab-redis' + manage_accounts['enable'] = true + manage_storage_directories['manage_etc'] = false + gitlab_shell['auth_file'] = '/gitlab-data/ssh/authorized_keys' + git_data_dir '/gitlab-data/git-data' + gitlab_rails['shared_path'] = '/gitlab-data/shared' + gitlab_rails['uploads_directory'] = '/gitlab-data/uploads' + gitlab_ci['builds_directory'] = '/gitlab-data/builds' ports: - name: http containerPort: 80 - name: ssh containerPort: 22 + volumeMounts: + - name: config + mountPath: /etc/gitlab + - name: data + mountPath: /gitlab-data livenessProbe: httpGet: path: /help @@ -47,3 +59,6 @@ spec: - name: data persistentVolumeClaim: claimName: gitlab-rails-storage + - name: config + persistentVolumeClaim: + claimName: gitlab-config-storage