🔥딱 8일간! 인프런x토스x허먼밀러 역대급 혜택

Application 기능으로 이해하기 - Configmap, Secret [미션3]

응용1 : Configmap의 환경변수들을 Secret을 사용해서 작성하고, App에서는 같은 결과가 나오도록 확인해 보세요.

  1. 쿠버네티스 대쉬보드에서 아래와 같이 Secret 생성(Configmap은 생략)


apiVersion: v1
kind: Secret
metadata:
  namespace: anotherclass-123
  name: api-tester-1231-properties
  labels:
    part-of: k8s-anotherclass
    component: backend-server
    name: api-tester
    instance: api-tester-1231
    version: 1.0.0
    managed-by: dashboard
stringData:
  spring_profiles_active: "dev"
  application_role: "ALL"
  postgresql_filepath: "/usr/src/myapp/datasource/dev/postgresql-info.yaml"
  1. 대쉬보드의 Secret에서 Configmap 환경변수 확인

image

  1. Deployment의 envFrom.secretRef 부분 업데이트

아래 명령어로 configMapRef ==> secretRef로 변경

kubectl edit -n anotherclass-123 deployments.apps api-tester-1231

image

응용2 : 반대로 Secret의 DB정보를 Configmap으로 만들어보고 App을 동작시켜 보세요

  1. 쿠버네티스 대쉬보드에서 아래와 같이 Configmap은 생성(Secret은 생략)


apiVersion: v1
kind: ConfigMap
metadata:
  namespace: anotherclass-123
  name: api-tester-1231-postgresql
  labels:
    part-of: k8s-anotherclass
    component: backend-server
    name: api-tester
    instance: api-tester-1231
    version: 1.0.0
    managed-by: dashboard
data:
  postgresql-info.yaml: |
    driver-class-name: "org.postgresql.Driver"
    url: "jdbc:postgresql://postgresql:5431"
    username: "dev"
    password: "dev123"
  1. 대쉬보드의 Configmap에서 Secret 환경변수 확인

image

  1. Deployment의 volumeMounts.name과 volumes 부분 업데이트

  • 아래 명령어로 수정

kubectl edit -n anotherclass-123 deployments.apps api-tester-1231

image

댓글을 작성해보세요.

채널톡 아이콘