Skip to content

Commit

Permalink
Merge branch 'main' into csprclick-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Arango committed Aug 15, 2024
2 parents 5776b74 + 305cd4b commit 78a7921
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .cicd/manifests/config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{.Values.appName}}-{{.Values.envName}}-config
namespace: {{.Values.namespace}}
data:
# Database
MYSQL_USER: {{.Values.MYSQL_USER}}
MYSQL_PASSWORD: {{.Values.MYSQL_PASSWORD}}
MYSQL_PORT: {{.Values.MYSQL_PORT}}
MYSQL_HOST: {{.Values.MYSQL_HOST}}
MYSQL_TABLE: {{.Values.MYSQL_TABLE}}
MYSQL_DATABASE: {{.Values.MYSQL_DATABASE}}
# Recaptcha
RECAPTCHA_SECRET_KEY: {{.Values.RECAPTCHA_SECRET_KEY}}
# Public keys
PUBLIC_KEYS: {{.Values.PUBLIC_KEYS}}
# React
REACT_APP_BACKEND_URL: {{.Values.REACT_APP_BACKEND_URL}}
REACT_APP_BACKEND_PORT: {{.Values.REACT_APP_BACKEND_PORT}}
REACT_APP_RECAPTCHA_CLIENT_KEY: {{.Values.REACT_APP_RECAPTCHA_CLIENT_KEY}}


35 changes: 35 additions & 0 deletions .cicd/manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: {{.Values.namespace}}
name: {{.Values.appName}}-{{.Values.envName}}
labels:
app: {{.Values.appName}}-{{.Values.envName}}
exectionId: {{.Values.ExecutionId}}
spec:
replicas: {{.Values.replicaCount}}
selector:
matchLabels:
app: {{.Values.appName}}-{{.Values.envName}}
template:
metadata:
labels:
app: {{.Values.appName}}-{{.Values.envName}}
exectionId: {{.Values.ExecutionId}}
spec:
containers:
- name: {{.Values.appName}}-{{.Values.envName}}
image: {{.Values.artifactImage}}
imagePullPolicy: Always
ports:
- containerPort: {{.Values.containerPort}}
resources:
requests:
memory: {{.Values.resourceMemoryRequest}}
cpu: {{.Values.resourceCpuRequest}}
limits:
memory: {{.Values.resourceMemoryLimit}}
cpu: {{.Values.resourceCpuLimit}}
envFrom:
- configMapRef:
name: {{.Values.appName}}-{{.Values.envName}}-config
33 changes: 33 additions & 0 deletions .cicd/manifests/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.ingressDomainName}}

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: {{.Values.namespace}}
name: {{.Values.appName}}-{{.Values.envName}}-ingress
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-origin: {{.Values.CorsOrigin}}
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"
nginx.ingress.kubernetes.io/cors-expose-headers: "Content-Length,Content-Range"
spec:
tls:
- hosts:
- {{.Values.ingressDomainName}}
secretName: {{.Values.appName}}-{{.Values.envName}}-tls
rules:
- host: {{.Values.ingressDomainName}}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{.Values.appName}}-{{.Values.envName}}-svc
port:
number: {{.Values.servicePort}}
ingressClassName: nginx

{{- end}}
5 changes: 5 additions & 0 deletions .cicd/manifests/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{.Values.namespace}}

15 changes: 15 additions & 0 deletions .cicd/manifests/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
namespace: {{.Values.namespace}}
name: {{.Values.appName}}-{{.Values.envName}}-svc
labels:
app: {{.Values.appName}}-{{.Values.envName}}
spec:
type: ClusterIP
ports:
- protocol: TCP
port: {{.Values.servicePort}}
targetPort: {{.Values.containerPort}}
selector:
app: {{.Values.appName}}-{{.Values.envName}}
29 changes: 29 additions & 0 deletions .cicd/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# K8S / Harness
envName: <+env.name>
appName: <+service.name>
artifactImage: <+artifact.image> #from Harness Service Primary Artifact
containerPort: <+serviceVariables.containerPort>
servicePort: 80
namespace: <+service.name>-<+env.name>
ingressDomainName: <+serviceVariables.ingressDomainName>
CorsOrigin: <+serviceVariables.CorsOrigin>
ExecutionId: <+pipeline.executionId>

# Database
MYSQL_USER: <+serviceVariables.MYSQL_USER>
MYSQL_PASSWORD: <+serviceVariables.MYSQL_PASSWORD>
MYSQL_PORT: <+serviceVariables.MYSQL_PORT>
MYSQL_HOST: <+serviceVariables.MYSQL_HOST>
MYSQL_TABLE: <+serviceVariables.MYSQL_TABLE>
MYSQL_DATABASE: <+serviceVariables.MYSQL_DATABASE>

# Recaptcha
RECAPTCHA_SECRET_KEY: <+serviceVariables.RECAPTCHA_SECRET_KEY>

# Public keys
PUBLIC_KEYS: <+serviceVariables.PUBLIC_KEYS>

# React
REACT_APP_BACKEND_URL: <+serviceVariables.REACT_APP_BACKEND_URL>
REACT_APP_BACKEND_PORT: <+serviceVariables.REACT_APP_BACKEND_PORT>
REACT_APP_RECAPTCHA_CLIENT_KEY: <+serviceVariables.REACT_APP_RECAPTCHA_CLIENT_KEY>
9 changes: 9 additions & 0 deletions .cicd/values/prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deployment
replicaCount: 3

# Pod
resourceCpuRequest: 300m
resourceCpuLimit: 1

resourceMemoryRequest: 800Mi
resourceMemoryLimit: 4Gi
9 changes: 9 additions & 0 deletions .cicd/values/staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deployment
replicaCount: 1

# Pod
resourceCpuRequest: 100m
resourceCpuLimit: 1

resourceMemoryRequest: 800Mi
resourceMemoryLimit: 4Gi
11 changes: 10 additions & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ WORKDIR /app

COPY package*.json ./

ARG REACT_APP_RECAPTCHA_CLIENT_KEY
ENV REACT_APP_RECAPTCHA_CLIENT_KEY=$REACT_APP_RECAPTCHA_CLIENT_KEY

ARG REACT_APP_BACKEND_URL
ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL

ARG REACT_APP_BACKEND_PORT
ENV REACT_APP_BACKEND_PORT=$REACT_APP_BACKEND_PORT

RUN npm install

COPY . .
Expand All @@ -16,4 +25,4 @@ COPY --from=0 /app/build /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit 78a7921

Please sign in to comment.