From e13a05cb4349672e110199ede5c821892e6b1b38 Mon Sep 17 00:00:00 2001 From: dongli Date: Mon, 17 Feb 2025 18:03:17 -0800 Subject: [PATCH] Add k8s configuration files for service-hub --- sites/authentication/deploy/k8s/alpha.yaml | 38 +++++++++++++++++++++ sites/authentication/deploy/k8s/prod.yaml | 38 +++++++++++++++++++++ sites/authentication/deploy/k8s/readme.md | 11 ++++++ sites/central_storage/deploy/k8s/alpha.yaml | 38 +++++++++++++++++++++ sites/central_storage/deploy/k8s/prod.yaml | 38 +++++++++++++++++++++ sites/central_storage/deploy/k8s/readme.md | 11 ++++++ sites/content/deploy/k8s/alpha.yaml | 38 +++++++++++++++++++++ sites/content/deploy/k8s/prod.yaml | 38 +++++++++++++++++++++ sites/content/deploy/k8s/readme.md | 11 ++++++ sites/notification/deploy/k8s/alpha.yaml | 38 +++++++++++++++++++++ sites/notification/deploy/k8s/prod.yaml | 38 +++++++++++++++++++++ sites/notification/deploy/k8s/readme.md | 11 ++++++ sites/payment/deploy/k8s/alpha.yaml | 3 +- sites/payment/deploy/k8s/prod.yaml | 1 + 14 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 sites/authentication/deploy/k8s/alpha.yaml create mode 100644 sites/authentication/deploy/k8s/prod.yaml create mode 100644 sites/authentication/deploy/k8s/readme.md create mode 100644 sites/central_storage/deploy/k8s/alpha.yaml create mode 100644 sites/central_storage/deploy/k8s/prod.yaml create mode 100644 sites/central_storage/deploy/k8s/readme.md create mode 100644 sites/content/deploy/k8s/alpha.yaml create mode 100644 sites/content/deploy/k8s/prod.yaml create mode 100644 sites/content/deploy/k8s/readme.md create mode 100644 sites/notification/deploy/k8s/alpha.yaml create mode 100644 sites/notification/deploy/k8s/prod.yaml create mode 100644 sites/notification/deploy/k8s/readme.md diff --git a/sites/authentication/deploy/k8s/alpha.yaml b/sites/authentication/deploy/k8s/alpha.yaml new file mode 100644 index 0000000..01d8067 --- /dev/null +++ b/sites/authentication/deploy/k8s/alpha.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: authentication + ENVIRONMENT: alpha + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://mongodb-service.freeleaps-alpha.svc.cluster.local:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 50 + timeoutSeconds: 125 + periodSeconds: 125 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/authentication/deploy/k8s/prod.yaml b/sites/authentication/deploy/k8s/prod.yaml new file mode 100644 index 0000000..15e0560 --- /dev/null +++ b/sites/authentication/deploy/k8s/prod.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: authentication + ENVIRONMENT: prod + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://freeleaps2-mongodb:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 60 + timeoutSeconds: 120 + periodSeconds: 30 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/authentication/deploy/k8s/readme.md b/sites/authentication/deploy/k8s/readme.md new file mode 100644 index 0000000..868b410 --- /dev/null +++ b/sites/authentication/deploy/k8s/readme.md @@ -0,0 +1,11 @@ +- K8s namespace should be the same as the code repository name(project name), e.g. **freeleaps-service-hub** + - All apps within the repository should be deployed under the same namespace +- For each app, the K8s pod name must be the same as appEnv.APP_NAME +- When loading deployment yaml file under k8s folder (alpha.yaml, prod.yaml): + - Replace the secret values that are in format of {SECRET_NAME}, e.g. **{STRIPE_API_KEY}** + - Secret value should be stored in {REPO_NAME}/{APP_NAME}/{ENV}/{SECRET_NAME}, e.g. **freeleaps-service-hub/payment/alpha/STRIPE_API_KEY** + - Resolve appEnv references in the yaml file, e.g. **LOG_BASE_PATH: \$CONTAINER_APP_ROOT/log/\$APP_NAME**, **\$CONTAINER_APP_ROOT** and **$APP_NAME** should be replaced by the appEnv with the same name. And we should do the same for a SECRET referrence + - NOTE: only appEnvs are allowed to have references in the yaml file + - When reference can not be resolved, terminate the CI/CD +- For each app, the related k8s resource should be named as {APP_NAME}-{RESOURCE_NAME}, e.g. **payment-deployment**, **payment-service** +- For each app's k8s pod, we should deploy the resources defined in **appK8sConfig** as long as it doesn't conflict with the resource quota. \ No newline at end of file diff --git a/sites/central_storage/deploy/k8s/alpha.yaml b/sites/central_storage/deploy/k8s/alpha.yaml new file mode 100644 index 0000000..43d994c --- /dev/null +++ b/sites/central_storage/deploy/k8s/alpha.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: central_storage + ENVIRONMENT: alpha + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://mongodb-service.freeleaps-alpha.svc.cluster.local:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 50 + timeoutSeconds: 125 + periodSeconds: 125 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/central_storage/deploy/k8s/prod.yaml b/sites/central_storage/deploy/k8s/prod.yaml new file mode 100644 index 0000000..b9027bc --- /dev/null +++ b/sites/central_storage/deploy/k8s/prod.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: central_storage + ENVIRONMENT: prod + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://freeleaps2-mongodb:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 60 + timeoutSeconds: 120 + periodSeconds: 30 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/central_storage/deploy/k8s/readme.md b/sites/central_storage/deploy/k8s/readme.md new file mode 100644 index 0000000..868b410 --- /dev/null +++ b/sites/central_storage/deploy/k8s/readme.md @@ -0,0 +1,11 @@ +- K8s namespace should be the same as the code repository name(project name), e.g. **freeleaps-service-hub** + - All apps within the repository should be deployed under the same namespace +- For each app, the K8s pod name must be the same as appEnv.APP_NAME +- When loading deployment yaml file under k8s folder (alpha.yaml, prod.yaml): + - Replace the secret values that are in format of {SECRET_NAME}, e.g. **{STRIPE_API_KEY}** + - Secret value should be stored in {REPO_NAME}/{APP_NAME}/{ENV}/{SECRET_NAME}, e.g. **freeleaps-service-hub/payment/alpha/STRIPE_API_KEY** + - Resolve appEnv references in the yaml file, e.g. **LOG_BASE_PATH: \$CONTAINER_APP_ROOT/log/\$APP_NAME**, **\$CONTAINER_APP_ROOT** and **$APP_NAME** should be replaced by the appEnv with the same name. And we should do the same for a SECRET referrence + - NOTE: only appEnvs are allowed to have references in the yaml file + - When reference can not be resolved, terminate the CI/CD +- For each app, the related k8s resource should be named as {APP_NAME}-{RESOURCE_NAME}, e.g. **payment-deployment**, **payment-service** +- For each app's k8s pod, we should deploy the resources defined in **appK8sConfig** as long as it doesn't conflict with the resource quota. \ No newline at end of file diff --git a/sites/content/deploy/k8s/alpha.yaml b/sites/content/deploy/k8s/alpha.yaml new file mode 100644 index 0000000..8d9da57 --- /dev/null +++ b/sites/content/deploy/k8s/alpha.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: content + ENVIRONMENT: alpha + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://mongodb-service.freeleaps-alpha.svc.cluster.local:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 50 + timeoutSeconds: 125 + periodSeconds: 125 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/content/deploy/k8s/prod.yaml b/sites/content/deploy/k8s/prod.yaml new file mode 100644 index 0000000..93a1250 --- /dev/null +++ b/sites/content/deploy/k8s/prod.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: content + ENVIRONMENT: prod + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://freeleaps2-mongodb:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 60 + timeoutSeconds: 120 + periodSeconds: 30 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/content/deploy/k8s/readme.md b/sites/content/deploy/k8s/readme.md new file mode 100644 index 0000000..868b410 --- /dev/null +++ b/sites/content/deploy/k8s/readme.md @@ -0,0 +1,11 @@ +- K8s namespace should be the same as the code repository name(project name), e.g. **freeleaps-service-hub** + - All apps within the repository should be deployed under the same namespace +- For each app, the K8s pod name must be the same as appEnv.APP_NAME +- When loading deployment yaml file under k8s folder (alpha.yaml, prod.yaml): + - Replace the secret values that are in format of {SECRET_NAME}, e.g. **{STRIPE_API_KEY}** + - Secret value should be stored in {REPO_NAME}/{APP_NAME}/{ENV}/{SECRET_NAME}, e.g. **freeleaps-service-hub/payment/alpha/STRIPE_API_KEY** + - Resolve appEnv references in the yaml file, e.g. **LOG_BASE_PATH: \$CONTAINER_APP_ROOT/log/\$APP_NAME**, **\$CONTAINER_APP_ROOT** and **$APP_NAME** should be replaced by the appEnv with the same name. And we should do the same for a SECRET referrence + - NOTE: only appEnvs are allowed to have references in the yaml file + - When reference can not be resolved, terminate the CI/CD +- For each app, the related k8s resource should be named as {APP_NAME}-{RESOURCE_NAME}, e.g. **payment-deployment**, **payment-service** +- For each app's k8s pod, we should deploy the resources defined in **appK8sConfig** as long as it doesn't conflict with the resource quota. \ No newline at end of file diff --git a/sites/notification/deploy/k8s/alpha.yaml b/sites/notification/deploy/k8s/alpha.yaml new file mode 100644 index 0000000..14eab24 --- /dev/null +++ b/sites/notification/deploy/k8s/alpha.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: notification + ENVIRONMENT: alpha + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://mongodb-service.freeleaps-alpha.svc.cluster.local:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 50 + timeoutSeconds: 125 + periodSeconds: 125 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/notification/deploy/k8s/prod.yaml b/sites/notification/deploy/k8s/prod.yaml new file mode 100644 index 0000000..290a054 --- /dev/null +++ b/sites/notification/deploy/k8s/prod.yaml @@ -0,0 +1,38 @@ +appEnv: + APP_NAME: notification + ENVIRONMENT: prod + CONTAINER_APP_ROOT: /app + SERVICE_API_ACCESS_HOST: 0.0.0.0 + SERVICE_API_ACCESS_PORT: 80 + + JWT_SECRET_KEY: {JWT_SECRET_KEY} + JWT_ALGORITHM: HS256 + + STRIPE_API_KEY: {STRIPE_API_KEY} + + MONGODB_NAME: freeleaps2 + MONGODB_PORT: 27017 + MONGODB_URI: mongodb://freeleaps2-mongodb:27017/ + + LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME + BACKEND_LOG_FILE_NAME: $APP_NAME + APPLICATION_ACTIVITY_LOG: $APP_NAME-activity + +appK8sConfig: + replicaCount: 2 + limits: + cpu: "1" + memory: "1Gi" + requests: + cpu: "0.5" + memory: "0.5Gi" + startupProbe: + command: to_add_startup_check.sh + initialDelaySeconds: 60 + timeoutSeconds: 120 + periodSeconds: 30 + livenessProbe: + command: to_add_healthcheck.sh + readinessProbe: + command: to_add_healthcheck.sh + diff --git a/sites/notification/deploy/k8s/readme.md b/sites/notification/deploy/k8s/readme.md new file mode 100644 index 0000000..868b410 --- /dev/null +++ b/sites/notification/deploy/k8s/readme.md @@ -0,0 +1,11 @@ +- K8s namespace should be the same as the code repository name(project name), e.g. **freeleaps-service-hub** + - All apps within the repository should be deployed under the same namespace +- For each app, the K8s pod name must be the same as appEnv.APP_NAME +- When loading deployment yaml file under k8s folder (alpha.yaml, prod.yaml): + - Replace the secret values that are in format of {SECRET_NAME}, e.g. **{STRIPE_API_KEY}** + - Secret value should be stored in {REPO_NAME}/{APP_NAME}/{ENV}/{SECRET_NAME}, e.g. **freeleaps-service-hub/payment/alpha/STRIPE_API_KEY** + - Resolve appEnv references in the yaml file, e.g. **LOG_BASE_PATH: \$CONTAINER_APP_ROOT/log/\$APP_NAME**, **\$CONTAINER_APP_ROOT** and **$APP_NAME** should be replaced by the appEnv with the same name. And we should do the same for a SECRET referrence + - NOTE: only appEnvs are allowed to have references in the yaml file + - When reference can not be resolved, terminate the CI/CD +- For each app, the related k8s resource should be named as {APP_NAME}-{RESOURCE_NAME}, e.g. **payment-deployment**, **payment-service** +- For each app's k8s pod, we should deploy the resources defined in **appK8sConfig** as long as it doesn't conflict with the resource quota. \ No newline at end of file diff --git a/sites/payment/deploy/k8s/alpha.yaml b/sites/payment/deploy/k8s/alpha.yaml index 8d5bbcf..8665f7d 100644 --- a/sites/payment/deploy/k8s/alpha.yaml +++ b/sites/payment/deploy/k8s/alpha.yaml @@ -1,5 +1,6 @@ appEnv: APP_NAME: payment + ENVIRONMENT: alpha CONTAINER_APP_ROOT: /app SERVICE_API_ACCESS_HOST: 0.0.0.0 SERVICE_API_ACCESS_PORT: 80 @@ -11,7 +12,7 @@ appEnv: MONGODB_NAME: freeleaps2 MONGODB_PORT: 27017 - MONGODB_URI: mongodb://freeleaps2-mongodb:27017/ + MONGODB_URI: mongodb://mongodb-service.freeleaps-alpha.svc.cluster.local:27017/ LOG_BASE_PATH: $CONTAINER_APP_ROOT/log/$APP_NAME BACKEND_LOG_FILE_NAME: $APP_NAME diff --git a/sites/payment/deploy/k8s/prod.yaml b/sites/payment/deploy/k8s/prod.yaml index 62ff03a..3e09390 100644 --- a/sites/payment/deploy/k8s/prod.yaml +++ b/sites/payment/deploy/k8s/prod.yaml @@ -1,5 +1,6 @@ appEnv: APP_NAME: payment + ENVIRONMENT: prod CONTAINER_APP_ROOT: /app SERVICE_API_ACCESS_HOST: 0.0.0.0 SERVICE_API_ACCESS_PORT: 80