Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit cc65276

Browse files
Merge pull request #87 from AnthonyAmanse/dev-cn
Modify README to use Cloud Native deployment
2 parents f213b6f + ac168a8 commit cc65276

File tree

4 files changed

+235
-119
lines changed

4 files changed

+235
-119
lines changed

README.md

Lines changed: 86 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -24,184 +24,151 @@ By using different GitLab components (NGINX, Ruby on Rails, Redis, PostgreSQL, a
2424
- [GitLab](https://about.gitlab.com/)
2525
- [PostgreSQL](https://www.postgresql.org/)
2626
- [Redis](https://redis.io/)
27+
- [Minio](https://github.com/minio/minio)
2728
- [Kubernetes Clusters](https://console.ng.bluemix.net/docs/containers/cs_ov.html#cs_ov)
28-
- [Bluemix container service](https://console.ng.bluemix.net/catalog/?taxonomyNavigation=apps&category=containers)
29-
- [Bluemix Compose for PostgreSQL](https://console.ng.bluemix.net/catalog/services/compose-for-postgresql)
29+
- [IBM Cloud Kubernetes Service](https://console.ng.bluemix.net/catalog/?taxonomyNavigation=apps&category=containers)
3030

31-
## Objectives
32-
This scenario provides instructions and learning for the following tasks:
31+
# Prerequisites
3332

34-
- Build containers, and store them in container registry
35-
- Use Kubernetes to create local persistent volumes to define persistent disks
36-
- Deploy containers using Kubernetes pods and services
37-
- Use Bluemix service in Kubernetes applications
38-
- Deploy a distributed GitLab on Kubernetes
33+
<!-- Use [Deploying Gitlab to IBM Cloud Private](docs/deploy-with-ICP.md) if you wish to install this on IBM Cloud Private, otherwise follow the instructions below. -->
3934

40-
## Deployment Scenarios
35+
Create a Kubernetes cluster with either [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube) for local testing, or with [IBM Cloud Kubernetes Service](https://console.bluemix.net/docs/containers/cs_tutorials.html#cs_cluster_tutorial) to deploy in cloud. The code here is regularly tested against [Kubernetes Cluster from IBM Cloud Kubernetes Service](https://console.ng.bluemix.net/docs/containers/cs_ov.html#cs_ov) using Travis.
4136

42-
### Deploy using Docker
37+
[Helm](https://helm.sh/) to install GitLab's Cloud Native charts.
4338

44-
see [Deploying Gitlab with Docker](docs/deploy-with-docker.md)
39+
# Steps
4540

46-
### Deploy to Kubernetes
41+
1. [Clone the repo](#1-clone-the-repo)
42+
2. [Create IBM Cloud Kubernetes Service](#2-create-ibm-cloud-kubernetes-service)
43+
3. [Install Helm](#3-install-helm)
44+
4. [Configure GitLab and Install](#4-configure-gitlab-and-install)
45+
5. [Launch GitLab](#5-launch-gitlab)
4746

48-
Use [Deploying Gitlab to IBM Cloud Private](docs/deploy-with-ICP.md) if you wish to install this on IBM Cloud Private, otherwise follow the instructions below.
47+
### 1. Clone the repo
4948

50-
Create a Kubernetes cluster with either [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube) for local testing, or with [IBM Bluemix Container Service](https://github.com/IBM/container-journey-template#container-journey-template---creating-a-kubernetes-cluster) to deploy in cloud. The code here is regularly tested against [Kubernetes Cluster from Bluemix Container Service](https://console.ng.bluemix.net/docs/containers/cs_ov.html#cs_ov) using Travis.
49+
Clone the repo and go in the cloned directory
50+
```
51+
$ git clone https://github.com/IBM/Kubernetes-container-service-GitLab-sample/
52+
```
5153

52-
If you want to use the Bluemix Container Registry start by [Uploading the images](docs/use-bluemix-container-registry.md) to the Bluemix Container Registry.
54+
### 2. Create IBM Cloud Kubernetes Service
5355

54-
### Deploy using DevOps Toolchain to Kubernetes Cluster from Bluemix Container Service
55-
If you want to deploy the Gitlab directly to Bluemix, click on `Deploy to Bluemix` button below to create a [Bluemix DevOps service toolchain and pipeline](https://console.ng.bluemix.net/docs/services/ContinuousDelivery/toolchains_about.html#toolchains_about) for deploying the Gitlab sample, else jump to [Steps](#steps)
56+
Create an IBM Cloud Kubernetes Service if you don't already have one:
5657

57-
[![Create Toolchain](https://github.com/IBM/container-journey-template/blob/master/images/button.png)](https://console.ng.bluemix.net/devops/setup/deploy/)
58+
* [IBM Cloud Kubernetes Service](https://console.bluemix.net/containers-kubernetes/catalog/cluster)
5859

59-
Please follow the [Toolchain instructions](https://github.com/IBM/container-journey-template/blob/master/Toolchain_Instructions_new.md) to complete your toolchain and pipeline.
60+
### 3. Install Helm
6061

61-
#### Steps
62+
If you don't have the Helm client in your machine, you can find one in the [official releases page](https://github.com/helm/helm/releases).
6263

63-
1. [Use Kubernetes to create Services and Deployments](#1-use-kubernetes-to-create-services-and-deployments-for-gitlab-redis-and-postgresql)
64-
- 1.1 [Use PostgreSQL in container](#11-use-postgresql-in-container) or
65-
- 1.2 [Use PostgreSQL from Bluemix](#12-use-postgresql-from-bluemix)
66-
2. [Retrieve external ip and port for GitLab](#2-retrieve-external-ip-and-port-for-gitlab)
67-
3. [GitLab is ready! Use GitLab to host your repositories](#3-gitlab-is-ready-use-gitlab-to-host-your-repositories)
64+
To install Helm in your Kubernetes Cluster, do:
6865

69-
#### 1. Use Kubernetes to create Services and Deployments for GitLab, Redis, and PostgreSQL
66+
```
67+
$ helm init
68+
```
7069

71-
Ensure your kubernetes cluster is reachable by running the `kubectl` command.
70+
Add the official gitlab repo:
7271

73-
```bash
74-
$ kubectl get nodes
75-
NAME STATUS AGE VERSION
76-
x.x.x.x Ready 17h v1.5.3-2+be7137fd3ad68f
72+
```
73+
$ helm repo add gitlab https://charts.gitlab.io/
74+
$ helm repo update
7775
```
7876

79-
> Note: If this step fails see troubleshooting docs at [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube) or [IBM Bluemix Container Service](https://console.ng.bluemix.net/docs/containers/cs_troubleshoot.html#cs_troubleshoot).
80-
81-
##### 1.1 Use PostgreSQL in container
77+
To verify installation of Helm in your cluster:
8278

83-
If you are using a container image to run PostgreSQL, run the following commands or run the quickstart script `./scripts/quickstart.sh` with your Kubernetes cluster.
79+
```
80+
$ helm version
8481
85-
```bash
86-
$ kubectl create -f kubernetes/local-volumes.yaml
87-
$ kubectl create -f kubernetes/postgres.yaml
88-
$ kubectl create -f kubernetes/redis.yaml
89-
$ kubectl create -f kubernetes/gitlab.yaml
82+
Client: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}
83+
Server: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}
9084
```
9185

92-
After you have created all the services and deployments, wait for 3 to 5 minutes. You can check the status of your deployment on Kubernetes UI. Run `kubectl proxy` and go to URL 'http://127.0.0.1:8001/ui' to check when the GitLab container becomes ready.
86+
> For more info in installing helm, you can find the official documentation [here](https://docs.helm.sh/using_helm/#installing-helm).
9387
94-
![Kubernetes Status Page](images/kube_ui.png)
88+
### 4. Configure GitLab and Install
9589

96-
Next [retrieve your external ip and port for GitLab](#2-retrieve-external-ip-and-port-for-GitLab)
90+
You can find the official helm chart repo for Cloud Native GitLab deployment [here](https://gitlab.com/charts/gitlab). This can guide you in configuring your own deployment for production use.
9791

98-
##### 1.2 Use PostgreSQL from Bluemix
92+
A sample configuration `config.yaml` in this repo can helm you get started with GitLab in IKS. This yaml file is configured to use the provided ingress controller with IKS. The components (Gitaly, Postgres, Redis, Minio) will not use any persistent storage for now.
9993

100-
Use the Bluemix catalog or the `bx` command to create a service instance of Compose for PostgreSQL and add a set of credentials.
94+
Modify `config.yaml` file to use your own Ingress Subdomain, certificate, and IP.
10195

102-
```bash
103-
$ bx service create compose-for-postgresql Standard "Compose for PostgreSQL-GL"
104-
$ bx service key-create "Compose for PostgreSQL-GL" Credentials-1
10596
```
97+
$ bx cs cluster-get <CLUSTER_NAME>
10698
107-
Retrieve the connection string from the credentials object for the service on Bluemix.
108-
109-
```bash
110-
$ bx service key-show "Compose for PostgreSQL-GL" "Credentials-1" | grep "postgres:"
99+
## You should look for these values
100+
## ...
101+
## Ingress Subdomain: anthony-dev.us-south.containers.appdomain.cloud
102+
## Ingress Secret: anthony-dev
103+
## ...
111104
```
112105

113-
![Postgres Connection String example](images/pg_credentials.png)
114-
115-
Modify your ```kubernetes/gitlab-postgres-svc.yaml``` file and replace `COMPOSE_PG_PASSWORD` with the password, `COMPOSE_PG_HOST` with the hostname, and `COMPOSE_PG_PORT` with the port.
106+
To get the ALB (Application Load Balancer) IP address of your cluster:
116107

117-
Using the above example, the ```env:``` section will look like this.
118-
119-
```yaml
120-
env:
121-
- name: GITLAB_OMNIBUS_CONFIG
122-
value: |
123-
postgresql['enable'] = false
124-
gitlab_rails['db_username'] = "admin"
125-
gitlab_rails['db_password'] = "ETIDRKCGOEIGBMZA"
126-
gitlab_rails['db_host'] = "bluemix-sandbox-dal-9-portal.6.dblayer.com"
127-
gitlab_rails['db_port'] = "26576"
128-
gitlab_rails['db_database'] = "compose"
129-
gitlab_rails['db_adapter'] = 'postgresql'
130-
gitlab_rails['db_encoding'] = 'utf8'
131-
redis['enable'] = false
132-
gitlab_rails['redis_host'] = 'redis'
133-
gitlab_rails['redis_port'] = '6379'
134-
gitlab_rails['gitlab_shell_ssh_port'] = 30022
135-
external_url 'http://gitlab.example.com:30080'
108+
```
109+
$ bx cs albs --cluster <CLUSTER_NAME>
136110
111+
## Get the IP Address from the public ALB
112+
## ALB ID Enabled Status Type ALB IP Zone
113+
## private-...-alb1 false disabled private - -
114+
## public-...-alb1 true enabled public 169.XX.XX.XX dal13
137115
```
138116

117+
You can now fill in your own values of `INGERSS_SUBDOMAIN`, `INGRESS_SECRET`, and `ALB_IP` in `config.yaml`
139118

140-
Run the following commands or run the quickstart script `./scripts/quickstart-postgres-svc.sh` with your Kubernetes cluster.
119+
Install GitLab by doing:
141120

142-
```bash
143-
$ kubectl create -f kubernetes/local-volumes.yaml
144-
$ kubectl create -f kubernetes/redis.yaml
145-
$ kubectl create -f kubernetes/gitlab-postgres-svc.yaml
121+
```
122+
$ helm upgrade --install gitlab gitlab/gitlab -f config.yaml
146123
```
147124

148-
After you have created all the services and deployments, wait for 3 to 5 minutes. You can check the status of your deployment on Kubernetes UI. Run `kubectl proxy` and go to URL 'http://127.0.0.1:8001/ui' to check when the GitLab container becomes ready.
149-
150-
![Kubernetes Status Page](images/kube_ui_gr.png)
151-
152-
### 2. Retrieve external ip and port for GitLab
125+
### 5. Launch GitLab
153126

154-
After few minutes run the following commands to get your public IP and NodePort number.
127+
Installing GitLab can take minutes to setup. You can check the status of your deployment:
155128

156-
```bash
157-
$ $ bx cs workers <cluster_name>
158-
OK
159-
ID Public IP Private IP Machine Type State Status
160-
kube-hou02-pa817264f1244245d38c4de72fffd527ca-w1 169.47.241.22 10.10.10.148 free normal Ready
161-
$ kubectl get svc gitlab
162-
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
163-
gitlab 10.10.10.148 <nodes> 80:30080/TCP,22:30022/TCP 2s
129+
```
130+
$ kubectl get pods
131+
132+
NAME READY STATUS RESTARTS AGE
133+
gitlab-gitaly-0 1/1 Running 0 3m
134+
gitlab-gitlab-runner-7554ff7c9d-2rt7x 0/1 Running 4 3m
135+
gitlab-gitlab-shell-78b8677b59-9z9m2 1/1 Running 0 3m
136+
gitlab-gitlab-shell-78b8677b59-hssqc 1/1 Running 0 2m
137+
gitlab-migrations.1-74xqt 0/1 Completed 0 3m
138+
gitlab-minio-7b67585cf5-tc4gh 1/1 Running 0 3m
139+
gitlab-minio-create-buckets.1-bdbhk 0/1 Completed 0 3m
140+
gitlab-postgresql-7756f9c75f-pzvlj 1/1 Running 0 3m
141+
gitlab-redis-554dc46b4c-jlkps 2/2 Running 0 3m
142+
gitlab-registry-75cdd8cc6d-n6fx6 1/1 Running 0 2m
143+
gitlab-registry-75cdd8cc6d-nz9sq 1/1 Running 0 3m
144+
gitlab-sidekiq-all-in-1-5865f7f999-wvg6c 1/1 Running 0 3m
145+
gitlab-task-runner-d84b7b9b9-9mc9k 1/1 Running 0 3m
146+
gitlab-unicorn-596cbf98cc-kqrsr 2/2 Running 0 3m
147+
gitlab-unicorn-596cbf98cc-mjbtn 2/2 Running 0 2m
164148
```
165149

166-
> Note: The `30080` port is for gitlab UI and the `30022` port is for ssh.
167-
168-
> Note: The gitlab external url is set to `gitlab.example.com` add this to your hosts file pointing to your IP address from above in order to use the url that gitlab expects. If you can't do this, then using the IP (in this example `169.47.241.22`) should work.
169-
170-
> Note: If you using Minikube for local kubernetes deployment, you can access the list of service IPs using the `minikube service list` command.
150+
If all your pods are now running, you can now go to your GitLab installation by visiting `https://gitlab.<INGRESS_SUBDOMAIN>`
171151

172-
Congratulations. Now you can use the link [http://gitlab.example.com:30080](http://gitlab.example.com:30080) or http://<node_ip>:30080 to access your gitlab service from your web browser.
152+
Now that Gitlab is running you can [register as a new user and create a project](docs/using-gitlab.md).
173153

174-
### 3. GitLab is ready! Use GitLab to host your repositories
154+
To try GitLab with persistent storage, you can explore `config-persistent.yaml` and use that instead of `config.yaml`. This will use dynamic storage provisioning that's provided with IKS.
175155

176-
Now that Gitlab is running you can [register as a new user and create a project](docs/using-gitlab.md).
156+
You can learn how to expose the port `22` [here](docs/ssh-port-ingress.md) with the ingress controller to clone repositories using SSH.
177157

178-
### Troubleshooting
158+
# Troubleshooting
179159

180160
If a pod doesn't start examine the logs.
181161
```bash
182162
kubectl get pods
183163
kubectl logs <pod name>
184164
```
185165

186-
### Cleanup
187-
188-
To delete all your services, deployments, and persistent volume claim, run
189-
190-
```bash
191-
kubectl delete deployment,service,pvc -l app=gitlab
192-
```
193-
194-
To delete your persistent volume, run
195-
196-
```bash
197-
kubectl delete pv local-volume-1 local-volume-2 local-volume-3
198-
```
166+
# Cleanup
199167

200-
To delete your PostgreSQL credentials and remove the service instance from Bluemix, run
168+
To delete your GitLab installation:
201169

202170
```bash
203-
bx service key-delete "Compose for PostgreSQL-GL" Credentials-1
204-
bx service delete "Compose for PostgreSQL-GL"
171+
$ helm delete gitlab --purge
205172
```
206173

207174
# License

config-persistent.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
# note: this is using a forked repo of
3+
# the gitlab chart for minio security context
4+
# https://gitlab.com/AnthonyAmanse/gitlab
5+
global:
6+
hosts:
7+
domain: <INGRESS_SUBDOMAIN>
8+
externalIP: <ALB_IP>
9+
ingress:
10+
configureCertmanager: false
11+
tls:
12+
secretName: <INGRESS_SECRET>
13+
class: ""
14+
annotations:
15+
ingress.bluemix.net/client-max-body-size: size=0
16+
edition: ce
17+
18+
gitlab:
19+
gitaly:
20+
persistence:
21+
size: 20Gi
22+
storageClass: ibmc-file-gold
23+
securityContext:
24+
runAsUser: 0
25+
26+
postgresql:
27+
persistence:
28+
size: 20Gi
29+
storageClass: ibmc-file-gold
30+
securityContext:
31+
runAsUser: 0
32+
metrics:
33+
enabled: false
34+
35+
minio:
36+
persistence:
37+
size: 20Gi
38+
storageClass: ibmc-file-gold
39+
securityContext:
40+
runAsUser: 0
41+
42+
redis:
43+
persistence:
44+
size: 20Gi
45+
storageClass: ibmc-file-gold
46+
securityContext:
47+
runAsUser: 0
48+
49+
certmanager:
50+
install: false
51+
52+
nginx-ingress:
53+
enabled: false
54+
55+
prometheus:
56+
install: false

config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
global:
3+
hosts:
4+
domain: <INGRESS_SUBDOMAIN>
5+
externalIP: <ALB_IP>
6+
ingress:
7+
configureCertmanager: false
8+
tls:
9+
secretName: <INGRESS_SECRET>
10+
class: ""
11+
annotations:
12+
ingress.bluemix.net/client-max-body-size: size=0
13+
edition: ce
14+
15+
gitlab:
16+
gitaly:
17+
persistence:
18+
enabled: false
19+
20+
postgresql:
21+
persistence:
22+
enabled: false
23+
metrics:
24+
enabled: false
25+
26+
minio:
27+
persistence:
28+
enabled: false
29+
30+
redis:
31+
persistence:
32+
enabled: false
33+
34+
certmanager:
35+
install: false
36+
37+
nginx-ingress:
38+
enabled: false
39+
40+
prometheus:
41+
install: false

0 commit comments

Comments
 (0)