Skip to content

Commit

Permalink
Merge pull request #6 from m3-learning/kube-deploy
Browse files Browse the repository at this point in the history
Kube deploy
  • Loading branch information
jagar2 authored May 21, 2024
2 parents 2bbd0c2 + ae15a87 commit e07b698
Show file tree
Hide file tree
Showing 92 changed files with 17,256 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ jobs:
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: pages/pages/_build/html
publish_dir: pages/pages/_build/html

- name: pre-commit
uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ cython_debug/
.DS_STORE

# Ignore all Builds
_build
_build
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# K8_senior_design
# K8_senior_design

## Pre Commit
This project utilizes pre-commit which ensures proper formatting convention.

Initialize pre-commit:
```
pip install pre-commit
```

Install and run pre-commit on all files
```
pre-commit install
pre-commit run --all-files
```

Stage and Apply pre-commit changes
```
git add .
git commit -m "Lint files with pre-commit"
```
59 changes: 59 additions & 0 deletions cloudlab/gitlab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Gitlab install guide
The purpose of this project is to spinup a gitlab service for kubernetes utilizing local storage provisioners

## Disclaimer
The installation procedure gives you a sample-working production environment for GitLab. For best practices, please ensure that proper methods are used to secure each service. For any values specified in the configurations, they can be modified to the operator's specs.

## Dependencies
* GitLab Helm chart dependency
* Postgresql Helm chart dependency
* Redis Helm chart dependency
* Paths specified in volume should be satisfied across hosts

## Order of install operation
Production environments specified on GitLab

## Install Prerequiste
You must satisfy the `storage-class` requirements that may not be created already. To do this, supply the following command:
```
kubectl apply -f storage.yml
```

Then you must allocate volumes required for postgresql:
```
kubectl apply -f postgresql-volume.yml
```

Force patch the claim to the volume:
```
kubectl patch pvc data-my-postgresql-0 -p '{"spec":{"volumeName":"example-pv"}}'
```

This creates the storageclass necessary for the GitLab cluster and dependency services to use. Then, proceed to create the postgresql PVC. This is required since automated bounding does not happen for non-dynamic provisioners:
```
kubectl apply -f patch-postgresql-pvc-claim.yml
```

Now, postgresql can be deployed with the values.yml file supplied. First, the configurations are set such that it does not allow any dynamic provisioners to be set by default. This is shown for entries that consist of `"-"`. Then, postgresql is forced to use the `local-storage` storage class that was previously deployed in `storage.yml`. The most important variable set is that `persistance.existingClaim` is set to the volume claim set earlier. This can be applied by:
```
helm install postgresql bitnami/postgresql -f postgresql-values.yml
```

The next dependency required is redis, which similar to the previous deployment of postgresql, can be done. Note, the claim must be created for redis, and the `persistance.existingClaim` must also be set alongside disabling any dynamic provisioners. This is already supplied within the `patch-redis-pvc-claim.yml`. The following can be used to spin up a redis service:
```
kubectl apply -f redis-storage.yml
kubectl apply -f redis-volume.yml
kubectl apply -f redis-pvc-claim.yml
kubectl patch pvc data-my-redis-0 -p '{"spec":{"volumeName":"example-pv-redis"}}'
helm install redis bitnami/redis -f redis-values.yml
```

Now, we have setup the required dependencies for a bare minimum for a production-ready environment for GitLab.

## Prerequisite installs for GitLab
Patch the core storage class for GitLab
```
kubectl patch storageclass CUSTOM_STORAGE_CLASS_NAME -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
```

Create persistence storageclass, volumes, and claims for Gitaly, MinIO, and Redis
11 changes: 11 additions & 0 deletions cloudlab/gitlab/gitaly/gitaly-pvc-claim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-my-gitaly-0
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage-gitaly # Add your storage class if not specified
resources:
requests:
storage: 100Gi # Adjust the storage capacity as needed
6 changes: 6 additions & 0 deletions cloudlab/gitlab/gitaly/gitaly-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage-gitaly
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
24 changes: 24 additions & 0 deletions cloudlab/gitlab/gitaly/gitaly-volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv-gitaly
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage-gitaly
local:
path: /mnt/disks/ssd3
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1
- node2
- node3
11 changes: 11 additions & 0 deletions cloudlab/gitlab/gitlab-toolbox/gitlab-toolbox-pvc-claim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-my-gitlab-toolbox-0
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage-gitlab-toolbox # Add your storage class if not specified
resources:
requests:
storage: 100Gi # Adjust the storage capacity as needed
6 changes: 6 additions & 0 deletions cloudlab/gitlab/gitlab-toolbox/gitlab-toolbox-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage-gitlab-toolbox
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
24 changes: 24 additions & 0 deletions cloudlab/gitlab/gitlab-toolbox/gitlab-toolbox-volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv-gitlab-toolbox
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage-gitlab-toolbox
local:
path: /mnt/disks/ssd6
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1
- node2
- node3
11 changes: 11 additions & 0 deletions cloudlab/gitlab/gitlab/gitlab-pvc-claim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-my-gitlab-0
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage-gitlab # Add your storage class if not specified
resources:
requests:
storage: 100Gi # Adjust the storage capacity as needed
6 changes: 6 additions & 0 deletions cloudlab/gitlab/gitlab/gitlab-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage-gitlab
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
43 changes: 43 additions & 0 deletions cloudlab/gitlab/gitlab/gitlab-values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
global:
edition: ee
gitlab:
psql:
host:
password:
key:
secret:
redis:
host:
auth:
secret:
key:
hosts:
domain: example.com
externalIP:

redis:
install: false

postgresql:
install: false

certmanager-issuer:
email: [email protected]

minio:
persistence:
storageClass:
volumeName:

gitlab:
toolbox:
persistence:
storageClass:
volumeName:
backups:
cron:
enabled: true
gitaly:
persistence:
storageClass:
volumeName:
24 changes: 24 additions & 0 deletions cloudlab/gitlab/gitlab/gitlab-volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv-gitlab
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage-gitlab
local:
path: /mnt/disks/ssd6
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1
- node2
- node3
11 changes: 11 additions & 0 deletions cloudlab/gitlab/minio/minio-pvc-claim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-my-minio-0
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage-minio # Add your storage class if not specified
resources:
requests:
storage: 100Gi # Adjust the storage capacity as needed
6 changes: 6 additions & 0 deletions cloudlab/gitlab/minio/minio-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage-minio
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
24 changes: 24 additions & 0 deletions cloudlab/gitlab/minio/minio-volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv-minio
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage-minio
local:
path: /mnt/disks/ssd4
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1
- node2
- node3
11 changes: 11 additions & 0 deletions cloudlab/gitlab/postgresql/postgresql-pvc-claim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-my-postgresql-0
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage # Add your storage class if not specified
resources:
requests:
storage: 100Gi # Adjust the storage capacity as needed
6 changes: 6 additions & 0 deletions cloudlab/gitlab/postgresql/postgresql-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
Loading

0 comments on commit e07b698

Please sign in to comment.