secret이란?

configmap과 동일하게 key: value 값이 들어가고 mount와 env로 데이터를 passing 해주는 것 까지 동일함

근데 value에 있는 정보가 ASCII.text가 아니라 base64로 인코딩 된 정보가 value에 들어가게 되는 차이점이 존재함.

⇒ base64란 binary date(2진수)를 ASCII text로 바꿔주는 인코딩 기능을 함

Untitled

그래서 저장 될 때는 base64로 인코딩이 되고 정보 전달 후 다시 디코딩이 되어 읽을 수 있도록 하는 과정을 겪음

하지만 인코딩, 디코딩 과정을 겪어서 암호화를 한다고 생각하면 안되고 단지 Secret에 저장 될 때는 base64 형태로 저장이 되는 것을 알고 있으면 됌,

Untitled


  1. kubectl config use-context k8s

  2. kubectl create secret generic super-secret --from-literal=password=secretpass

    ⇒ secret(공홈) → Using Secrets as environment variables에서 Distribute credentials securely using Secrets 접속 → 접속 후 Create a Secret부분 → Create a Secret directly with kubectl 부분에서

kubectl create secret generic test-secret --from-literal='username=my-app' 
--from-literal='password=39528$vdg7Jb’

코드해석
 - generic -> key, value타입의 여러가지 정보를 넣을 타입으로 설정해줌
   (아래 사진 확인)
 - test-secrt -> secret 이름
	 username=my-app -> vey=value

수정 후
kubectl create secret generic super-secret --from-literal=password=secretpass

Untitled

    를 가져옴
  1. kubectl get secrets ⇒ 생성 된 secret 확인
  2. kubectl describe secrets super-secret