Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm migration #32

Merged
merged 58 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bcdafda
helm create
Flagro Feb 8, 2024
7d16853
Add release message input to release workflow
Flagro Feb 12, 2024
27abffa
Rename github actions workflows
Flagro Feb 13, 2024
b8bf489
Rename docker compose files
Flagro Feb 13, 2024
ba3cab3
Rename k8s yaml files
Flagro Feb 13, 2024
b5dc76c
Move old k8s yaml to helm templates
Flagro Feb 13, 2024
1b2861a
Update database container image to use latest version
Flagro Feb 13, 2024
d27a80e
Initialize values helm config
Flagro Feb 13, 2024
1bcd10c
Remove empty line at end of file in values.yaml
Flagro Feb 13, 2024
3e7e450
Flatten the helm templates
Flagro Feb 13, 2024
b510ea7
Helmify yaml templates
Flagro Feb 13, 2024
9cebb8e
Add Dmitry Trofumushkin as a copyright holder in LICENSE
Flagro Feb 15, 2024
6719b70
Fix order in db config
Flagro Mar 2, 2024
c1f70c7
Add .yamllint configuration file
Flagro Mar 2, 2024
f714dc8
Fix order and indents in db deployment
Flagro Mar 2, 2024
729381c
Fix order in db_deployment
Flagro Mar 2, 2024
a992c70
Fix indentations
Flagro Mar 2, 2024
19e2f89
Fix identations and order in db_pv
Flagro Mar 2, 2024
b73e18f
Fix order and indents in db_pvc
Flagro Mar 2, 2024
5adf6b5
Fix indentation in db_service.yaml
Flagro Mar 2, 2024
ac46d23
Refactor ingress.yaml to update paths and add TLS configuration
Flagro Mar 2, 2024
bf04221
Fix indentation in static_config.yaml
Flagro Mar 2, 2024
2aa3c7a
Refactor static_deployment.yaml file
Flagro Mar 2, 2024
03e7f9b
Fix indentation in static_service.yaml
Flagro Mar 2, 2024
39001f0
Fix indentation in web_config.yaml
Flagro Mar 2, 2024
384a80f
Refactor web_deployment.yaml file structure
Flagro Mar 2, 2024
ab1db51
Fix indentation and access mode in web_pv.yaml
Flagro Mar 2, 2024
9bac0ed
Fix indentation in web_pvc.yaml
Flagro Mar 2, 2024
3252290
Fix indentation in web_service.yaml
Flagro Mar 2, 2024
75226eb
Fix indentation in db_config.yaml
Flagro Mar 2, 2024
ca2620e
Update path for db_pv.yaml file
Flagro Mar 2, 2024
3fa049f
Refactor ingress.yaml to update paths and backend services
Flagro Mar 2, 2024
a864277
Update environment variables in web_deployment.yaml
Flagro Mar 2, 2024
a75d7ba
Update path in web_pv.yaml file
Flagro Mar 2, 2024
ecb18ed
Update storage and access modes for PV and PVC
Flagro Mar 2, 2024
b68c258
Update hostPath in db_pv.yaml and web_pv.yaml
Flagro Mar 2, 2024
3c8a3b0
Update storage and reclaim policies for PVs
Flagro Mar 2, 2024
05d9011
Fix indentation in staticService ports definition
Flagro Mar 2, 2024
fa09795
Standartize the ports in kubernetes configs
Flagro Mar 2, 2024
5e9f30c
Standartize the persistent volume variables
Flagro Mar 2, 2024
3fc45d2
Update static_service.yaml and values.yaml
Flagro Mar 2, 2024
10072b3
Update nginx configuration to serve static files
Flagro Mar 2, 2024
9a1daf0
Update db_service.yaml and values.yaml
Flagro Mar 2, 2024
da1dc7a
Update web_service.yaml and values.yaml
Flagro Mar 2, 2024
4603717
Refactor backendDeployment args in values.yaml
Flagro Mar 2, 2024
b10dee8
Fix POSTGRES_NAME value in db_config.yaml
Flagro Mar 2, 2024
a2538b1
Fix port order in service templates
Flagro Mar 2, 2024
1680378
Update ingress host in helm templates and values.yaml
Flagro Mar 2, 2024
edde610
Update database configuration and remove unused code
Flagro Mar 2, 2024
a48f419
Merge pull request #35 from Flagro/helmify_templates
Flagro Mar 2, 2024
c307b24
Add configuration files and services for web, database, static, and i…
Flagro Mar 2, 2024
fe284a7
Add Helm templates for web, db, and static components
Flagro Mar 2, 2024
685e85b
Update secrets and labels in Helm templates
Flagro Mar 2, 2024
de98294
Add Kubernetes cluster domain and update ingress host***
Flagro Mar 2, 2024
6725f4d
Update deployment script to use Helm for Kubernetes deployment
Flagro Mar 2, 2024
1e78fa8
Add namespace creation step in deploy workflow
Flagro Mar 2, 2024
a05aa5e
Update deployment workflow to use Helm for deployment
Flagro Mar 2, 2024
09ce57e
Merge branch 'main' into helm_migration
Flagro Mar 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 25 additions & 32 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,20 @@ jobs:
with:
kubeconfig: ${{ secrets.KUBE_CONFIG }}

- name: Create and Apply Kubernetes Secrets
- name: Create Namespace (if not exists)
run: |
kubectl get ns phrinifluent || kubectl create ns phrinifluent

- name: Set up Helm
uses: azure/setup-helm@v1

# - name: Add Helm repository
# run: helm repo add myrepo https://mychartrepo.com/charts

# - name: Update Helm repositories
# run: helm repo update

- name: Deploy with Helm
env:
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
Expand All @@ -43,34 +56,14 @@ jobs:
SSL_CERTIFICATE: ${{ secrets.SSL_CERTIFICATE }}
SSL_KEY: ${{ secrets.SSL_KEY }}
run: |
kubectl create secret generic phrinifluent-db-secrets \
--from-literal=POSTGRES_USER="$DB_USER" \
--from-literal=POSTGRES_PASSWORD="$DB_PASSWORD" \
--from-literal=POSTGRES_DB="$DB_NAME" \
-o yaml --dry-run=client | kubectl apply -f -
kubectl create secret generic phrinifluent-backend-secrets \
--from-literal=SECRET_KEY="$SECRET_KEY" \
--from-literal=ADMIN_USERNAME="$ADMIN_USERNAME" \
--from-literal=ADMIN_EMAIL="$ADMIN_EMAIL" \
--from-literal=ADMIN_PASSWORD="$ADMIN_PASSWORD" \
--from-literal=SSL_CERTIFICATE="$SSL_CERTIFICATE" \
--from-literal=SSL_KEY="$SSL_KEY" \
-o yaml --dry-run=client | kubectl apply -f -
echo "$SSL_CERTIFICATE" > cert.pem
echo "$SSL_KEY" > key.pem
kubectl create secret tls phrinifluent-tls-secrets \
--cert=cert.pem \
--key=key.pem \
-o yaml --dry-run=client | kubectl apply -f -

- name: Update image tags in Kubernetes manifests
run: |
TAG="${{ steps.latest_tag.outputs.tag }}"
sed -i "s|flagro/phrinifluent_web:latest|flagro/phrinifluent_web:$TAG|g" ./k8s/web/deployment.yml

- name: Deploy to Kubernetes
run: |
kubectl apply -f ./k8s/db/
kubectl apply -f ./k8s/ingress/
kubectl apply -f ./k8s/web/
kubectl apply -f ./k8s/static/
helm upgrade --install ${{ steps.latest_tag.outputs.tag }} ./helm \
--namespace phrinifluent \
--set image.tag=${{ steps.latest_tag.outputs.tag }} \
--set dbSecrets.user=${{ secrets.DB_USER }} \
--set dbSecrets.password=${{ secrets.DB_PASSWORD }} \
--set backendSecrets.secretKey=${{ secrets.SECRET_KEY }} \
--set backendSecrets.adminUsername=${{ secrets.ADMIN_USERNAME }} \
--set backendSecrets.adminEmail=${{ secrets.ADMIN_EMAIL }} \
--set backendSecrets.adminPassword=${{ secrets.ADMIN_PASSWORD }} \
--set-file tlsSecrets.certFile=<(echo "${{ secrets.SSL_CERTIFICATE }}") \
--set-file tlsSecrets.keyFile=<(echo "${{ secrets.SSL_KEY }}")
23 changes: 23 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: helm
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
62 changes: 62 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "flatchart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "flatchart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "flatchart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "flatchart.labels" -}}
helm.sh/chart: {{ include "flatchart.chart" . }}
{{ include "flatchart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "flatchart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "flatchart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "flatchart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "flatchart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions helm/templates/db/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "flatchart.fullname" . }}-db-config
labels:
{{- include "flatchart.labels" . | nindent 4 }}
data:
POSTGRES_NAME: "postgres"
POSTGRES_HOST: "{{ include "flatchart.fullname" . }}-db-service"
POSTGRES_PORT: "5432"
39 changes: 39 additions & 0 deletions helm/templates/db/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "flatchart.fullname" . }}-db-deployment
labels:
{{- include "flatchart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.dbDeployment.replicas }}
selector:
matchLabels:
app: phrinifluent-db
{{- include "flatchart.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: phrinifluent-db
{{- include "flatchart.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: phrinifluent-db
image: {{ .Values.dbDeployment.phrinifluentDb.image.repository }}:{{ .Values.dbDeployment.phrinifluentDb.image.tag | default .Chart.AppVersion }}
ports:
- containerPort: 5432
envFrom:
- secretRef:
name: {{ include "flatchart.fullname" . }}-db-secrets
- configMapRef:
name: {{ include "flatchart.fullname" . }}-db-config
- env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
resources: {}
volumeMounts:
- name: phrinifluent-db-storage
mountPath: /var/lib/postgresql/data
volumes:
- name: phrinifluent-db-storage
persistentVolumeClaim:
claimName: {{ include "flatchart.fullname" . }}-db-pvc
15 changes: 15 additions & 0 deletions helm/templates/db/pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ include "flatchart.fullname" . }}-db-pv
labels:
{{- include "flatchart.labels" . | nindent 4 }}
spec:
capacity:
storage: {{ .Values.pv.dbPv.storageRequest }}
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: standard
hostPath:
path: {{ .Values.pv.dbPv.hostPath | quote }}
13 changes: 13 additions & 0 deletions helm/templates/db/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "flatchart.fullname" . }}-db-pvc
labels:
{{- include "flatchart.labels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.pvc.dbPvc.storageRequest | quote }}
storageClassName: standard
11 changes: 11 additions & 0 deletions helm/templates/db/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "flatchart.fullname" . }}-db-secrets
labels:
{{- include "flatchart.labels" . | nindent 4 }}
type: Opaque
data:
POSTGRES_USER: {{ .Values.dbSecrets.user | b64enc | quote }}
POSTGRES_PASSWORD: {{ .Values.dbSecrets.password | b64enc | quote }}
POSTGRES_DB: {{ .Values.dbSecrets.dbName | b64enc | quote }}
15 changes: 15 additions & 0 deletions helm/templates/db/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "flatchart.fullname" . }}-db-service
labels:
{{- include "flatchart.labels" . | nindent 4 }}
spec:
type: ClusterIP
selector:
app: phrinifluent-db
{{- include "flatchart.selectorLabels" . | nindent 4 }}
ports:
- protocol: TCP
port: 5432
targetPort: 5432
29 changes: 29 additions & 0 deletions helm/templates/ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "flatchart.fullname" . }}-ingress
labels:
{{- include "flatchart.labels" . | nindent 4 }}
spec:
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /static
pathType: Prefix
backend:
service:
name: '{{ include "flatchart.fullname" . }}-static-service'
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: '{{ include "flatchart.fullname" . }}-backend-service'
port:
number: 80
tls:
- hosts:
- {{ .Values.ingress.host }}
secretName: {{ include "flatchart.fullname" . }}-tls-secrets
10 changes: 10 additions & 0 deletions helm/templates/ingress/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "flatchart.fullname" . }}-tls-secrets
labels:
{{- include "flatchart.labels" . | nindent 4 }}
type: kubernetes.io/tls
data:
tls.crt: {{ .Files.Get .Values.tlsSecrets.certFile | b64enc | quote }}
tls.key: {{ .Files.Get .Values.tlsSecrets.keyFile | b64enc | quote }}
16 changes: 16 additions & 0 deletions helm/templates/static/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "flatchart.fullname" . }}-nginx-config

Check failure on line 4 in helm/templates/static/config.yaml

View workflow job for this annotation

GitHub Actions / python-lint

4:11 [braces] too many spaces inside braces

Check failure on line 4 in helm/templates/static/config.yaml

View workflow job for this annotation

GitHub Actions / python-lint

4:42 [braces] too many spaces inside braces

Check failure on line 4 in helm/templates/static/config.yaml

View workflow job for this annotation

GitHub Actions / python-lint

4:45 syntax error: expected <block end>, but found '<scalar>' (syntax)
labels:
{{- include "flatchart.labels" . | nindent 4 }}
data:
default.conf: |
server {
listen 80;
server_name _;

location /static {
alias /usr/share/nginx/html/static;
}
}
40 changes: 40 additions & 0 deletions helm/templates/static/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "flatchart.fullname" . }}-nginx-deployment

Check failure on line 4 in helm/templates/static/deployment.yaml

View workflow job for this annotation

GitHub Actions / python-lint

4:11 [braces] too many spaces inside braces

Check failure on line 4 in helm/templates/static/deployment.yaml

View workflow job for this annotation

GitHub Actions / python-lint

4:42 [braces] too many spaces inside braces

Check failure on line 4 in helm/templates/static/deployment.yaml

View workflow job for this annotation

GitHub Actions / python-lint

4:45 syntax error: expected <block end>, but found '<scalar>' (syntax)
labels:
{{- include "flatchart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.nginxDeployment.replicas }}

Check failure on line 8 in helm/templates/static/deployment.yaml

View workflow job for this annotation

GitHub Actions / python-lint

8:15 [braces] too many spaces inside braces

Check failure on line 8 in helm/templates/static/deployment.yaml

View workflow job for this annotation

GitHub Actions / python-lint

8:48 [braces] too many spaces inside braces
selector:
matchLabels:
app: nginx
{{- include "flatchart.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: nginx
{{- include "flatchart.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: nginx
image: {{ .Values.nginxDeployment.nginx.image.repository }}:{{ .Values.nginxDeployment.nginx.image.tag | default .Chart.AppVersion }}

Check failure on line 21 in helm/templates/static/deployment.yaml

View workflow job for this annotation

GitHub Actions / python-lint

21:128 [line-length] line too long (143 > 127 characters)
ports:
- containerPort: 80
env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
resources: {}
volumeMounts:
- name: phrinifluent-static-storage
mountPath: /usr/share/nginx/html/static
- name: phrinifluent-nginx-config-storage
mountPath: /etc/nginx/conf.d
readOnly: true
volumes:
- name: phrinifluent-static-storage
persistentVolumeClaim:
claimName: {{ include "flatchart.fullname" . }}-static-pvc
- name: phrinifluent-nginx-config-storage
configMap:
name: {{ include "flatchart.fullname" . }}-nginx-config
Loading
Loading