apps/templates/internhasha-dev.yamlinternhasha-dev 서버 어플리케이션을 정의한다.waffle-world/apps/values.yaml에 정의되어 있는 source, destination, syncPolicy를 사용하여 EKS 클러스터에 배포된다.Application 리소스는 argocd 네임스페이스에, 해당 애플리케이션이 관리하는 k8s 리소스(Deployment, Service, ...) 등은 internhasha-dev에 배포된다.apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
namespace: argocd
name: internhasha-dev
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: {{ .Values.spec.source.repoURL }} # https://github.com/wafflestudio/waffle-world.git
targetRevision: HEAD
path: apps/internhasha-dev/internhasha
destination:
server: {{ .Values.spec.destination.server }} # https://kubernetes.default.svc
namespace: argocd
syncPolicy:
{{- .Values.spec.syncPolicy | toYaml | nindent 4 }}
apps/internhasha-dev/internhasha/internhasha-server.yamlinternhasha-dev 네임스페이스에서 배포된다.env로 직접 설정하였다.dev로 설정internhasha라는 이름의 ServiceAccount를 정의하여 Deployment에서 사용하였다.istio 리소스에서 dev-api-internhasha.wafflestudio.com 호스트로부터 오는 트래픽은 internhasha-server 서비스 리소스로 라우팅하도록 규칙 설정apiVersion: apps/v1
kind: Deployment
metadata:
name: internhasha-server
labels:
app: internhasha-server
namespace: internhasha-dev
spec:
replicas: 1
selector:
matchLabels:
app: internhasha-server
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
revisionHistoryLimit: 4
template:
metadata:
labels:
app: internhasha-server
spec:
serviceAccountName: internhasha
nodeSelector:
phase: dev
tolerations:
- effect: NoSchedule
key: phase
operator: Equal
value: dev
containers:
- image: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com/internhasha-dev/internhasha-server:12
name: internhasha-server
env:
- name: JAVA_OPTS
value: "-XX:InitialRAMPercentage=80.0 -XX:MaxRAMPercentage=80.0"
- name: SPRING_PROFILES_ACTIVE
value: "dev"
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
cpu: 200m
memory: 512Mi
ports:
- containerPort: 8080
startupProbe:
httpGet:
path: /actuator/health/startup
port: 8080
initialDelaySeconds: 10
failureThreshold: 20
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: internhasha
namespace: internhasha-dev
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::405906814034:role/internhasha-dev-role
---
apiVersion: v1
kind: Service
metadata:
namespace: internhasha-dev
name: internhasha-server
spec:
type: ClusterIP
selector:
app: internhasha-server
ports:
- port: 80
targetPort: 8080
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
namespace: internhasha-dev
name: internhasha-server
spec:
gateways:
- istio-ingress/waffle-ingressgateway
- mesh
hosts:
- dev-api-internhasha.wafflestudio.com
http:
- route:
- destination:
host: internhasha-server
misc/apps/namespace.yamlistio-injection을 통해 사이드카 프록시 주입을 설정하여 istio 리소스의 라우팅 기능이 동작하도록 한다.# ...
---
apiVersion: v1
kind: Namespace
metadata:
name: internhasha-dev
labels:
istio-injection: enabled
---
apiVersion: v1
kind: Namespace
metadata:
name: internhasha-prod
labels:
istio-injection: enabled
default 프로필로 실행)ServiceAccount가 정의되어 있지 않아 IRSA를 통한 Secrets Manager 접근이 불가능했음128mi, 256mi로 설정하여 Spring 앱 구동이 OOM으로 실패, Pod을 계속 새로 다시 만드는 문제상황이 발생하였음ServiceAccount와 Spring profile 환경변수를 추가Deployment에 해당 serviceAccountName를 사용하지 않아 여전히 IRSA 기능 불가능replicas:0으로 설정되며 일단 pod 생성을 멈추었음serviceAccountName 추가128mi에서 256mi로 증가- name: JAVA_OPTS
value: "-XX:InitialRAMPercentage=80.0 -XX:MaxRAMPercentage=80.0 # "가 닫히지 않음256mi에서 768Mi로 대폭 증가0/7 nodes are available: 2 Insufficient memory, 2 node(s) didn't match Pod's node affinity/selector, 3 node(s) had untolerated taint {phase: prod}. preemption: 0/7 nodes are available: 2 No preemption victims found for incoming pod, 5 Preemption is not helpful for scheduling.
0/7 nodes are available: 현재 7개의 노드 중 이 파드를 배포할 수 있는 노드가 0개2 Insufficient memory: 2개 노드는 메모리 부족2 node(s) ~ untolerated taint {phase: prod}: phase=dev 라벨이 붙은 노드에만 올라갈 수 있는 dev 파드는 5개의 phase=prod 라벨이 붙은 노드에 올라가지 못 함(2+3)768mi에서 512mi로 축소phase=dev 라벨이 붙은 노드에 성공적으로 추가되었음!internhasha:dev, internhasha:prod)를 추가하여 저장된 데이터를 구분하도록 하였다.⇒ 두 리소스를 접근하는데에는 별도의 IRSA 설정이 요구되진 않았다.
kubectl를 이용한 CLI 접근도 불가능하기 때문에 훨씬 제한적이고 엄격한 상황에서 배포가 이루어지는 느낌이었다.