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

added app-config file, api-gateway .yaml files #52

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
context: ./services/user-service
args:
- PORT=${USER_PORT}
image: ${DOCKER_USERNAME}/user-service:latest
ports:
- "${USER_PORT}:${USER_PORT}"
environment:
Expand Down Expand Up @@ -110,6 +111,7 @@ services:
- MATCHING_URL=http://matching-service
- QUESTION_URL=http://question-service
- COLLAB_URL=http://collaboration-service
image: ${DOCKER_USERNAME}/api-gateway:latest
ports:
- "${GATEWAY_PORT}:${GATEWAY_PORT}"
environment:
Expand Down
17 changes: 17 additions & 0 deletions k8/app-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
QUESTION_PORT: "3001"
USER_PORT: "3002"
MATCHING_PORT: "8080"
COLLAB_PORT: "8081"
GATEWAY_PORT: "4000"
ENV: "PROD"
REACT_APP_QUESTION_API_URL: "http://question-service:3001"
REACT_APP_USER_API_URL: "http://user-service:3002"
REACT_APP_MATCHING_API_URL: "http://matching-service:8080"
REACT_APP_COLLAB_WS_URL: "ws://collaboration-service:8081"
REACT_APP_COLLAB_API_URL: "http://collaboration-service:8081"
REACT_APP_GATEWAY_URL: "http://api-gateway:4000/api"
203 changes: 203 additions & 0 deletions k8/components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: metrics-server
name: metrics-server
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
k8s-app: metrics-server
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
name: system:aggregated-metrics-reader
rules:
- apiGroups:
- metrics.k8s.io
resources:
- pods
- nodes
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
k8s-app: metrics-server
name: system:metrics-server
rules:
- apiGroups:
- ""
resources:
- nodes/metrics
verbs:
- get
- apiGroups:
- ""
resources:
- pods
- nodes
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
k8s-app: metrics-server
name: metrics-server-auth-reader
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
name: metrics-server
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
k8s-app: metrics-server
name: metrics-server:system:auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: metrics-server
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
k8s-app: metrics-server
name: system:metrics-server
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:metrics-server
subjects:
- kind: ServiceAccount
name: metrics-server
namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: metrics-server
name: metrics-server
namespace: kube-system
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: https
selector:
k8s-app: metrics-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: metrics-server
name: metrics-server
namespace: kube-system
spec:
selector:
matchLabels:
k8s-app: metrics-server
strategy:
rollingUpdate:
maxUnavailable: 0
template:
metadata:
labels:
k8s-app: metrics-server
spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=10250
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
- --secure-port=443
- --kubelet-insecure-tls
image: registry.k8s.io/metrics-server/metrics-server:v0.7.2
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /livez
port: https
scheme: HTTPS
periodSeconds: 10
name: metrics-server
ports:
- containerPort: 10250
name: https
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /readyz
port: https
scheme: HTTPS
initialDelaySeconds: 20
periodSeconds: 10
resources:
requests:
cpu: 100m
memory: 200Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
volumeMounts:
- mountPath: /tmp
name: tmp-dir
nodeSelector:
kubernetes.io/os: linux
priorityClassName: system-cluster-critical
serviceAccountName: metrics-server
volumes:
- emptyDir: {}
name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
labels:
k8s-app: metrics-server
name: v1beta1.metrics.k8s.io
spec:
group: metrics.k8s.io
groupPriorityMinimum: 100
insecureSkipTLSVerify: true
service:
name: metrics-server
namespace: kube-system
version: v1beta1
versionPriority: 100
22 changes: 22 additions & 0 deletions k8/deployments/api-gateway-deplyoment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
spec:
replicas: 1
selector:
matchLabels:
app: api-gateway
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: wuemily/api-gateway:latest
ports:
- containerPort: 4000
envFrom:
- configMapRef:
name: app-config
6 changes: 3 additions & 3 deletions k8/deployments/collaboration-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ spec:
env:
- name: PORT
value: "8083"
- name: ENV
value: "${ENV}"

envFrom:
- configMapRef:
name: app-config
5 changes: 4 additions & 1 deletion k8/deployments/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ spec:
limits:
cpu: 500m
requests:
cpu: 200m
cpu: 200m
envFrom:
- configMapRef:
name: app-config
5 changes: 3 additions & 2 deletions k8/deployments/matching-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ spec:
value: "redis"
- name: REDIS_PORT
value: "6379"
- name: ENV
value: "${ENV}"
envFrom:
- configMapRef:
name: app-config
2 changes: 1 addition & 1 deletion k8/deployments/metrics-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: metrics-server
image: k8s.gcr.io/metrics-server/metrics-server:v0.7.2 # Check for the latest version
image: k8s.gcr.io/metrics-server/metrics-server:v0.7.2
args:
- --secure-port=443
- --metric-resolution=30s
Expand Down
9 changes: 3 additions & 6 deletions k8/deployments/question-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ spec:
env:
- name: PORT
value: "8081"
- name: DB_CLOUD_URI
value: "${QUESTION_DB_CLOUD_URI}"
- name: DB_LOCAL_URI
value: "${QUESTION_DB_LOCAL_URI}"
- name: ENV
value: "${ENV}"
envFrom:
- configMapRef:
name: app-config
3 changes: 3 additions & 0 deletions k8/deployments/user-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ spec:
env:
- name: PORT
value: "8080"
envFrom:
- configMapRef:
name: app-config
12 changes: 12 additions & 0 deletions k8/services/api-gateway-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: api-gateway
spec:
selector:
app: api-gateway-deployment
ports:
- protocol: TCP
port: 4000
targetPort: 4000
type: LoadBalancer
9 changes: 5 additions & 4 deletions k8/services/frontend-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ kind: Service
metadata:
name: frontend
spec:
type: LoadBalancer
selector:
app: frontend-service
ports:
- port: 3000
- protocol: TCP
port: 3000
targetPort: 3000
selector:
app: frontend
type: LoadBalancer