diff --git a/charts/api/charts/booking/Chart.lock b/charts/api/charts/booking/Chart.lock deleted file mode 100644 index b385c20..0000000 --- a/charts/api/charts/booking/Chart.lock +++ /dev/null @@ -1,9 +0,0 @@ -dependencies: -- name: api-booking-database - repository: file://./charts/database - version: 0.1.0 -- name: api-booking-redis - repository: file://./charts/redis - version: 0.1.0 -digest: sha256:4fb6e79f98009b0d936065b3353c9c58f75c95490da5bf1a08fe8143decb4abd -generated: "2025-08-06T10:12:22.2963493+09:00" diff --git a/charts/api/charts/booking/Chart.yaml b/charts/api/charts/booking/Chart.yaml index b18b269..9bf50c8 100644 --- a/charts/api/charts/booking/Chart.yaml +++ b/charts/api/charts/booking/Chart.yaml @@ -9,6 +9,9 @@ dependencies: - name: api-booking-database version: 0.1.0 repository: "file://./charts/database" + alias: apiBookingDatabase + - name: api-booking-redis version: 0.1.0 - repository: "file://./charts/redis" \ No newline at end of file + repository: "file://./charts/redis" + alias: apiBookingRedis \ No newline at end of file diff --git a/charts/api/charts/booking/charts/database/values.yaml b/charts/api/charts/booking/charts/database/values.yaml index af2f750..aa3b2eb 100644 --- a/charts/api/charts/booking/charts/database/values.yaml +++ b/charts/api/charts/booking/charts/database/values.yaml @@ -1,18 +1,17 @@ -apiBookingDatabase: - replicaCount: 1 +replicaCount: 1 - auth: - rootPassword: "rookies" - database: booking - username: rookies - password: rookies +auth: + rootPassword: "rookies" + database: booking + username: rookies + password: rookies - service: - name: api-booking-database-service - type: ClusterIP - port: 3306 +service: + name: api-booking-database-service + type: ClusterIP + port: 3306 - persistence: - enabled: true - size: 8Gi - storageClass: "" \ No newline at end of file +persistence: + enabled: true + size: 8Gi + storageClass: "" \ No newline at end of file diff --git a/charts/api/charts/booking/charts/redis/values.yaml b/charts/api/charts/booking/charts/redis/values.yaml index 658673f..3269323 100644 --- a/charts/api/charts/booking/charts/redis/values.yaml +++ b/charts/api/charts/booking/charts/redis/values.yaml @@ -1,17 +1,16 @@ -apiBookingRedis: - replicaCount: 1 +replicaCount: 1 - image: - repository: redis - tag: "7.2.4" - pullPolicy: IfNotPresent +image: + repository: redis + tag: "7.2.4" + pullPolicy: IfNotPresent - service: - name: api-booking-redis-service - type: ClusterIP - port: 6379 +service: + name: api-booking-redis-service + type: ClusterIP + port: 6379 - persistence: - enabled: true - size: 8Gi - storageClass: "" \ No newline at end of file +persistence: + enabled: true + size: 8Gi + storageClass: "gp2" \ No newline at end of file diff --git a/charts/api/charts/booking/templates/_helpers.tpl b/charts/api/charts/booking/templates/_helpers.tpl index 7ff6a26..9cc9f35 100644 --- a/charts/api/charts/booking/templates/_helpers.tpl +++ b/charts/api/charts/booking/templates/_helpers.tpl @@ -29,42 +29,12 @@ expose-via-spring-gateway # # Application Properties # -# -# Application Properties -# -{{- define "api-booking.applicationProperties" -}} -spring.application.name=booking - - -server.port=8080 +{{- define "api-booking.kafka-server" -}} +{{ printf "%s.kafka.svc.cluster.local:%d" (default "kafka-service" .Values.global.service.kafka) 9092 }} +{{- end -}} -server.address=0.0.0.0 +{{- define "api-booking.user-server" -}} +{{ printf "http://%s.user.svc.cluster.local:%d" (default "api-user-service" .Values.global.service.apiUser) 8080 }} +{{- end -}} -# log file -logging.file.path=logs -logging.level.com.basic.myspringboot=debug - -# MariaDB Database 설정 -spring.datasource.url=jdbc:mariadb://{{ .Values.global.service.apiBookingDatabase | default "api-booking-database-service" }}:{{ .Values.apiBookingDatabase.service.port | default 3306 }}/{{ .Values.apiBookingDatabase.auth.database | default "booking" }} -spring.datasource.driver-class-name=org.mariadb.jdbc.Driver -spring.datasource.username={{ .Values.apiBookingDatabase.auth.username | default "rookies" }} -spring.datasource.password={{ .Values.apiBookingDatabase.auth.password | default "rookies" }} - -# JPA 설정 -spring.jpa.database-platform=org.hibernate.dialect.MariaDBDialect -spring.jpa.hibernate.ddl-auto=update - -# Redis 설정 -spring.data.redis.host={{ .Values.global.service.apiBookingRedis | default "api-booking-redis-service" }} -spring.data.redis.port={{ .Values.apiBookingRedis.service.port | default 6379 }} - -# Kafka 설정 -app.kafka.topic.booking-event=booking-events -app.kafka.topic.user-event=user-events -spring.kafka.bootstrap-servers={{ printf "%s.kafka.svc.cluster.local:%d" (default "kafka-service" .Values.global.service.kafka) 9092 }} -spring.kafka.consumer.auto-offset-reset=earliest -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.properties.spring.json.trusted.packages=* -spring.kafka.consumer.properties.spring.json.use.type.headers=false -{{- end }} diff --git a/charts/api/charts/booking/templates/api-booking-config-map.yaml.tpl b/charts/api/charts/booking/templates/api-booking-config-map.yaml.tpl deleted file mode 100644 index 0499468..0000000 --- a/charts/api/charts/booking/templates/api-booking-config-map.yaml.tpl +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "api-booking.fullname" . }}-config -data: - application-dev.properties: | -{{ include "api-booking.applicationProperties" . | nindent 4}} \ No newline at end of file diff --git a/charts/api/charts/booking/templates/api-booking-deployment.yaml.tpl b/charts/api/charts/booking/templates/api-booking-deployment.yaml.tpl index f7070c9..85c4d9c 100644 --- a/charts/api/charts/booking/templates/api-booking-deployment.yaml.tpl +++ b/charts/api/charts/booking/templates/api-booking-deployment.yaml.tpl @@ -14,13 +14,6 @@ spec: labels: app: {{ include "api-booking.fullname" . }} spec: - volumes: - - name: config-volume - configMap: - name: api-booking-booking-config - items: - - key: application-dev.properties - path: application-dev.properties containers: - name: booking image: "{{ .Values.apiBooking.image.registry }}/{{ .Values.apiBooking.image.repository }}:{{ .Values.apiBooking.image.tag }}" @@ -29,10 +22,84 @@ spec: - containerPort: {{ .Values.apiBooking.service.port }} env: - name: SPRING_PROFILES_ACTIVE - value: dev - - name: SPRING_CONFIG_LOCATION - value: "classpath:/,file:/config/" - volumeMounts: - - name: config-volume - mountPath: /config - readOnly: true \ No newline at end of file + value: "prod" + - name: SERVER_PORT + value: "{{ .Values.apiBooking.service.port }}" + # Database + - name: DB_URL + value: "jdbc:mariadb://{{ .Values.global.service.apiBookingDatabase | default "api-booking-database-service" }}:{{ .Values.apiBookingDatabase.service.port | default 3306 }}/{{ .Values.apiBookingDatabase.auth.database | default "booking" }}" + - name: DB_USERNAME + value: {{ .Values.apiBookingDatabase.auth.username | default "rookies" }} + - name: DB_PASSWORD + value: {{ .Values.apiBookingDatabase.auth.password | default "rookies" }} + - name: SPRING_JPA_HIBERNATE_DDL_AUTO + value: update + # Redis + - name: REDIS_SERVER_URL + value: {{ .Values.global.service.apiBookingRedis | default "api-booking-redis-service" }} + - name: REDIS_PORT + value: "6379" + + # Kafka + - name: KAFKA_SERVERS + value: {{ include "api-booking.kafka-server" . }} + + # External APIs + - name: BASE_API + value: {{ include "api-booking.user-server" . }} + - name: USER_BASE_API + value: {{ include "api-booking.user-server" . }} + - name: USER_EMAIL_INFO_API + value: /api/users/booking-profile + - name: USER_STATS_LIST_API + value: /api/users/statisticsList + - name: BOOKING_USER_INFO_API + value: /api/users/reservationList + - name: LOGGING_LEVEL_COM_MNMS_BOOKING_SERVICE + value: DEBUG + - name: LOGGING_LEVEL_COM_MNMS_BOOKING_CONTROLLER + value: DEBUG + + - name: MAIL_USERNAME + valueFrom: + secretKeyRef: + name: api-booking-secret + key: MAIL_USERNAME + - name: MAIL_PASSWORD + valueFrom: + secretKeyRef: + name: api-booking-secret + key: MAIL_PASSWORD + # OCR Settings + - name: OCR_SECRET_KEY + valueFrom: + secretKeyRef: + name: api-booking-secret + key: OCR_SECRET_KEY + - name: OCR_INVOKE_URL + valueFrom: + secretKeyRef: + name: api-booking-secret + key: OCR_INVOKE_URL + + + resources: + requests: + cpu: {{ .Values.apiBooking.resources.requests.cpu | default "256m" }} + memory: {{ .Values.apiBooking.resources.requests.memory | default "256Mi" }} + limits: + cpu: {{ .Values.apiBooking.resources.limits.cpu | default "500m" }} + memory: {{ .Values.apiBooking.resources.limits.memory | default "1024Mi" }} + # actuator 가 없어서 주석처리 + # livenessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiBooking.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 10 + # readinessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiBooking.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 5 diff --git a/charts/api/charts/booking/templates/api-booking-service.yaml.tpl b/charts/api/charts/booking/templates/api-booking-service.yaml.tpl index ff3acd0..c850629 100644 --- a/charts/api/charts/booking/templates/api-booking-service.yaml.tpl +++ b/charts/api/charts/booking/templates/api-booking-service.yaml.tpl @@ -10,5 +10,7 @@ spec: selector: app: {{ include "api-booking.fullname" . }} ports: - - port: {{ .Values.apiBooking.service.port }} + + - name: http + port: {{ .Values.apiBooking.service.port }} targetPort: {{ .Values.apiBooking.service.port }} \ No newline at end of file diff --git a/charts/api/charts/booking/values.yaml b/charts/api/charts/booking/values.yaml index 3957e2a..57ffd62 100644 --- a/charts/api/charts/booking/values.yaml +++ b/charts/api/charts/booking/values.yaml @@ -19,17 +19,16 @@ apiBooking: # apiBookingDatabase: replicaCount: 1 - auth: rootPassword: "rookies" database: booking username: rookies password: rookies - service: + # ← 부모 템플릿에서 바로 읽어 쓰려면 name을 명시해 두는 게 안전합니다 + name: api-booking-database-service type: ClusterIP port: 3306 - persistence: enabled: true size: 8Gi @@ -38,19 +37,19 @@ apiBookingDatabase: # # Redis Values # + + apiBookingRedis: replicaCount: 1 - image: repository: redis tag: "7.2.4" pullPolicy: IfNotPresent - service: + name: api-booking-redis-service # ← 동일하게 명시 type: ClusterIP port: 6379 - persistence: enabled: true - size: 8Gi - storageClass: "" \ No newline at end of file + size: 7Gi + storageClass: "gp2" \ No newline at end of file diff --git a/charts/api/charts/festival/Chart.yaml b/charts/api/charts/festival/Chart.yaml index f62fb23..f82805d 100644 --- a/charts/api/charts/festival/Chart.yaml +++ b/charts/api/charts/festival/Chart.yaml @@ -8,4 +8,5 @@ appVersion: "1.0.0" dependencies: - name: api-festival-database version: 0.1.0 - repository: "file://./charts/database" \ No newline at end of file + repository: "file://./charts/database" + alias: apiFestivalDatabase \ No newline at end of file diff --git a/charts/api/charts/festival/charts/database/values.yaml b/charts/api/charts/festival/charts/database/values.yaml index d58b909..78da4dd 100644 --- a/charts/api/charts/festival/charts/database/values.yaml +++ b/charts/api/charts/festival/charts/database/values.yaml @@ -1,18 +1,17 @@ -apiFestivalDatabase: - replicaCount: 1 +replicaCount: 1 - auth: - rootPassword: "rookies" - database: festival - username: rookies - password: rookies +auth: + rootPassword: "rookies" + database: festival + username: rookies + password: rookies - service: - name: api-festival-database-service - type: ClusterIP - port: 3306 +service: + name: api-festival-database-service + type: ClusterIP + port: 3306 - persistence: - enabled: true - size: 8Gi - storageClass: "" \ No newline at end of file +persistence: + enabled: true + size: 8Gi + storageClass: "" \ No newline at end of file diff --git a/charts/api/charts/festival/templates/_helpers.tpl b/charts/api/charts/festival/templates/_helpers.tpl index 4909ee2..2f54010 100644 --- a/charts/api/charts/festival/templates/_helpers.tpl +++ b/charts/api/charts/festival/templates/_helpers.tpl @@ -2,6 +2,12 @@ {{ .Release.Name }}-festival {{- end }} +{{- define "api-festival-deployment.fullname" -}} +{{ include "api-festival.fullname" . }}-deployment +{{- end }} + + + {{- define "api-festival.labels" -}} app.kubernetes.io/name: {{ include "api-festival.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} @@ -24,4 +30,38 @@ api-festival-service {{- else }} expose-via-spring-gateway {{- end }} -{{- end }} \ No newline at end of file +{{- end }} + + +{{- define "api-festival.kafka.url" -}} +{{- $g := .Values.global | default (dict) -}} +{{- $svc := $g.service | default (dict) -}} +{{- $name := $svc.kafka | default "kafka-service" -}} +{{- $name -}}.kafka.svc.cluster.local:9092 +{{- end -}} + +{{- define "api-festival.database.url" -}} +jdbc:mariadb://{{ .Values.global.service.apiFestivalDatabase | default "api-festival-database-service" }}:3306/{{ .Values.apiFestival.database.name }} +{{- end -}} + + + + + +{{- define "api-festival-ai.fullname" -}} +{{ .Release.Name }}-festival-ai +{{- end }} + +{{- define "api-festival-ai.labels" -}} +app.kubernetes.io/name: {{ include "api-festival-ai.fullname" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "api-festival-ai.servicename" -}} +{{- $g := .Values.global | default (dict) -}} +{{- $svc := $g.service | default (dict) -}} +{{- $name := $svc.apiFestivalAi | default "api-festival-ai" -}} +{{- $name -}} +{{- end }} + diff --git a/charts/api/charts/festival/templates/api-festival-ai-deployment.yaml.tpl b/charts/api/charts/festival/templates/api-festival-ai-deployment.yaml.tpl new file mode 100644 index 0000000..835e560 --- /dev/null +++ b/charts/api/charts/festival/templates/api-festival-ai-deployment.yaml.tpl @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "api-festival-ai.fullname" . }} + labels: + {{- include "api-festival-ai.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.apiFestivalAi.replicaCount }} + selector: + matchLabels: + app: {{ include "api-festival-ai.fullname" . }} + template: + metadata: + labels: + app: {{ include "api-festival-ai.fullname" . }} + spec: + containers: + - name: festival + image: "{{ .Values.apiFestivalAi.image.registry }}/{{ .Values.apiFestivalAi.image.repository }}:{{ .Values.apiFestivalAi.image.tag }}" + imagePullPolicy: {{ .Values.apiFestivalAi.image.pullPolicy }} + ports: + - containerPort: {{ .Values.apiFestivalAi.service.port }} + env: + - name: AWS_BEDROCK_REGION + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_BEDROCK_REGION + - name: AWS_BEDROCK_API_KEY + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_BEDROCK_API_KEY + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_SECRET_ACCESS_KEY diff --git a/charts/api/charts/festival/templates/api-festival-ai-service.yaml.tpl b/charts/api/charts/festival/templates/api-festival-ai-service.yaml.tpl new file mode 100644 index 0000000..5c6ee8e --- /dev/null +++ b/charts/api/charts/festival/templates/api-festival-ai-service.yaml.tpl @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "api-festival-ai.servicename" . }} + labels: + {{- include "api-festival-ai.labels" . | nindent 4 }} +spec: + type: {{ .Values.apiFestivalAi.service.type }} + selector: + app: {{ include "api-festival-ai.fullname" . }} + ports: + - port: {{ .Values.apiFestivalAi.service.port }} + targetPort: {{ .Values.apiFestivalAi.service.port }} \ No newline at end of file diff --git a/charts/api/charts/festival/templates/api-festival-deployment.yaml.tpl b/charts/api/charts/festival/templates/api-festival-deployment.yaml.tpl new file mode 100644 index 0000000..9fb7756 --- /dev/null +++ b/charts/api/charts/festival/templates/api-festival-deployment.yaml.tpl @@ -0,0 +1,113 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "api-festival-deployment.fullname" . }} + labels: + {{- include "api-festival.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.apiFestival.replicaCount }} + selector: + matchLabels: + app: {{ include "api-festival-deployment.fullname" . }} + template: + metadata: + labels: + app: {{ include "api-festival-deployment.fullname" . }} + spec: + containers: + - name: festival + image: "{{ .Values.apiFestival.image.registry }}/{{ .Values.apiFestival.image.repository }}:{{ .Values.apiFestival.image.tag }}" + imagePullPolicy: {{ .Values.apiFestival.image.pullPolicy }} + ports: + - containerPort: {{ .Values.apiFestival.service.port }} + env: + - name: SERVER_PORT + value: "8080" + - name: SPRING_PROFILES_ACTIVE + value: prod + - name: TZ + value: Asia/Seoul + + # Kafka + - name: SPRING_KAFKA_BOOTSTRAP_SERVERS + value: {{ include "api-festival.kafka.url" . }} + + # Database + - name: SPRING_DATASOURCE_URL + value: {{ include "api-festival.database.url" . }} + - name: SPRING_DATASOURCE_USERNAME + valueFrom: + secretKeyRef: + name: api-festival-secret + key: SPRING_DATASOURCE_USERNAME + - name: SPRING_DATASOURCE_PASSWORD + valueFrom: + secretKeyRef: + name: api-festival-secret + key: SPRING_DATASOURCE_PASSWORD + - name: KAKAO_REST_API_KEY + valueFrom: + secretKeyRef: + name: api-festival-secret + key: KAKAO_REST_API_KEY + + + # External Service + - name: FESTIVAL_API_KEY + valueFrom: + secretKeyRef: + name: api-festival-secret + key: FESTIVAL_API_KEY + + - name: AI_URL + value: {{ printf "http://%s:%s" (.Values.global.service.apiFestivalAi | default "api-festival-ai-service") (.Values.global.service.apiFestivalAiPort | default "8084") }} + # AWS Setting + - name: AWS_S3_BUCKET_NAME + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_S3_BUCKET_NAME + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_SECRET_ACCESS_KEY + - name: AWS_REGION + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_REGION + - name: AWS_STS_ROLE_ARN + valueFrom: + secretKeyRef: + name: api-festival-secret + key: AWS_STS_ROLE_ARN + # GEOCODE + - name: USER_GEOCODE_API + value: "/api/users/geocodeInfo" + - name: BASE_API + value: {{ printf "https://api.%s" .Values.global.domain | quote }} + resources: + requests: + cpu: {{ .Values.apiFestival.resources.requests.cpu | default "256m" }} + memory: {{ .Values.apiFestival.resources.requests.memory | default "256Mi" }} + limits: + cpu: {{ .Values.apiFestival.resources.limits.cpu | default "500m" }} + memory: {{ .Values.apiFestival.resources.limits.memory | default "1024Mi" }} + # livenessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiFestival.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 10 + # readinessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiFestival.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 5 \ No newline at end of file diff --git a/charts/api/charts/festival/templates/service.yaml b/charts/api/charts/festival/templates/api-festival-service.yaml.tpl similarity index 87% rename from charts/api/charts/festival/templates/service.yaml rename to charts/api/charts/festival/templates/api-festival-service.yaml.tpl index 013f23f..acdc857 100644 --- a/charts/api/charts/festival/templates/service.yaml +++ b/charts/api/charts/festival/templates/api-festival-service.yaml.tpl @@ -8,7 +8,7 @@ metadata: spec: type: {{ .Values.apiFestival.service.type }} selector: - app: {{ include "api-festival.fullname" . }} + app: {{ include "api-festival-deployment.fullname" . }} ports: - port: {{ .Values.apiFestival.service.port }} targetPort: {{ .Values.apiFestival.service.port }} \ No newline at end of file diff --git a/charts/api/charts/festival/templates/deployment.yaml b/charts/api/charts/festival/templates/deployment.yaml deleted file mode 100644 index 55e0f00..0000000 --- a/charts/api/charts/festival/templates/deployment.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "api-festival.fullname" . }} - labels: - {{- include "api-festival.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.apiFestival.replicaCount }} - selector: - matchLabels: - app: {{ include "api-festival.fullname" . }} - template: - metadata: - labels: - app: {{ include "api-festival.fullname" . }} - spec: - containers: - - name: festival - image: "{{ .Values.apiFestival.image.registry }}/{{ .Values.apiFestival.image.repository }}:{{ .Values.apiFestival.image.tag }}" - imagePullPolicy: {{ .Values.apiFestival.image.pullPolicy }} - ports: - - containerPort: {{ .Values.apiFestival.service.port }} \ No newline at end of file diff --git a/charts/api/charts/festival/values.yaml b/charts/api/charts/festival/values.yaml index 7706f08..d77ffaf 100644 --- a/charts/api/charts/festival/values.yaml +++ b/charts/api/charts/festival/values.yaml @@ -1,19 +1,57 @@ apiFestival: replicaCount: 1 - image: registry: rookiesdogun repository: api-festival - tag: test + tag: v20250902065439 pullPolicy: IfNotPresent - service: type: ClusterIP port: 8080 - database: host: api-festival-database-service port: 3306 name: festival username: rookies - password: rookies \ No newline at end of file + password: rookies + resources: + requests: + cpu: "256m" + memory: "512Mi" + limits: + cpu: "500m" + memory: "1024Mi" + +apiFestivalDatabase: + replicaCount: 1 + auth: + rootPassword: "rookies" + database: festival + username: rookies + password: rookies + service: + name: api-festival-database-service + type: ClusterIP + port: 3306 + persistence: + enabled: true + size: 8Gi + storageClass: "gp2" + +apiFestivalAi: + replicaCount: 1 + image: + registry: rookiesdogun + repository: api-festival + tag: test + pullPolicy: IfNotPresent + service: + type: ClusterIP + port: 8084 + resources: + requests: + cpu: "256m" + memory: "512Mi" + limits: + cpu: "500m" + memory: "1024Mi" \ No newline at end of file diff --git a/charts/api/charts/gateway/templates/_helpers.tpl b/charts/api/charts/gateway/templates/_helpers.tpl index d48ae1d..762b0b9 100644 --- a/charts/api/charts/gateway/templates/_helpers.tpl +++ b/charts/api/charts/gateway/templates/_helpers.tpl @@ -79,9 +79,12 @@ api.rookies-tekcit.com kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: {{ .Values.apiGateway.ingress.aws.scheme | default "internet-facing" }} alb.ingress.kubernetes.io/target-type: ip +alb.ingress.kubernetes.io/healthcheck-path: /actuator/health +alb.ingress.kubernetes.io/success-codes: "200" {{- if eq .Values.apiGateway.ingress.tls true }} alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]' alb.ingress.kubernetes.io/certificate-arn: {{ .Values.apiGateway.ingress.aws.certificateArn | quote }} +alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}' {{- else }} alb.ingress.kubernetes.io/listen-ports: '[{"HTTP":80}]' {{- end -}} @@ -112,3 +115,10 @@ kubernetes.io/ingress.class: gce kubernetes.io/ingress.global-static-ip-name: {{ .Values.apiGateway.ingress.gce.ipName | default "rookies-tkcit-static-ip" }} {{- end -}} + +{{- define "api-gateway.serviceaccountname" -}} +{{ include "api-gateway.fullname" . }}-sa +{{- end -}} + + + diff --git a/charts/api/charts/gateway/templates/api-gateway-deployment.yaml.tpl b/charts/api/charts/gateway/templates/api-gateway-deployment.yaml.tpl index 4db3ce2..5242084 100644 --- a/charts/api/charts/gateway/templates/api-gateway-deployment.yaml.tpl +++ b/charts/api/charts/gateway/templates/api-gateway-deployment.yaml.tpl @@ -4,7 +4,6 @@ metadata: name: {{ include "api-gateway.fullname" . }} labels: app: {{ include "api-gateway.name" . }} - {{ include "api-gateway.exposelabel" . }}: "true" spec: replicas: {{ .Values.apiGateway.replicaCount | default 2 }} selector: @@ -14,9 +13,8 @@ spec: metadata: labels: app: {{ include "api-gateway.name" . }} - {{ include "api-gateway.exposelabel" . | indent 4 }}: "true" spec: - serviceAccountName: {{ include "api-gateway.fullname" . }}-sa + serviceAccountName: {{ include "api-gateway.serviceaccountname" . }} containers: - name: {{ include "api-gateway.name" . }} image: "{{ .Values.apiGateway.image.repository }}:{{ .Values.apiGateway.image.tag }}" @@ -25,9 +23,6 @@ spec: - containerPort: {{ .Values.apiGateway.service.port }} name: http protocol: TCP - env: - - name: SPRING_PROFILES_ACTIVE - value: {{ .Values.apiGateway.spring.profiles | default "develop" | quote }} resources: requests: @@ -47,4 +42,30 @@ spec: path: /actuator/health port: {{ .Values.apiGateway.service.targetPort }} initialDelaySeconds: 80 - periodSeconds: 5 \ No newline at end of file + periodSeconds: 5 + + env: + # JWT 파일 경로 + - name: SPRING_PROFILES_ACTIVE + value: {{ .Values.apiGateway.spring.profiles | default "prod" }} + - name: JWT_PRIVATE_PEM_PATH + value: "file:/etc/keys/private.pem" + - name: JWT_PUBLIC_PEM_PATH + value: "file:/etc/keys/public.pem" + - name: CORS_URL + value: {{ .Values.apiGateway.spring.corsUrl | default "https://www.rookies-tekcit.com" }} + volumeMounts: + - name: jwt-keys + mountPath: /etc/keys + readOnly: true + volumes: + - name: jwt-keys + secret: + secretName: api-gateway-secret + items: + - key: JWT_PRIVATE_PEM_PATH + path: private.pem + - key: JWT_PUBLIC_PEM_PATH + path: public.pem + + \ No newline at end of file diff --git a/charts/api/charts/gateway/templates/api-gateway-rbac.tpl b/charts/api/charts/gateway/templates/api-gateway-rbac.tpl index 824210d..c7571fe 100644 --- a/charts/api/charts/gateway/templates/api-gateway-rbac.tpl +++ b/charts/api/charts/gateway/templates/api-gateway-rbac.tpl @@ -4,7 +4,10 @@ kind: ServiceAccount metadata: name: {{ include "api-gateway.fullname" . }}-sa namespace: {{ .Release.Namespace }} - + {{- if eq .Values.apiGateway.ingress.mode "aws" }} + annotations: + eks.amazonaws.com/role-arn: {{ .Values.apiGateway.ingress.aws.roleArn | default "arn:aws:iam::123456789012:role/RookiesApiGatewayRole" }} + {{- end }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole diff --git a/charts/api/charts/gateway/templates/api-gateway-secret-store.yaml.tpl b/charts/api/charts/gateway/templates/api-gateway-secret-store.yaml.tpl index 9b89285..39e6768 100644 --- a/charts/api/charts/gateway/templates/api-gateway-secret-store.yaml.tpl +++ b/charts/api/charts/gateway/templates/api-gateway-secret-store.yaml.tpl @@ -1,5 +1,5 @@ -{{- if eq .Values.apiGateway.ingress.mode "aws" -}} +{{- if eq .Values.apiGateway.ingress.mode "test" -}} apiVersion: external-secrets.io/v1beta1 kind: ClusterSecretStore metadata: @@ -14,4 +14,25 @@ spec: serviceAccountRef: name: external-secrets-sa namespace: external-secrets -{{- end -}} \ No newline at end of file + +--- +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: api-gateway-role-arn + namespace: gateway +spec: + refreshInterval: 1h + secretStoreRef: + name: aws-secrets-manager + kind: ClusterSecretStore + target: + name: api-gateway-role-arn + creationPolicy: Owner + data: + - secretKey: roleArn + remoteRef: + key: /gateway/apiGateway/roleArn + +{{- end -}} + diff --git a/charts/api/charts/gateway/values.yaml b/charts/api/charts/gateway/values.yaml index 94142f1..546d003 100644 --- a/charts/api/charts/gateway/values.yaml +++ b/charts/api/charts/gateway/values.yaml @@ -6,6 +6,7 @@ apiGateway: pullPolicy: IfNotPresent spring: profiles: local + corsUrl: http://www.rookies-tekcit.com resources: requests: cpu: "256m" @@ -35,5 +36,6 @@ apiGateway: backendConfigName: api-gateway-backendconfig tlsSecret: api-gateway-tls-secret aws: - scheme: "internal-facing" + scheme: "internet-facing" certificateArn: "none" + serviceAccountName: aws-load-balancer-controller diff --git a/charts/api/charts/messageTest/templates/_helpers.tpl b/charts/api/charts/messageTest/templates/_helpers.tpl deleted file mode 100644 index 13dfab3..0000000 --- a/charts/api/charts/messageTest/templates/_helpers.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{{- define "api-message-test.fullname" -}} -{{ .Release.Name }}-message-test -{{- end }} - -{{- define "api-message-test.labels" -}} -app.kubernetes.io/name: {{ include "api-message-test.fullname" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{- define "api-message-test.servicename" -}} -api-message-test-service -{{- end }} - -{{- define "api-message-test.exposelabel" -}} -expose-via-spring-gateway -{{- end }} \ No newline at end of file diff --git a/charts/api/charts/messageTest/templates/deployment.yaml b/charts/api/charts/messageTest/templates/deployment.yaml deleted file mode 100644 index 0018c49..0000000 --- a/charts/api/charts/messageTest/templates/deployment.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "api-message-test.fullname" . }} - labels: - {{- include "api-message-test.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.apiMessageTest.replicaCount }} - selector: - matchLabels: - app: {{ include "api-message-test.fullname" . }} - template: - metadata: - labels: - app: {{ include "api-message-test.fullname" . }} - spec: - containers: - - name: message-test - image: "{{ .Values.apiMessageTest.image.registry }}/{{ .Values.apiMessageTest.image.repository }}:{{ .Values.apiMessageTest.image.tag }}" - imagePullPolicy: {{ .Values.apiMessageTest.image.pullPolicy }} - ports: - - containerPort: {{ .Values.apiMessageTest.service.port }} - env: - - name: SPRING_KAFKA_BOOTSTRAP_SERVERS - value: kafka-service.kafka.svc.cluster.local:9092 \ No newline at end of file diff --git a/charts/api/charts/messageTest/templates/service.yaml b/charts/api/charts/messageTest/templates/service.yaml deleted file mode 100644 index b0a842c..0000000 --- a/charts/api/charts/messageTest/templates/service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "api-message-test.servicename" . }} - labels: - {{- include "api-message-test.labels" . | nindent 4 }} - {{- printf "%s: \"true\"" (include "api-message-test.exposelabel" .) | nindent 4 }} -spec: - type: {{ .Values.apiMessageTest.service.type }} - selector: - app: {{ include "api-message-test.fullname" . }} - ports: - - port: {{ .Values.apiMessageTest.service.port }} - targetPort: {{ .Values.apiMessageTest.service.port }} \ No newline at end of file diff --git a/charts/api/charts/messageTest/values.yaml b/charts/api/charts/messageTest/values.yaml deleted file mode 100644 index 805de74..0000000 --- a/charts/api/charts/messageTest/values.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiMessageTest: - replicaCount: 1 - - image: - registry: rookiesdogun - repository: kafka-message - tag: test - pullPolicy: IfNotPresent - - service: - type: ClusterIP - port: 8080 - - database: - host: api-festival-database-service - port: 3306 - name: festival - username: rookies - password: rookies \ No newline at end of file diff --git a/charts/api/charts/payment/Chart.yaml b/charts/api/charts/payment/Chart.yaml index 0057362..04eb5c8 100644 --- a/charts/api/charts/payment/Chart.yaml +++ b/charts/api/charts/payment/Chart.yaml @@ -8,4 +8,5 @@ appVersion: "1.0.0" dependencies: - name: api-payment-database version: 0.1.0 - repository: "file://./charts/database" \ No newline at end of file + repository: "file://./charts/database" + alias: apiPaymentDatabase \ No newline at end of file diff --git a/charts/api/charts/payment/templates/_helpers.tpl b/charts/api/charts/payment/templates/_helpers.tpl index 67d6769..db733db 100644 --- a/charts/api/charts/payment/templates/_helpers.tpl +++ b/charts/api/charts/payment/templates/_helpers.tpl @@ -24,4 +24,16 @@ api-payment-service {{- else }} expose-via-spring-gateway {{- end }} -{{- end }} \ No newline at end of file +{{- end }} + + +{{- define "api-payment.kafka.url" -}} +{{- $g := .Values.global | default (dict) -}} +{{- $svc := $g.service | default (dict) -}} +{{- $name := $svc.kafka | default "kafka-service" -}} +{{- $name -}}.kafka.svc.cluster.local:9092 +{{- end -}} + +{{- define "api-payment.database.url" -}} +jdbc:mariadb://{{ .Values.global.service.apiPaymentDatabase | default "api-payment-database-service" }}:3306/{{ .Values.apiPayment.database.name }} +{{- end -}} diff --git a/charts/api/charts/payment/templates/api-payment-deployment.yaml.tpl b/charts/api/charts/payment/templates/api-payment-deployment.yaml.tpl new file mode 100644 index 0000000..453873a --- /dev/null +++ b/charts/api/charts/payment/templates/api-payment-deployment.yaml.tpl @@ -0,0 +1,92 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "api-payment.fullname" . }} + labels: + {{- include "api-payment.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.apiPayment.replicaCount }} + selector: + matchLabels: + app: {{ include "api-payment.fullname" . }} + template: + metadata: + labels: + app: {{ include "api-payment.fullname" . }} + spec: + containers: + - name: payment + image: "{{ .Values.apiPayment.image.registry }}/{{ .Values.apiPayment.image.repository }}:{{ .Values.apiPayment.image.tag }}" + imagePullPolicy: {{ .Values.apiPayment.image.pullPolicy }} + ports: + - containerPort: {{ .Values.apiPayment.service.port }} + env: + # Spring Settings + - name: SPRING_PROFILES_ACTIVE + value: {{ .Values.apiPayment.spring.profiles | default "prod" }} + - name: SERVER_PORT + value: {{ .Values.apiPayment.service.port | quote }} + + # # Portone Settings + - name: PORTONE_API_SECRET + valueFrom: + secretKeyRef: + name: api-payment-secret + key: PORTONE_API_SECRET + - name: PORTONE_CHANNEL_KEY + valueFrom: + secretKeyRef: + name: api-payment-secret + key: PORTONE_CHANNEL_KEY + - name: PORTONE_STORE_ID + valueFrom: + secretKeyRef: + name: api-payment-secret + key: PORTONE_STORE_ID + - name: WEBHOOK_SECRET + valueFrom: + secretKeyRef: + name: api-payment-secret + key: WEBHOOK_SECRET + + + # Database Settings + - name: SPRING_DATASOURCE_URL + value: {{ include "api-payment.database.url" . }} + - name: SPRING_DATASOURCE_USERNAME + valueFrom: + secretKeyRef: + name: api-payment-secret + key: SPRING_DATASOURCE_USERNAME + - name: SPRING_DATASOURCE_PASSWORD + valueFrom: + secretKeyRef: + name: api-payment-secret + key: SPRING_DATASOURCE_PASSWORD + - name: SPRING_JPA_HIBERNATE_DDL_AUTO + value: update + + + # Kafka Settings + - name: SPRING_KAFKA_BOOTSTRAP_SERVERS + value: {{ include "api-payment.kafka.url" . }} + + resources: + requests: + cpu: {{ .Values.apiPayment.resources.requests.cpu | default "256m" }} + memory: {{ .Values.apiPayment.resources.requests.memory | default "256Mi" }} + limits: + cpu: {{ .Values.apiPayment.resources.limits.cpu | default "500m" }} + memory: {{ .Values.apiPayment.resources.limits.memory | default "1024Mi" }} + # livenessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiPayment.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 10 + # readinessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiPayment.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 5 \ No newline at end of file diff --git a/charts/api/charts/payment/templates/service.yaml b/charts/api/charts/payment/templates/api-payment-service.yaml.tpl similarity index 100% rename from charts/api/charts/payment/templates/service.yaml rename to charts/api/charts/payment/templates/api-payment-service.yaml.tpl diff --git a/charts/api/charts/payment/templates/deployment.yaml b/charts/api/charts/payment/templates/deployment.yaml deleted file mode 100644 index d0e3111..0000000 --- a/charts/api/charts/payment/templates/deployment.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "api-payment.fullname" . }} - labels: - {{- include "api-payment.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.apiPayment.replicaCount }} - selector: - matchLabels: - app: {{ include "api-payment.fullname" . }} - template: - metadata: - labels: - app: {{ include "api-payment.fullname" . }} - spec: - containers: - - name: payment - image: "{{ .Values.apiPayment.image.registry }}/{{ .Values.apiPayment.image.repository }}:{{ .Values.apiPayment.image.tag }}" - imagePullPolicy: {{ .Values.apiPayment.image.pullPolicy }} - ports: - - containerPort: {{ .Values.apiPayment.service.port }} \ No newline at end of file diff --git a/charts/api/charts/payment/values.yaml b/charts/api/charts/payment/values.yaml index 9511a7c..b3e4073 100644 --- a/charts/api/charts/payment/values.yaml +++ b/charts/api/charts/payment/values.yaml @@ -16,4 +16,23 @@ apiPayment: port: 3306 name: payment username: rookies - password: rookies \ No newline at end of file + password: rookies + +apiPaymentDatabase: + replicaCount: 1 + + auth: + rootPassword: "rookies" + database: payment + username: rookies + password: rookies + + service: + name: api-payment-database-service + type: ClusterIP + port: 3306 + + persistence: + enabled: true + size: 8Gi + storageClass: "" \ No newline at end of file diff --git a/charts/api/charts/user/Chart.yaml b/charts/api/charts/user/Chart.yaml index d66719f..873c83c 100644 --- a/charts/api/charts/user/Chart.yaml +++ b/charts/api/charts/user/Chart.yaml @@ -8,4 +8,5 @@ appVersion: "1.0.0" dependencies: - name: api-user-database version: 0.1.0 - repository: "file://./charts/database" \ No newline at end of file + repository: "file://./charts/database" + alias: apiUserDatabase \ No newline at end of file diff --git a/charts/api/charts/user/templates/_helpers.tpl b/charts/api/charts/user/templates/_helpers.tpl index 8f5c8b3..8e013d7 100644 --- a/charts/api/charts/user/templates/_helpers.tpl +++ b/charts/api/charts/user/templates/_helpers.tpl @@ -9,14 +9,14 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{- define "api-user.servicename" -}} -{{- if .Values.global.service.apiUser }} -{{- .Values.global.service.apiUser | trunc 63 | trimSuffix "-" }} -{{- else if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} +{{- if .Values.global.service.apiUser -}} +{{- .Values.global.service.apiUser | trunc 63 | trimSuffix "-" -}} +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} api-user-service -{{- end }} -{{- end }} +{{- end -}} +{{- end -}} {{- define "api-user.exposelabel" -}} {{- if .Values.global.apiGateway.serviceLabel }} @@ -24,4 +24,19 @@ api-user-service {{- else }} expose-via-spring-gateway {{- end }} -{{- end }} \ No newline at end of file +{{- end }} + +{{- define "api-user.kafka.url" -}} +{{- $g := .Values.global | default (dict) -}} +{{- $svc := $g.service | default (dict) -}} +{{- $name := $svc.kafka | default "kafka-service" -}} +{{- $name -}}.kafka.svc.cluster.local:9092 +{{- end -}} + +{{- define "api-user.database.url" -}} +jdbc:mariadb://{{ .Values.global.service.apiUserDatabaseService | default "api-user-database-service" }}:3306/{{ .Values.apiUser.database.name }} +{{- end -}} + +{{- define "api-user.booking.url" -}} +{{ printf "http://%s.booking.svc.cluster.local:8080" (default "kafka-service" .Values.global.service.apiBooking) }} +{{- end -}} \ No newline at end of file diff --git a/charts/api/charts/user/templates/api-user-deployment.yaml.tpl b/charts/api/charts/user/templates/api-user-deployment.yaml.tpl new file mode 100644 index 0000000..22bfa3b --- /dev/null +++ b/charts/api/charts/user/templates/api-user-deployment.yaml.tpl @@ -0,0 +1,130 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "api-user.fullname" . }} + labels: + {{- include "api-user.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.apiUser.replicaCount }} + selector: + matchLabels: + app: {{ include "api-user.fullname" . }} + template: + metadata: + labels: + app: {{ include "api-user.fullname" . }} + spec: + containers: + - name: user + image: "{{ .Values.apiUser.image.registry }}/{{ .Values.apiUser.image.repository }}:{{ .Values.apiUser.image.tag }}" + imagePullPolicy: {{ .Values.apiUser.image.pullPolicy }} + ports: + - containerPort: {{ .Values.apiUser.service.port }} + env: + + # Kakao + - name: KAKAO_REDIRECT_URL + value: {{ printf "https://api.%s" .Values.global.domain | quote }} + + - name: KAKAO_REST_API_KEY + valueFrom: + secretKeyRef: + name: api-user-secret + key: KAKAO_REST_API_KEY + - name: KAKAO_ADMIN_KEY + valueFrom: + secretKeyRef: + name: api-user-secret + key: KAKAO_ADMIN_KEY + + # Mail + - name: MAIL_USERNAME + valueFrom: + secretKeyRef: + name: api-user-secret + key: MAIL_USERNAME + - name: MAIL_PASSWORD + valueFrom: + secretKeyRef: + name: api-user-secret + key: MAIL_PASSWORD + + # Database + - name: DB_URL + value: {{ include "api-user.database.url" . }} + - name: DB_USERNAME + valueFrom: + secretKeyRef: + name: api-user-secret + key: DB_USERNAME + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: api-user-secret + key: DB_PASSWORD + + # Kafka + - name: KAFKA_SERVERS + value: {{ include "api-user.kafka.url" . }} + + # Kafka + - name: BOOKING_BASE_API + value: {{ include "api-user.booking.url" . }} + + - name: FRONTEND_URL + value: {{ printf "https://www.%s" .Values.global.domain | quote }} + + # Files + - name: JWT_PRIVATE_PEM_PATH + value: "file:/etc/keys/private.pem" + - name: JWT_PUBLIC_PEM_PATH + value: "file:/etc/keys/public.pem" + - name: FIREBASE_KEY_PATH + value: "/etc/firebase/firebase-adminsdk.json" + + + volumeMounts: + - name: jwt-keys + mountPath: /etc/keys + readOnly: true + + - name: firebase-keys + mountPath: /etc/firebase + readOnly: true + volumes: + - name: jwt-keys + secret: + secretName: api-user-secret + items: + - key: JWT_PRIVATE_PEM_PATH + path: private.pem + - key: JWT_PUBLIC_PEM_PATH + path: public.pem + - key: JWT_PUBLIC_PEM_PATH + path: public.pem + - name: firebase-keys + secret: + secretName: api-user-secret + items: + - key: FIREBASE_KEY_PATH + path: firebase-adminsdk.json + + resources: + requests: + cpu: {{ .Values.apiUser.resources.requests.cpu | default "256m" }} + memory: {{ .Values.apiUser.resources.requests.memory | default "256Mi" }} + limits: + cpu: {{ .Values.apiUser.resources.limits.cpu | default "500m" }} + memory: {{ .Values.apiUser.resources.limits.memory | default "1024Mi" }} + # livenessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiUser.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 10 + # readinessProbe: + # httpGet: + # path: /actuator/health + # port: {{ .Values.apiUser.service.port }} + # initialDelaySeconds: 60 + # periodSeconds: 5 \ No newline at end of file diff --git a/charts/api/charts/user/templates/service.yaml b/charts/api/charts/user/templates/api-user-service.yaml.tpl similarity index 86% rename from charts/api/charts/user/templates/service.yaml rename to charts/api/charts/user/templates/api-user-service.yaml.tpl index 0cb27d3..0403949 100644 --- a/charts/api/charts/user/templates/service.yaml +++ b/charts/api/charts/user/templates/api-user-service.yaml.tpl @@ -11,4 +11,5 @@ spec: app: {{ include "api-user.fullname" . }} ports: - port: {{ .Values.apiUser.service.port }} - targetPort: {{ .Values.apiUser.service.port }} \ No newline at end of file + targetPort: {{ .Values.apiUser.service.port }} + \ No newline at end of file diff --git a/charts/api/charts/user/templates/deployment.yaml b/charts/api/charts/user/templates/deployment.yaml deleted file mode 100644 index 46c62a5..0000000 --- a/charts/api/charts/user/templates/deployment.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "api-user.fullname" . }} - labels: - {{- include "api-user.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.apiUser.replicaCount }} - selector: - matchLabels: - app: {{ include "api-user.fullname" . }} - template: - metadata: - labels: - app: {{ include "api-user.fullname" . }} - spec: - containers: - - name: user - image: "{{ .Values.apiUser.image.registry }}/{{ .Values.apiUser.image.repository }}:{{ .Values.apiUser.image.tag }}" - imagePullPolicy: {{ .Values.apiUser.image.pullPolicy }} - ports: - - containerPort: {{ .Values.apiUser.service.port }} \ No newline at end of file diff --git a/charts/api/charts/user/values.yaml b/charts/api/charts/user/values.yaml index c1a87f0..1ce3bfc 100644 --- a/charts/api/charts/user/values.yaml +++ b/charts/api/charts/user/values.yaml @@ -16,4 +16,26 @@ apiUser: port: 3306 name: user username: rookies - password: rookies \ No newline at end of file + password: rookies + + login: + uri: /auth/signup/kakao + +apiUserDatabase: + replicaCount: 1 + + auth: + rootPassword: "rookies" + database: user + username: rookies + password: rookies + + service: + name: api-user-database-service + type: ClusterIP + port: 3306 + + persistence: + enabled: true + size: 8Gi + storageClass: "" \ No newline at end of file diff --git a/charts/api/charts/messageTest/Chart.yaml b/charts/db-proxy/Chart.yaml similarity index 54% rename from charts/api/charts/messageTest/Chart.yaml rename to charts/db-proxy/Chart.yaml index e00b78f..0ddfaed 100644 --- a/charts/api/charts/messageTest/Chart.yaml +++ b/charts/db-proxy/Chart.yaml @@ -1,6 +1,7 @@ apiVersion: v2 -name: apiMessage -description: apiMessage +name: db-proxy +description: Helm chart for User Service type: application version: 0.1.0 appVersion: "1.0.0" + diff --git a/charts/db-proxy/templates/_helpers.tpl b/charts/db-proxy/templates/_helpers.tpl new file mode 100644 index 0000000..1f8fd78 --- /dev/null +++ b/charts/db-proxy/templates/_helpers.tpl @@ -0,0 +1,3 @@ +{{- define "db-proxy.name" -}} +db-porxy-haproxy-gateway +{{- end -}} \ No newline at end of file diff --git a/charts/db-proxy/templates/db-proxy-gateway-deployment.yaml.tpl b/charts/db-proxy/templates/db-proxy-gateway-deployment.yaml.tpl new file mode 100644 index 0000000..75b827f --- /dev/null +++ b/charts/db-proxy/templates/db-proxy-gateway-deployment.yaml.tpl @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "db-proxy.name" . }} + namespace: db-proxy +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "db-proxy.name" . }} + template: + metadata: + labels: + app: {{ include "db-proxy.name" . }} + spec: + containers: + - name: haproxy + image: haproxy:2.8 + volumeMounts: + - name: haproxy-config + mountPath: /usr/local/etc/haproxy + volumes: + - name: haproxy-config + configMap: + name: haproxy-config \ No newline at end of file diff --git a/charts/db-proxy/templates/db-proxy-gateway-service.yaml.tpl b/charts/db-proxy/templates/db-proxy-gateway-service.yaml.tpl new file mode 100644 index 0000000..cfaef1a --- /dev/null +++ b/charts/db-proxy/templates/db-proxy-gateway-service.yaml.tpl @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "db-proxy.name" . }}-svc + namespace: db-proxy +spec: + type: LoadBalancer + selector: + app: {{ include "db-proxy.name" . }} + ports: + - name: payment-db + port: {{ .Values.dbProxy.payment.port }} + targetPort: {{ .Values.dbProxy.payment.targetPort }} + - name: user-db + port: {{ .Values.dbProxy.user.port }} + targetPort: {{ .Values.dbProxy.user.targetPort }} + - name: festival-db + port: {{ .Values.dbProxy.festival.port }} + targetPort: {{ .Values.dbProxy.festival.targetPort }} + - name: booking-db + port: {{ .Values.dbProxy.booking.port }} + targetPort: {{ .Values.dbProxy.booking.targetPort }} + - name: kafka-ui + port: {{ .Values.dbProxy.kafkaUi.port }} + targetPort: {{ .Values.dbProxy.kafkaUi.targetPort }} + - name: grafana + port: {{ .Values.dbProxy.grafana.port }} + targetPort: 4011 \ No newline at end of file diff --git a/charts/db-proxy/templates/db-proxy-haproxy-config.yaml.tpl b/charts/db-proxy/templates/db-proxy-haproxy-config.yaml.tpl new file mode 100644 index 0000000..d5b2267 --- /dev/null +++ b/charts/db-proxy/templates/db-proxy-haproxy-config.yaml.tpl @@ -0,0 +1,48 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: haproxy-config + namespace: db-proxy +data: + haproxy.cfg: | + + global + log stdout format raw local0 + + defaults + log global + mode tcp + option tcplog + timeout connect 10s + timeout client 1m + timeout server 1m + + listen payment-db + bind *:{{ .Values.dbProxy.payment.port }} + mode tcp + server payment-db-svc {{ .Values.global.service.apiPaymentDatabase }}.payment.svc.cluster.local:3306 check + + listen user-db + bind *:{{ .Values.dbProxy.user.port }} + mode tcp + server user-db-svc {{.Values.global.service.apiUserDatabase }}.user.svc.cluster.local:3306 check + + listen festival-db + bind *:{{ .Values.dbProxy.festival.port }} + mode tcp + server festival-db-svc {{ .Values.global.service.apiFestivalDatabase }}.festival.svc.cluster.local:3306 check + + listen booking-db + bind *:{{ .Values.dbProxy.booking.port }} + mode tcp + server booking-db-svc {{ .Values.global.service.apiBookingDatabase }}.booking.svc.cluster.local:3306 check + + listen kafka-ui + bind *:8080 + mode http + server kafka-ui kafka-rookies-kafka-ui.kafka.svc.cluster.local:8080 check + + listen grafana + bind *:{{ .Values.dbProxy.grafana.port }} + mode http + server monitoring-grafana monitoring-grafana.monitoring.svc.cluster.local:80 \ No newline at end of file diff --git a/charts/db-proxy/values.yaml b/charts/db-proxy/values.yaml new file mode 100644 index 0000000..afe7313 --- /dev/null +++ b/charts/db-proxy/values.yaml @@ -0,0 +1,19 @@ +dbProxy: + payment: + port: 4000 + targetPort: 4000 + user: + port: 4001 + targetPort: 4001 + festival: + port: 4002 + targetPort: 4002 + booking: + port: 4003 + targetPort: 4003 + kafkaUi: + port: 4010 + targetPort: 8080 + grafana: + port: 4011 + targetPort: 80 \ No newline at end of file diff --git a/charts/kafka/templates/kafka-statefulset.yaml.tpl b/charts/kafka/templates/kafka-statefulset.yaml.tpl index 8fad6c0..fab35ca 100644 --- a/charts/kafka/templates/kafka-statefulset.yaml.tpl +++ b/charts/kafka/templates/kafka-statefulset.yaml.tpl @@ -97,10 +97,7 @@ spec: chmod 644 ${FINAL_SERVER_PROPERTIES_PATH} ${LOG4J_PROPERTIES_PATH} ${TOOLS_LOG4J_PROPERTIES_PATH} chown 1001:1001 ${FINAL_SERVER_PROPERTIES_PATH} ${LOG4J_PROPERTIES_PATH} ${TOOLS_LOG4J_PROPERTIES_PATH} - echo "Formatting Kafka data directory..." - /opt/bitnami/kafka/bin/kafka-storage.sh format \ - -t {{ .Values.kafka.kafkaGlobalClusterId | default "pYdR4Xe6T9K7zTArYtR9XA" | quote }} \ - -c /opt/bitnami/kafka/config/server.properties + echo "All configuration files created and permissions set." @@ -149,7 +146,16 @@ spec: rm -r "/bitnami/kafka/data/lost+found" fi # Bitnami Kafka 시작 스크립트 실행 + + + echo "Formatting Kafka data directory..." + /opt/bitnami/kafka/bin/kafka-storage.sh format \ + -t {{ .Values.kafka.kafkaGlobalClusterId | default "pYdR4Xe6T9K7zTArYtR9XA" | quote }} \ + -c /opt/bitnami/kafka/config/server.properties + + exec /opt/bitnami/scripts/kafka/run.sh + resources: {{ toYaml .Values.kafka.resources | nindent 12 }} nodeSelector: diff --git a/charts/nginx-admin/Chart.yaml b/charts/nginx-admin/Chart.yaml deleted file mode 100644 index 95ef16e..0000000 --- a/charts/nginx-admin/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: nginx-admin -description: A Helm chart for admin Nginx reverse proxy -type: application -version: 0.1.0 -appVersion: "1.16.0" \ No newline at end of file diff --git a/charts/nginx-admin/Dockerfile b/charts/nginx-admin/Dockerfile deleted file mode 100644 index 494b30a..0000000 --- a/charts/nginx-admin/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# 빌드 -FROM node:22 AS builder - -WORKDIR /app - -COPY package*.json ./ - -RUN npm install - -COPY . . - -RUN npm run build - -# 배포 -FROM nginx:latest - -COPY nginx.conf /etc/nginx/nginx.conf - - -RUN mkdir -p /app/log/nginx/client && chown -R nginx:nginx /app/log && chmod -R 755 /app/log - -RUN rm -f /etc/nginx/conf.d/default.conf - -COPY --from=builder /app/dist /usr/share/nginx/html - -EXPOSE 80 - -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/charts/nginx-admin/nginx.conf b/charts/nginx-admin/nginx.conf deleted file mode 100644 index 688cbc4..0000000 --- a/charts/nginx-admin/nginx.conf +++ /dev/null @@ -1,37 +0,0 @@ -user nginx; -worker_processes auto; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - keepalive_timeout 65; - - include /etc/nginx/conf.d/*.conf; - - server { - listen 80; - server_name localhost; - - root /usr/share/nginx/html; - index index.html; - - location / { - try_files $uri $uri/ /index.html; - } - } -} diff --git a/charts/nginx-admin/templates/_helpers.tpl b/charts/nginx-admin/templates/_helpers.tpl deleted file mode 100644 index 1456f71..0000000 --- a/charts/nginx-admin/templates/_helpers.tpl +++ /dev/null @@ -1,71 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "nginx-admin.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - - -{{- define "nginx-admin.serviceName" -}} -{{- $g := .Values.global | default (dict) -}} -{{- $svc := $g.service | default (dict) -}} -{{- $name := $svc.admin | default "nginx-admin-service" -}} -{{- $name -}} -{{- 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 "nginx-admin.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 "nginx-admin.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "nginx-admin.labels" -}} -helm.sh/chart: {{ include "nginx-admin.chart" . }} -{{ include "nginx-admin.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "nginx-admin.selectorLabels" -}} -app.kubernetes.io/name: {{ include "nginx-admin.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "nginx-admin.serviceAccountName" -}} -{{- if .Values.nginxAdmin.serviceAccount.create }} -{{- default (include "nginx-admin.fullname" .) .Values.nginxAdmin.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.nginxAdmin.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/charts/nginx-admin/templates/configmap.yaml b/charts/nginx-admin/templates/configmap.yaml deleted file mode 100644 index d7940d9..0000000 --- a/charts/nginx-admin/templates/configmap.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "nginx-admin.fullname" . }}-config -data: - nginx.conf: | -{{ .Files.Get "nginx.conf" | indent 4 }} diff --git a/charts/nginx-admin/templates/deployment.yaml b/charts/nginx-admin/templates/deployment.yaml deleted file mode 100644 index 677ea20..0000000 --- a/charts/nginx-admin/templates/deployment.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "nginx-admin.fullname" . }} - labels: - {{- include "nginx-admin.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.nginxAdmin.replicaCount }} - selector: - matchLabels: - {{- include "nginx-admin.selectorLabels" . | nindent 6 }} - template: - metadata: - labels: - {{- include "nginx-admin.selectorLabels" . | nindent 8 }} - spec: - containers: - - name: nginx - image: "{{ .Values.nginxAdmin.image.repository }}:{{ .Values.nginxAdmin.image.tag }}" - imagePullPolicy: {{ .Values.nginxAdmin.image.pullPolicy }} - ports: - - containerPort: 80 - volumeMounts: - - name: nginx-config - mountPath: /etc/nginx/nginx.conf - subPath: nginx.conf - volumes: - - name: nginx-config - configMap: - name: {{ include "nginx-admin.fullname" . }}-config \ No newline at end of file diff --git a/charts/nginx-admin/templates/service.yaml b/charts/nginx-admin/templates/service.yaml deleted file mode 100644 index 60cb7c6..0000000 --- a/charts/nginx-admin/templates/service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "nginx-admin.serviceName" . }} -spec: - selector: - app: {{ include "nginx-admin.fullname" . }} - ports: - - protocol: TCP - port: {{ .Values.nginxAdmin.service.port }} - targetPort: 80 - type: {{ .Values.nginxAdmin.service.type }} \ No newline at end of file diff --git a/charts/nginx-admin/values.yaml b/charts/nginx-admin/values.yaml deleted file mode 100644 index 6e52411..0000000 --- a/charts/nginx-admin/values.yaml +++ /dev/null @@ -1,11 +0,0 @@ -nginxAdmin: - replicaCount: 1 - - image: - repository: nginx - tag: latest - pullPolicy: IfNotPresent - - service: - type: ClusterIP - port: 80 \ No newline at end of file diff --git a/charts/nginx-client/nginx.conf b/charts/nginx-client/nginx.conf deleted file mode 100644 index 0f37fa5..0000000 --- a/charts/nginx-client/nginx.conf +++ /dev/null @@ -1,37 +0,0 @@ -user nginx; -worker_processes auto; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - keepalive_timeout 65; - - include /etc/nginx/conf.d/*.conf; - - server { - listen 80; - server_name localhost; - - root /usr/share/nginx/html; - index index.html; - - location / { - try_files $uri $uri/ /index.html; - } - } -} \ No newline at end of file diff --git a/charts/nginx-client/templates/_helpers.tpl b/charts/nginx-client/templates/_helpers.tpl index 453e16a..71c539a 100644 --- a/charts/nginx-client/templates/_helpers.tpl +++ b/charts/nginx-client/templates/_helpers.tpl @@ -1,10 +1,13 @@ -{{/* -Expand the name of the chart. -*/}} + +# ======== nginx client 설정 ======== +# 이름 설정 {{- define "nginx-client.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} + + +# Service 이름 설정 {{- define "nginx-client.serviceName" -}} {{- $g := .Values.global | default (dict) -}} {{- $svc := $g.service | default (dict) -}} @@ -13,12 +16,7 @@ Expand the name of the chart. {{- 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. -*/}} +# fullname 설정 {{- define "nginx-client.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} @@ -32,18 +30,17 @@ If release name contains chart name it will be used as a full name. {{- end }} {{- end }} -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "nginx-client.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} + + +# selectorLabels 설정 +{{- define "nginx-client.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nginx-client.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} -{{/* -Common labels -*/}} +# 라벨 설정 {{- define "nginx-client.labels" -}} -helm.sh/chart: {{ include "nginx-client.chart" . }} +helm.sh/chart: {{- printf " %s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{ include "nginx-client.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} @@ -51,21 +48,118 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} -{{/* -Selector labels -*/}} -{{- define "nginx-client.selectorLabels" -}} -app.kubernetes.io/name: {{ include "nginx-client.name" . }} + + +# ======== nginx mobile 설정 ======== +# 이름 설정 +{{- define "nginx-client-mobile.name" -}} +{{ include "nginx-client.name" . }}-mobile +{{- end }} + + +# fullname 설정 +{{- define "nginx-client-mobile.fullname" -}} +{{ include "nginx-client.fullname" . }}-mobile +{{- end }} + +# selectorLabel 설정 +{{- define "nginx-client-mobile.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nginx-client-mobile.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} -{{/* -Create the name of the service account to use -*/}} -{{- define "nginx-client.serviceAccountName" -}} -{{- if .Values.nginxClient.serviceAccount.create }} -{{- default (include "nginx-client.fullname" .) .Values.nginxClient.serviceAccount.name }} +# label 설정 +{{- define "nginx-client-mobile.labels" -}} +helm.sh/chart: {{- printf " %s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{ include "nginx-client-mobile.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + + + +# Service 설정 +{{- define "nginx-client-mobile.serviceName" -}} +{{- $g := .Values.global | default (dict) -}} +{{- $svc := $g.service | default (dict) -}} +{{- $name := $svc.mobile | default "nginx-mobile-service" -}} +{{- $name -}} +{{- end }} + + +# ===================== +# AWS Ingress 관련 설정 +# ==================== + +# Annotation 설정 +{{- define "nginx-client-ingress.aws.annotations.ingress" -}} +kubernetes.io/ingress.class: alb +alb.ingress.kubernetes.io/scheme: {{ .Values.nginxClient.ingress.aws.scheme | default "internet-facing" }} +alb.ingress.kubernetes.io/target-type: ip +alb.ingress.kubernetes.io/healthcheck-path: /health +alb.ingress.kubernetes.io/success-codes: "200" +{{- if eq .Values.nginxClient.ingress.tls true }} +alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]' +alb.ingress.kubernetes.io/certificate-arn: {{ .Values.nginxClient.ingress.aws.certificateArn | quote }} +alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}' +{{- else }} +alb.ingress.kubernetes.io/listen-ports: '[{"HTTP":80}]' +{{- end -}} +{{- end -}} + + + + + + +# ===================== +# GCE Ingress 관련 설정 +# ===================== + + +{{- define "nginx-client-ingress.gce.annotations.service" -}} +kubernetes.io/ingress.class: gce +cloud.google.com/backend-config: '{"ports":{"http":"{{ include "nginx-client-ingress.gce.backendconfing.name" . | trim }}"}}' +{{- end -}} + +{{- define "nginx-client-ingress.gce.annotations.ingress" -}} +kubernetes.io/ingress.class: gce +kubernetes.io/ingress.global-static-ip-name: {{ .Values.nginxClient.ingress.gce.ipName | default "rookies-tkcit-static-ip" }} +{{- end -}} + + +{{- define "nginx-client.serviceaccountname" -}} +{{ include "nginx-client.fullname" . }}-sa +{{- end -}} + + + +# +# Ingress 관련 설정 +# +{{- define "nginx-client-ingress.url" -}} +{{- if .Values.global.domain -}} +{{ .Values.global.domain }} +{{- else -}} +rookies-tekcit.com +{{- end }} +{{- end }} + + +{{- define "nginx-client-ingress.clientHost" -}} +{{- if .Values.global.domain }} +{{- printf "www.%s" .Values.global.domain -}} {{- else }} -{{- default "default" .Values.nginxClient.serviceAccount.name }} +www.rookies-tekcit.com +{{- end }} +{{- end }} + +{{- define "nginx-client-ingress.mobileHost" -}} +{{- if .Values.global.domain }} +{{- printf "m.%s" .Values.global.domain -}} +{{- else }} +m.rookies-tekcit.com +{{- end }} {{- end }} -{{- end }} \ No newline at end of file diff --git a/charts/nginx-client/templates/configmap.yaml b/charts/nginx-client/templates/configmap.yaml deleted file mode 100644 index e124ebd..0000000 --- a/charts/nginx-client/templates/configmap.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "nginx-client.fullname" . }}-config -data: - nginx.conf: | -{{ .Files.Get "nginx.conf" | indent 4 }} diff --git a/charts/nginx-client/templates/nginx-client-configmap.yaml.tpl b/charts/nginx-client/templates/nginx-client-configmap.yaml.tpl new file mode 100644 index 0000000..d00f35f --- /dev/null +++ b/charts/nginx-client/templates/nginx-client-configmap.yaml.tpl @@ -0,0 +1,63 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "nginx-client.fullname" . }}-config +data: + default-pc.conf: | + map $http_user_agent $redirect_domain { + default www.{{ .Values.global.domain }}; + "~*Mobile|Android|iPhone" m.{{ .Values.global.domain }}; + } + + server { + listen 80; + server_name www.{{ .Values.global.domain }} m.{{ .Values.global.domain }}; + + if ($http_user_agent = "ELB-HealthChecker/2.0") { + return 200 "healthy"; + } + + if ($host != $redirect_domain) { + return 302 https://$redirect_domain$request_uri; + } + + root /usr/share/nginx/html; + index index.html; + + location / { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires 0; + try_files $uri /index.html; + } + } + + default-mobile.conf: | + map $http_user_agent $redirect_domain { + default www.{{ .Values.global.domain }}; + "~*Mobile|Android|iPhone" m.{{ .Values.global.domain }}; + } + + server { + listen 80; + server_name www.{{ .Values.global.domain }} m.{{ .Values.global.domain }}; + + if ($http_user_agent = "ELB-HealthChecker/2.0") { + return 200 "healthy"; + } + + if ($host != $redirect_domain) { + return 302 https://$redirect_domain$request_uri; + } + + root /usr/share/nginx/html; + index index.html; + + location / { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires 0; + try_files $uri /index.html; + } + } + diff --git a/charts/nginx-client/templates/deployment.yaml b/charts/nginx-client/templates/nginx-client-deployment.yaml.tpl similarity index 54% rename from charts/nginx-client/templates/deployment.yaml rename to charts/nginx-client/templates/nginx-client-deployment.yaml.tpl index b8df995..c242d1a 100644 --- a/charts/nginx-client/templates/deployment.yaml +++ b/charts/nginx-client/templates/nginx-client-deployment.yaml.tpl @@ -1,8 +1,10 @@ + apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "nginx-client.fullname" . }} labels: + app: {{ include "nginx-client.name" . }} {{- include "nginx-client.labels" . | nindent 4 }} spec: replicas: {{ .Values.nginxClient.replicaCount }} @@ -12,19 +14,26 @@ spec: template: metadata: labels: + app: {{ include "nginx-client.name" . }} {{- include "nginx-client.selectorLabels" . | nindent 8 }} spec: containers: - name: nginx - image: "{{ .Values.nginxClient.image.repository }}:{{ .Values.nginxClient.image.tag }}" + image: "{{ .Values.nginxClient.image.registry }}/{{ .Values.nginxClient.image.repository }}:{{ .Values.nginxClient.image.tag }}" imagePullPolicy: {{ .Values.nginxClient.image.pullPolicy }} ports: - containerPort: 80 volumeMounts: - - name: nginx-config - mountPath: /etc/nginx/nginx.conf - subPath: nginx.conf + - name: env-secret + mountPath: /usr/share/nginx/html/env.js + subPath: env.js + - name: nginx-conf + mountPath: /etc/nginx/conf.d/default.conf + subPath: default-pc.conf volumes: - - name: nginx-config + - name: env-secret + secret: + secretName: nginx-client-secret + - name: nginx-conf configMap: name: {{ include "nginx-client.fullname" . }}-config \ No newline at end of file diff --git a/charts/nginx-client/templates/nginx-client-ingress.yaml.tpl b/charts/nginx-client/templates/nginx-client-ingress.yaml.tpl new file mode 100644 index 0000000..d33010a --- /dev/null +++ b/charts/nginx-client/templates/nginx-client-ingress.yaml.tpl @@ -0,0 +1,47 @@ +{{- if .Values.nginxClient.ingress }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "nginx-client.fullname" . }} + annotations: + {{ if eq .Values.nginxClient.ingress.mode "gce" }} + {{- include "nginx-client-ingress.gce.annotations.ingress" . | nindent 4 }} + {{- else if eq .Values.nginxClient.ingress.mode "aws" -}} + {{- include "nginx-client-ingress.aws.annotations.ingress" . | nindent 4 }} + {{ end }} + +spec: + rules: + - host: {{ include "nginx-client-ingress.clientHost" . }} + http: + paths: + - path: {{ .Values.nginxClient.ingress.path | default "/" }} + pathType: {{ .Values.nginxClient.ingress.pathType | default "Prefix" | title }} + backend: + service: + name: {{ include "nginx-client.serviceName" . }} + port: + number: {{ .Values.nginxClient.service.port }} + + - host: {{ include "nginx-client-ingress.mobileHost" . }} + http: + paths: + - path: {{ .Values.nginxClient.ingress.path | default "/" }} + pathType: {{ .Values.nginxClient.ingress.pathType | default "Prefix" | title }} + backend: + service: + name: {{ include "nginx-client-mobile.serviceName" . }} + port: + number: {{ .Values.nginxClient.service.port }} + + + {{- if and (eq .Values.nginxClient.ingress.mode "gce") .Values.nginxClient.ingress.tls }} + tls: + - hosts: + - {{ include "nginx-client-ingress.clientHost" . }} + secretName: {{ .Values.nginxClient.ingress.gce.tlsSecret | default "nginx-client-tls-secret" }} + - hosts: + - {{ include "nginx-client-ingress.mobileHost" . }} + secretName: {{ .Values.nginxClient.ingress.gce.tlsSecret | default "nginx-client-tls-secret" }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/nginx-client/templates/nginx-client-mobile-deployment.yaml.tpl b/charts/nginx-client/templates/nginx-client-mobile-deployment.yaml.tpl new file mode 100644 index 0000000..9a995fb --- /dev/null +++ b/charts/nginx-client/templates/nginx-client-mobile-deployment.yaml.tpl @@ -0,0 +1,39 @@ + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "nginx-client-mobile.fullname" . }} + labels: + app: {{ include "nginx-client-mobile.name" . }} + {{- include "nginx-client-mobile.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.nginxClientMobile.replicaCount }} + selector: + matchLabels: + {{- include "nginx-client-mobile.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + app: {{ include "nginx-client-mobile.name" . }} + {{- include "nginx-client-mobile.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: nginx + image: "{{ .Values.nginxClientMobile.image.registry }}/{{ .Values.nginxClientMobile.image.repository }}:{{ .Values.nginxClientMobile.image.tag }}" + imagePullPolicy: {{ .Values.nginxClientMobile.image.pullPolicy }} + ports: + - containerPort: 80 + volumeMounts: + - name: env-secret + mountPath: /usr/share/nginx/html/env.js + subPath: env.js + - name: nginx-conf + mountPath: /etc/nginx/conf.d/default.conf + subPath: default-mobile.conf + volumes: + - name: env-secret + secret: + secretName: nginx-client-secret + - name: nginx-conf + configMap: + name: {{ include "nginx-client.fullname" . }}-config \ No newline at end of file diff --git a/charts/nginx-client/templates/nginx-client-mobile-service.yaml.tpl b/charts/nginx-client/templates/nginx-client-mobile-service.yaml.tpl new file mode 100644 index 0000000..28370b0 --- /dev/null +++ b/charts/nginx-client/templates/nginx-client-mobile-service.yaml.tpl @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "nginx-client-mobile.serviceName" . }} +spec: + selector: + app: {{ include "nginx-client-mobile.fullname" . }} + ports: + - protocol: TCP + port: {{ .Values.nginxClientMobile.service.port }} + targetPort: 80 + type: {{ .Values.nginxClientMobile.service.type }} \ No newline at end of file diff --git a/charts/nginx-client/templates/service.yaml b/charts/nginx-client/templates/nginx-client-service.yaml.tpl similarity index 100% rename from charts/nginx-client/templates/service.yaml rename to charts/nginx-client/templates/nginx-client-service.yaml.tpl diff --git a/charts/nginx-client/values.yaml b/charts/nginx-client/values.yaml index 230286e..2057d08 100644 --- a/charts/nginx-client/values.yaml +++ b/charts/nginx-client/values.yaml @@ -1,11 +1,45 @@ +nginxClientMobile: + replicaCount: 1 + + image: + registry: rookiesdogun + repository: nginx-mobile + tag: latest + pullPolicy: IfNotPresent + + service: + type: ClusterIP + port: 80 + nginxClient: replicaCount: 1 image: - repository: nginx + registry: rookiesdogun + repository: nginx-client tag: latest pullPolicy: IfNotPresent service: type: ClusterIP - port: 80 \ No newline at end of file + port: 80 + + + + ingress: + mode: aws + port: + http: 80 + https: 443 + path: / + pathType: Prefix + tls: true + + gce: + ipName: rookies-tekcit-static-ip + backendConfigName: api-gateway-backendconfig + tlsSecret: nginx-client-tls-secret + aws: + scheme: "internet-facing" + certificateArn: "none" + serviceAccountName: aws-load-balancer-controller \ No newline at end of file diff --git a/charts/performance-test/Chart.yaml b/charts/performance-test/Chart.yaml new file mode 100644 index 0000000..2cdf83a --- /dev/null +++ b/charts/performance-test/Chart.yaml @@ -0,0 +1,26 @@ +apiVersion: v2 +name: rookies-app +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.0.0" + + +dependencies: + + - name: rookies-kafka + version: 1.0.0 + repository: file://./charts/kafka + + - name: rookies-api + version: 0.1.0 + repository: file://./charts/api + + - name: nginx-client + version: 1.0.0 + repository: file://./charts/nginx-client + + - name: rookies-infra + version: 1.0.0 + repository: file://./charts/infra + \ No newline at end of file diff --git a/charts/performance-test/values.yaml b/charts/performance-test/values.yaml new file mode 100644 index 0000000..6b661b8 --- /dev/null +++ b/charts/performance-test/values.yaml @@ -0,0 +1,30 @@ +argo-cd: + enabled: false + + +global: + service: + kafka: kafka-service + kafkaUi: kafka-ui-service + apiGateway: api-gateway-service + apiBooking: api-booking-service + apiBookingDatabase: api-booking-database-service + apiBookingRedis: api-booking-redis-service + apiFestival: api-festival-service + apiFestivalDatabase: api-festival-database-service + apiPayment: api-payment-service + apiPaymentDatabase: api-payment-database-service + apiUser: api-user-service + apiUserDatabase: api-user-database-service + + client: nginx-client-service + mobile: nginx-mobile-service + admin: nginx-admin-service + apiGateway: + serviceLabel: expose-via-spring-gateway + + namespace: + infra: infra + + url: rookies-tekcit.com + diff --git a/values.yaml b/values.yaml index 2f37b80..6b661b8 100644 --- a/values.yaml +++ b/values.yaml @@ -18,6 +18,7 @@ global: apiUserDatabase: api-user-database-service client: nginx-client-service + mobile: nginx-mobile-service admin: nginx-admin-service apiGateway: serviceLabel: expose-via-spring-gateway