<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kubernetes &#8211; WONIZZ.LOG</title>
	<atom:link href="https://blog.wonizz.com/tag/kubernetes/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.wonizz.com</link>
	<description>AI 자동화를 직접 굴려 본 개발자의 실무 교훈</description>
	<lastBuildDate>Fri, 25 Sep 2026 03:24:49 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/08/wz-siteicon-512.png?fit=32%2C32&#038;ssl=1</url>
	<title>Kubernetes &#8211; WONIZZ.LOG</title>
	<link>https://blog.wonizz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">152411368</site>	<item>
		<title>[DevOps] AI 에이전트 권한 설계 — &#8216;되돌릴 수 있다&#8217;는 착각</title>
		<link>https://blog.wonizz.com/2026/08/03/ai-agent-permission-recovery-cost/</link>
					<comments>https://blog.wonizz.com/2026/08/03/ai-agent-permission-recovery-cost/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Mon, 03 Aug 2026 00:28:13 +0000</pubDate>
				<category><![CDATA[AI & LLM]]></category>
		<category><![CDATA[AI에이전트]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[권한설계]]></category>
		<guid isPermaLink="false">https://blog.wonizz.com/?p=2571</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>흔한 답은 "위험한 작업은 사람이 하고 안전한 건 맡긴다"입니다. 저도 그렇게 정했고, 다음 단계로 "되돌릴 수 있으면 맡겨도 된다" 는 기준을 세웠습니다. 그리고 이 두 번째 기준이 첫 번째보다 더 위험할 수 있다는 걸 사고 두 번을 겪고 나서야 알았습니다.</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2026/08/03/ai-agent-permission-recovery-cost/">[DevOps] AI 에이전트 권한 설계 — &#8216;되돌릴 수 있다&#8217;는 착각</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요. 정리하는 개발자 워니즈입니다. AI 에이전트를 운영에 붙이기 시작하면 반드시 마주치는 질문이 있습니다. <strong>AI 에이전트 권한을 어디까지 허용할 것인가.</strong></p>
<p>흔한 답은 &#8220;위험한 작업은 사람이 하고 안전한 건 맡긴다&#8221;입니다. 저도 그렇게 정했고, 다음 단계로 <strong>&#8220;되돌릴 수 있으면 맡겨도 된다&#8221;</strong> 는 기준을 세웠습니다. 그리고 이 두 번째 기준이 첫 번째보다 더 위험할 수 있다는 걸 사고 두 번을 겪고 나서야 알았습니다.</p>
<p>미리 밝히면 되돌림 가능성(one-way door / two-way door)이나 파급 범위(blast radius)는 운영 분야의 오래된 개념입니다. 이 글은 그 개념을 <strong>AI 에이전트 권한 설계에 적용하다가 제가 빠진 함정</strong>에 대한 기록입니다.</p>
<p>그러면 본격적으로 정리해보도록 하겠습니다.</p>
<h2>1. &#8216;위험한 작업&#8217;만으로는 규칙이 되지 않는다</h2>
<p><code>kubectl rollout restart</code>는 위험한가요?</p>
<p>답이 갈립니다. 무중단 배포에 레플리카가 3개면 부담이 적고, 레플리카 1개에 초기화가 40초 걸리는 서비스면 위험합니다. 트래픽이 적은 새벽이면 영향이 작지만, 그 시간엔 대응 인력도 없어서 복구는 오히려 늦어집니다.</p>
<p>즉 &#8220;위험도&#8221;는 맥락마다 답이 달라집니다. 사람이 매번 판단한다면 그걸로 충분하지만, <strong>에이전트에게 권한을 미리 나눠줘야 하는 상황</strong>에서는 사전에 분류 가능한 축이 필요합니다.</p>
<p>그래서 저는 이런 질문을 축으로 삼았습니다.</p>
<blockquote><p><strong>&#8220;이 작업이 잘못됐을 때 되돌릴 수 있는가.&#8221;</strong></p>
</blockquote>
<p>되돌릴 수 있으면 맡기고, 없으면 사람이 한다. 명확해 보였습니다. <strong>문제는 &#8220;되돌릴 수 있다&#8221;를 제가 잘못 판정하고 있었다는 것</strong>입니다.</p>
<h2>2. 사고 ①: 지시를 어겼는데 살았다 — 운이 좋았을 뿐</h2>
<p>에이전트에게 작업을 위임하며 브리프 맨 위에 이렇게 적었습니다.</p>
<blockquote><p><strong>push / PR 생성 / merge 금지. 로컬 커밋까지만.</strong></p>
</blockquote>
<p>모호하지 않았고 맨 위에 있었고 강조도 했습니다. 그런데 작업 후 원격을 확인해보니 <strong>PR이 생성돼 있었고 이미 머지까지 되어 있었습니다.</strong></p>
<p>여기서 두 가지를 배웠는데, 두 번째가 훨씬 중요했습니다.</p>
<p><strong>첫째, 프롬프트의 금지는 강제가 아닙니다.</strong> AI 에이전트 권한을 브리프 문장으로 제한하려 한 것 자체가 설계 실수였습니다. 브리프는 모델이 참고하는 컨텍스트일 뿐 실행을 차단하지 않습니다. 확률적으로는 대부분 지켜지지만, 시스템이 강제하는 경계와는 성격이 다릅니다. 근본 원인도 &#8220;불복종&#8221;이 아니라 <strong>애초에 필요 없는 쓰기 자격증명이 쥐어져 있었다는 과권한</strong>입니다.</p>
<p><strong>둘째, 제가 안 다친 이유는 &#8220;git이라서&#8221;가 아니었습니다.</strong> 저는 그때 &#8220;git은 revert가 있으니 되돌릴 수 있는 칸&#8221;이라고 정리했습니다. 나중에 보니 틀린 정리였습니다.</p>
<p><code>git revert</code>가 되돌리는 것은 <strong>저장소의 코드 상태뿐</strong>입니다.</p>
<ul>
<li>머지를 트리거로 <strong>배포가 돌았다면</strong> 배포된 결과는 revert되지 않습니다</li>
<li><strong>DB 마이그레이션</strong>이 실행됐다면 스키마는 그대로입니다</li>
<li>외부로 나간 <strong>알림·웹훅</strong>은 회수되지 않습니다</li>
<li><strong>시크릿이 커밋에 포함됐다면</strong> revert 후에도 git 이력에 남아 있어, 사실상 유출입니다</li>
</ul>
<p>제 경우는 <strong>이 부작용이 하나도 없는 변경이었습니다.</strong> 그래서 revert 하나로 끝났습니다. 되돌릴 수 있는 작업이라서가 아니라, <strong>되돌릴 게 코드밖에 없었던 상황이라서</strong> 살았습니다.</p>
<h2>3. 사고 ②: 파급 범위를 세지 않았다 — 이번엔 사람이 냈다</h2>
<p>두 번째 사고의 행위자는 에이전트가 아니라 <strong>저 자신</strong>입니다. 사람도 같은 방식으로 실패한다는 점에서 오히려 중요한 사례입니다.</p>
<p>로컬 머신을 정리하다가 부모 프로세스가 <code>launchd</code>인 가상화 관련 프로세스를 발견했습니다. &#8220;부모가 launchd니까 고아 프로세스&#8221;라고 판단하고 종료시켰습니다. 결과는 이랬습니다.</p>
<ul>
<li>그 프로세스는 컨테이너 런타임의 VM이었고, 통째로 내려감</li>
<li>그 위에서 돌던 <strong>MCP 서버 컨테이너 14개 전멸</strong></li>
<li>진행 중이던 다른 작업 세션 4개 중단</li>
</ul>
<p>판단부터 틀렸습니다. macOS에서 시스템 서비스가 launchd 아래 붙는 건 정상이라, 부모가 launchd라는 것만으로는 고아인지 아닌지 알 수 없습니다.</p>
<p>하지만 더 중요한 건 <strong>대상을 잘못 잡았다</strong>는 점입니다. 저는 &#8220;프로세스 1개 재시작&#8221;으로 봤지만 실제 대상은 <strong>VM 전체</strong>였고, 거기 얹힌 컨테이너와 세션까지가 영향 범위였습니다. 컨테이너는 VM과 함께 되살아났지만, <strong>끊긴 세션의 작업 맥락은 checkpoint가 없어 복구하지 못했습니다.</strong></p>
<blockquote><p><strong>영향 범위는 명령이 지목한 대상이 아니라, 그 대상에 의존하는 것들로 정의된다.</strong></p>
</blockquote>
<h2>4. 두 사고가 가리키는 한 가지</h2>
<p>두 사고는 달라 보이지만 같은 실수입니다.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th></th>
<th>내가 본 것</th>
<th>실제</th>
</tr>
</thead>
<tbody>
<tr>
<td>사고 ①</td>
<td>&#8220;git이니까 revert 가능&#8221;</td>
<td>되돌릴 게 코드뿐이었을 때만 참</td>
</tr>
<tr>
<td>사고 ②</td>
<td>&#8220;프로세스 1개 재시작&#8221;</td>
<td>대상은 VM, 영향은 컨테이너 14개 + 세션 4개</td>
</tr>
</tbody>
</table>
</figure>
<p>둘 다 <strong>&#8220;되돌릴 수 있다&#8221;를 실제 확인 없이 명령어 이름만 보고 판정</strong>했습니다.</p>
<blockquote><p><strong>되돌리는 명령이 존재한다는 것과 실제로 복구된다는 것은 다릅니다.</strong></p>
</blockquote>
<p><code>kubectl scale</code>은 되돌리는 명령이 있지만 <strong>이전 replica 수를 기록해 두지 않았다면</strong> 무엇으로 되돌릴지 모릅니다. HPA가 붙어 있으면 상태가 더 복잡해집니다. ConfigMap 수정은 <strong>기본적으로 변경 이력이 없어서</strong>, 바꾸기 전 값을 따로 저장하지 않았다면 복원할 원본이 없습니다. 게다가 잘못된 설정이 이미 데이터를 망가뜨렸다면 설정을 되돌려도 데이터는 그대로입니다.</p>
<h2>5. 그래서 표를 이렇게 바꿨습니다</h2>
<p>처음에 저는 명령을 복구 시간에 따라 한 줄로 세웠습니다. 그 표는 버렸습니다. <strong>복구 시간·데이터 손실·영향 범위·기밀성은 서로 환산되지 않는 별개의 축</strong>이라, 하나의 등급으로 합치는 순간 부정확해지기 때문입니다.</p>
<p>지금은 <strong>축별로 보고 그중 가장 엄격한 통제를 적용</strong>합니다. AI 에이전트 권한은 이 다섯 축을 모두 통과한 범위로만 열립니다.<br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/08/wz-d1.png?w=1200&#038;ssl=1" alt="AI 에이전트 권한을 복구 비용으로 나눈 표 — 복구 0초(읽기 전용, 단독 실행) / 분 단위(되돌리기 명령 존재, 사후 검증) / 시간 단위(재생성 필요, 사람 승인) / 복구 불가(원본 소실, 권한 없음)" /></p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>평가 축</th>
<th>물어볼 것</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>복구 가능성</strong></td>
<td>되돌리는 명령이 아니라 <strong>되돌릴 원본</strong>이 있는가 (이전 값 캡처·스냅샷·PITR)</td>
</tr>
<tr>
<td><strong>부작용</strong></td>
<td>배포·마이그레이션·외부 알림 등 <strong>되돌릴 수 없는 파생 동작</strong>이 있는가</td>
</tr>
<tr>
<td><strong>영향 범위</strong></td>
<td>이 대상에 <strong>의존하는 것</strong>이 무엇인가</td>
</tr>
<tr>
<td><strong>기밀성</strong></td>
<td>되돌려도 <strong>이미 나간 정보</strong>(로그의 토큰·개인정보)가 있는가</td>
</tr>
<tr>
<td><strong>검증 여부</strong></td>
<td>그 복구 절차를 <strong>실제로 해본 적 있는가</strong></td>
</tr>
</tbody>
</table>
</figure>
<p><strong>어느 한 축이라도 걸리면 등급을 올립니다.</strong> &#8220;복구 명령이 있으니 괜찮다&#8221;는 판단은 여기서 걸러집니다.</p>
<p>에이전트 권한은 이 평가를 통과한 범위로만 줍니다.</p>
<ul>
<li><strong>무변경 조회</strong> — 단독 실행. 단 로그에 토큰·개인정보가 섞일 수 있으므로 <strong>마스킹과 네임스페이스 제한이 전제</strong>입니다. 읽기라고 무조건 안전한 게 아닙니다</li>
<li><strong>되돌릴 원본이 확보된 변경</strong> — 사전 조건 검사 + 실행 후 검증. 이전 값 캡처가 없으면 이 칸에 넣지 않습니다</li>
<li><strong>부작용이 딸린 변경</strong>(배포·마이그레이션·외부 통신) — 사람이 실행</li>
<li><strong>검증된 백업이 없는 삭제</strong> — 권한 자체를 주지 않습니다</li>
</ul>
<h2>6. 이 판정을 시스템으로 강제하기</h2>
<p>사고 ①이 알려준 건 <strong>프롬프트로는 경계를 만들 수 없다</strong>는 것이었습니다. AI 에이전트 권한은 판정만으로 좁혀지지 않고, 실제 인증·인가 계층에 반영돼야 합니다. 판정 결과는 권한 설정으로 옮겨야 합니다.</p>
<blockquote><p>⚠️ 예시 구성입니다. 환경에 맞게 리소스를 조정하세요.</p>
</blockquote>
<pre class="wp-block-code"><code class="language-yaml">apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: agent-readonly
rules:
  - apiGroups: [""]                # core
    resources: ["pods", "events"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["pods/log"]
    verbs: ["get"]                 # 로그 조회는 get 이면 충분
  - apiGroups: ["events.k8s.io"]   # 클라이언트에 따라 이쪽 Event 도 필요
    resources: ["events"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources: ["deployments", "replicasets"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding                  # ClusterRoleBinding 이 아니라 네임스페이스 한정
metadata:
  name: agent-readonly
  namespace: my-service
subjects:
  - kind: ServiceAccount
    name: agent-sa
    namespace: my-service
roleRef:
  kind: ClusterRole
  name: agent-readonly
  apiGroup: rbac.authorization.k8s.io</code></pre>
<p>API 그룹별로 rule을 나눠야 하고(core의 <code>pods</code>와 <code>apps</code>의 <code>deployments</code>를 한 줄에 섞으면 존재하지 않는 조합이 됩니다), <strong>Role 정의만으로는 아무 권한도 생기지 않으므로 바인딩까지가 한 세트</strong>입니다. 동사 단위로 권한을 끊는 방식은 <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" target="_blank" rel="noopener">Kubernetes RBAC 공식 문서</a>의 기본 개념 그대로입니다.</p>
<p><strong>다만 RBAC 하나로는 부족합니다.</strong> 권한은 여러 바인딩의 합집합이라 다른 곳에서 쓰기를 주고 있으면 소용없고, 에이전트가 GitOps 저장소나 클라우드 자격증명 같은 <strong>다른 경로</strong>로 같은 결과를 만들 수 있으면 그 경로도 막아야 합니다. 사고 ①이 정확히 이 경우였습니다 — k8s가 아니라 <strong>git 자격증명이 열려 있었습니다.</strong></p>
<h3>파괴적 작업 앞에 영향 범위를 세는 절차를 둔다</h3>
<p>사고 ②의 교훈은 코드보다 순서에 가깝습니다. <strong>무엇을 지우기 전에 거기 의존하는 것을 먼저 센다.</strong> 브랜치라면 아직 반영되지 않은 커밋을, 프로세스라면 그 위에 얹힌 컨테이너와 세션을 셉니다.</p>
<p>이때 기준은 <strong>로컬 상태가 아니라 원격·실제 상태</strong>여야 합니다. 로컬 <code>main</code>이 오래됐으면 &#8220;미반영 커밋 0건&#8221;이라는 잘못된 안심을 얻게 됩니다. <code>git fetch</code> 후 원격 ref로 비교하고, cherry-pick으로 이미 반영된 커밋이 있는 워크플로라면 patch 단위 비교까지 필요합니다.</p>
<h3>보고가 아니라 상태를 확인한다</h3>
<p>사고 ①에서 에이전트는 &#8220;로컬 커밋까지 완료했습니다&#8221;라고 보고했습니다. 사실이 아니었습니다.</p>
<p>에이전트의 보고는 <strong>자기 행동에 대한 서술</strong>이지 시스템 상태가 아닙니다. 원격 브랜치와 PR 목록을 직접 조회해야 하고, 이때도 이름 일부만 맞춰 찾으면 다른 브랜치를 잡을 수 있으니 전체 ref로 정확히 질의합니다.</p>
<h2>7. 그래서 자동화를 포기했나</h2>
<p>아닙니다. AI 에이전트 권한을 무변경 조회로 좁혀도 얻을 게 많습니다.</p>
<p>장애 대응에서 시간이 걸리는 건 엔터를 치는 순간이 아니라 <strong>진단과 커맨드 작성</strong>입니다. 에이전트가 로그를 긁고 이벤트를 모으고 원인을 정리한 뒤 조치 커맨드를 <strong>문자열로 출력</strong>해주면 그 부분이 사라집니다.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>단계</th>
<th>주체</th>
<th>권한</th>
</tr>
</thead>
<tbody>
<tr>
<td>이상 감지</td>
<td>에이전트</td>
<td>조회</td>
</tr>
<tr>
<td>원인 분석</td>
<td>에이전트</td>
<td>조회</td>
</tr>
<tr>
<td>조치 커맨드 생성</td>
<td>에이전트</td>
<td>없음 (텍스트 출력)</td>
</tr>
<tr>
<td>검토·실행</td>
<td>사람</td>
<td>실행</td>
</tr>
<tr>
<td>결과 검증</td>
<td>에이전트</td>
<td>조회</td>
</tr>
</tbody>
</table>
</figure>
<p>사람의 역할이 &#8220;복사해서 붙여넣기&#8221;로 줄어드는 건 아닙니다. 에이전트가 만든 커맨드 자체가 틀릴 수 있어 <strong>대상과 예상 결과를 확인하는 검토</strong>는 남습니다. 다만 진단부터 직접 하는 것보다는 훨씬 짧습니다.</p>
<p>권한을 네트워크 레벨에서도 좁히고 싶다면 <a href="https://blog.wonizz.com/2024/03/06/kubernetes-networkpolicy/">Kubernetes NetworkPolicy 적용하기</a>에서 다룬 접근이 같은 사고방식의 연장입니다. 상태를 바꾸는 작업을 어디까지 자동화할지는 <a href="https://blog.wonizz.com/2024/07/24/devops-kubernetes-hpa/">Kubernetes HPA 실전 적용</a>에서 오토스케일링 사례로 정리한 적이 있습니다.<br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/08/wz-d2.png?w=1200&#038;ssl=1" alt="복구 비용은 파급 범위까지 더해서 센다 — 직접 대상(프로세스 1개, 복구 분 단위) → 의존 대상(컨테이너 14개, 세션 4개) → 실제 합계(장애 범위 확대, 사람 승인 구간)" /></p>
<h2>8. AI 에이전트 권한 설계 요약</h2>
<ul>
<li>&#8220;위험한 작업 금지&#8221;는 출발점일 뿐, 맥락마다 답이 달라 사전 분류가 안 된다</li>
<li><strong>되돌리는 명령의 존재가 복구 가능성을 보장하지 않는다.</strong> 되돌릴 <em>원본</em>이 있는지, 되돌릴 수 없는 <em>부작용</em>이 딸렸는지를 본다</li>
<li>복구 가능성·부작용·영향 범위·기밀성·검증 여부는 <strong>별개 축</strong>이다. 하나로 합치지 말고 <strong>가장 엄격한 통제를 적용</strong>한다</li>
<li>영향 범위는 명령이 지목한 대상이 아니라 <strong>거기 의존하는 것들</strong>로 정의된다</li>
<li>경계는 프롬프트가 아니라 <strong>RBAC + 불필요한 자격증명 회수 + 우회 경로 차단</strong>으로 만든다</li>
<li>에이전트의 완료 보고는 <strong>상태 실측으로 확인</strong>한다</li>
</ul>
<p><strong>당장 해보실 수 있는 것 하나</strong>를 남기겠습니다. 에이전트가 쓰는 ServiceAccount의 권한을 확인해보세요.</p>
<pre class="wp-block-code"><code class="language-bash">NS=my-service; SA=agent-sa
kubectl auth can-i --list \
  --as="system:serviceaccount:${NS}:${SA}" --namespace="$NS"</code></pre>
<p>이 출력은 해당 네임스페이스에서 <strong>Kubernetes API 서버가 허용하는 범위</strong>만 보여줍니다. admission 정책이나 다른 자격증명 경로는 따로 봐야 합니다. 그래도 여기에 <code>delete</code>나 <code>patch</code>가 보인다면, 최소한 그 부분은 시스템이 아니라 프롬프트로 막고 있다는 뜻입니다.</p>
<p>다음 글에서는 &#8220;되돌릴 원본이 확보된 변경&#8221; 칸을 실제로 어떻게 운영했는지, 사전 조건 검사를 어디서 실패했는지 정리해보겠습니다. 읽어주셔서 감사합니다.</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2026/08/03/ai-agent-permission-recovery-cost/">[DevOps] AI 에이전트 권한 설계 — &#8216;되돌릴 수 있다&#8217;는 착각</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2026/08/03/ai-agent-permission-recovery-cost/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2571</post-id>	</item>
		<item>
		<title>[Kubernetes] 쿠버네티스 Deployment 란?</title>
		<link>https://blog.wonizz.com/2019/09/17/kubernetes-deployment/</link>
					<comments>https://blog.wonizz.com/2019/09/17/kubernetes-deployment/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Tue, 17 Sep 2019 07:42:30 +0000</pubDate>
				<category><![CDATA[kubernetes]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=829</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번시간에는 kubernetes 의 Deployment라는 개념에 대해서 알아보는 시간을 갖도록 하겠습니다. 지난 시간까지는 Service 의 개념에 대해서 알아봤었는데요. 이번에는 Pod의 배포가 어떻게 되는지 확인해보도록 하겠습니다. 지난 글들은 아래를 참고 해주시면 됩니다. 쿠버네티스 1편 : 설치 가이드 쿠버네티스 2편 : pod 쿠버네티스 3편 : service 쿠버네티스 4편 : deployment 쿠버네티스 5편 :&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/09/17/kubernetes-deployment/">[Kubernetes] 쿠버네티스 Deployment 란?</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번시간에는 kubernetes 의 <code>Deployment</code>라는 개념에 대해서 알아보는 시간을 갖도록 하겠습니다. 지난 시간까지는 <a href="https://blog.wonizz.com/2019/08/21/kubernetes-service/">Service</a> 의 개념에 대해서 알아봤었는데요. 이번에는 Pod의 배포가 어떻게 되는지 확인해보도록 하겠습니다.</p>
<p>지난 글들은 아래를 참고 해주시면 됩니다.</p>
<ul>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/16/kubenetes-install-guide/">쿠버네티스 1편 : 설치 가이드</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/19/kubernetes-pod/">쿠버네티스 2편 : pod</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/21/kubernetes-service/">쿠버네티스 3편 : service</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/09/17/kubernetes-deployment/">쿠버네티스 4편 : deployment</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/10/28/kubernetes-pod-configuration/">쿠버네티스 5편 : pod 설정 </a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/01/kubernetes-deployment-strategies/">쿠버네티스 6편 : 배포 전략</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/07/kubernetes-volume/">쿠버네티스 7편 : volume</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/15/kubernetes-daemonset/">쿠버네티스 8편 : daemonset</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/27/kubernetes-cluster-terraform/">쿠버네티스 9편 : 테라폼을 통한 클러스터 구성</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/28/kubernetes-aws-eks-volume/">쿠버네티스 10편 : eks에서 volume 사용하기</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/12/20/kubernetes-helm/">쿠버네티스 11편 : helm</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/01/03/kubernetes-helm-chart-template/">쿠버네티스 12편 : helm chart template</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/01/14/kubernetes-helm-deploy/">쿠버네티스 13편 : helm deploy</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/05/26/kubernetes-fluentd-logging/">쿠버네티스 14편 : fluentd를 통한 log수집</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/06/03/kubernetes-helm-chartmuseum/">쿠버네티스 15편 : chartmuseum</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/06/05/kubernetes-deploy-tool-argocd/">쿠버네티스 16편 : 배포툴(ArgoCD 설치방법/사용법)</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2020/06/15/kubernetes-deploy-tool-notification//">쿠버네티스 17편 : 배포툴(ArgoCD 구성/알람)</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/08/24/kubernetes-autoscaling-hpa/">쿠버네티스 18편 : 쿠버네티스 Autoscailing</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2020/10/14/kubernetes-logging-architecture/">쿠버네티스 19편 : 쿠버네티스 로깅 아키텍처</a></li>
</ul>
<h2>1. ReplicaSet</h2>
<p>먼저 Deployment의 개념중에서 가장 중요한것은 <code>ReplicaSet</code>입니다. Replication Controller의 새로운 버전으로 Label  Selector를 통해 노드 상의 여러 Pod의 생성/복제/삭제 등의 라이프 싸이클을 관리합니다.</p>
<ol>
<li>지정한 Replica의 숫자만큼 Pod 수 생성/유지</li>
<li>Label  Selector를 통한 Pod 타겟팅</li>
</ol>
<h2>2. Deployment</h2>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/09/k8S_Deployment_main.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Deployment 란?" /></p>
<p>Kubernetes에서 어플리케이션 단위를 관리하는 Controller 이며 Kubernetes의 최소 유닛인 Pod에 대한 기준스펙을 정의한 Object이다.</p>
<p>Kubernetes에서는 각 Object를 독립적으로 생성하기 보다는 Deployment를 통해서 생성하는 것을 권장하고 있으며,  Pod와 ReplicaSet의 기준정보를 지정할 수 있다.</p>
<p>이러한 Deployment는</p>
<ol>
<li>Pod의 scale in / out 되는 기준을 정의한다.</li>
<li>Pod의 배포되고 update 되는 모든 버전을 추적할 수 있다.</li>
<li>배포된 Pod에 대한 rollback을 수행할 수 있다.</li>
</ol>
<p><strong>즉, 개념적으로 Deployment = ReplicaSet +Pod+history이며 ReplicaSet 을 만드는 것보다 더 윗 단계의 선언(추상표현)이다.</strong></p>
<h2>3. Templates</h2>
<p>Deployment는 위에서 보았듯이 Deployment안에 ReplicaSet과 Pod를 담을 수 잇는 구조로 되어 있습니다.</p>
<pre><code class="line-numbers">apiVersion: apps/v1beta1
kind: Deployment
metadata:
  # Deployment 객체의 Unique한 명칭
  name: deployment-example
spec:
  # Deployment label selector for pod
  selector:
    matchLabels:
      app: nginx
  # 3 Pods should exist at all times.
  replicas: 3
  template:
    metadata:
      labels:
        # Pod의 라벨
        app: nginx
    spec:
      containers:
      - name: nginx
        # Run this image
        image: nginx:1.10
</code></pre>
<h2>4. 실습예제</h2>
<p>그럼 위의 개념들을 기반으로 <code>Deployment</code>에 대한 실습을 진행해보도록 하겠습니다.</p>
<h3>4-1. Deployment 파일 생성 및 배포</h3>
<ul>
<li>Deployment yaml파일 생성</li>
</ul>
<pre><code class="line-numbers">apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-deployment
spec:
  selector:
    matchLabels:
      run: my-nginx
  replicas: 2
  template:
    metadata:
      labels:
        run: my-nginx
    spec:
      containers:
      - name: my-nginx-container
        image: nginx
        imagePullPolicy: Always
        ports:
        - containerPort: 80
</code></pre>
<ul>
<li>Deployment 생성</li>
</ul>
<pre><code class="line-numbers"># kubectl apply -f /lab/deployment/nginx-deployment.yaml --record=true
</code></pre>
<ul>
<li>결과확인</li>
</ul>
<pre><code class="line-numbers">root@master:/k8s/metallb# kubectl get deployment
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
curl                  1         1         1            1           110m
my-nginx-deployment   2         2         2            2           15s

root@master:/k8s/metallb# kubectl get rs
NAME                             DESIRED   CURRENT   READY   AGE
curl-5cc7b478b6                  1         1         1       111m
my-nginx-deployment-6877c7847d   2         2         2       65s

root@master:/k8s/metallb# kubectl get pod
NAME                                   READY   STATUS    RESTARTS   AGE
curl-5cc7b478b6-vwtmj                  1/1     Running   2          111m
my-nginx-deployment-6877c7847d-j6nml   1/1     Running   0          71s
my-nginx-deployment-6877c7847d-wr7c9   1/1     Running   0          71s
</code></pre>
<ul>
<li><code>DESIRED</code> displays the desired number of <em>replicas</em> of the application, which you define when you create the Deployment. This is the <em>desired state</em>.</li>
<li><code>CURRENT</code> displays how many replicas are currently running.</li>
<li><code>UP-TO-DATE</code> displays the number of replicas that have been updated to achieve the desired state.</li>
<li><code>AVAILABLE</code> displays how many replicas of the application are available to your users.</li>
<li><code>AGE</code> displays the amount of time that the application has been running.</li>
</ul>
<h3>4-2. Delete Pod (장애 상황 표현)</h3>
<p>장애가 발생한 상황을 가정하여 Pod한개를 삭제해보자</p>
<pre><code class="line-numbers">root@master:/k8s/metallb# kubectl get pod
NAME                                   READY   STATUS    RESTARTS   AGE
curl-5cc7b478b6-vwtmj                  1/1     Running   2          111m
my-nginx-deployment-6877c7847d-j6nml   1/1     Running   0          71s
my-nginx-deployment-6877c7847d-wr7c9   1/1     Running   0          71s

root@master:/k8s/metallb# kubectl delete pod my-nginx-deployment-6877c7847d-j6nml
pod "my-nginx-deployment-6877c7847d-j6nml" deleted

root@master:/k8s/metallb# kubectl get pod
NAME                                   READY   STATUS        RESTARTS   AGE
curl-5cc7b478b6-vwtmj                  1/1     Running       2          114m
my-nginx-deployment-6877c7847d-7pm2c   1/1     Running       0          5s
my-nginx-deployment-6877c7847d-j6nml   0/1     Terminating   0          4m4s
my-nginx-deployment-6877c7847d-wr7c9   1/1     Running       0          4m4s
</code></pre>
<p>삭제를 하자마자 Deployment에서 선언한 replicas에 의해 신규로 1개의 pod가 생성었음을 알 수 있다.</p>
<h3>4-3. Updating a Deployment</h3>
<ul>
<li>ReplicaSet Edit</li>
</ul>
<p>ReplicaSet의  replicas의 숫자를 2에서 4로 변경해봅시다.</p>
<pre><code class="line-numbers"># kubectl edit deployment my-nginx-deployment
spec:
  progressDeadlineSeconds: 600
  replicas: 4
</code></pre>
<p>결과확인 &#8211; 위에서 변경한 갯수대로 변경되었는지 확인합니다.</p>
<pre><code class="line-numbers">root@master:/k8s/metallb# kubectl get pod
NAME                                   READY   STATUS    RESTARTS   AGE
my-nginx-deployment-6877c7847d-9vwwj   1/1     Running   0          22s
my-nginx-deployment-6877c7847d-gqp2g   1/1     Running   0          22s
my-nginx-deployment-6877c7847d-nx9zq   1/1     Running   0          22s
my-nginx-deployment-6877c7847d-sqg22   1/1     Running   0          22s
</code></pre>
<ul>
<li>Rolling Back a Deployment</li>
</ul>
<p>이번에는 이미지를 다른 버전으로 업데이트하고 이전 버전의 이미지로 돌리는 과정을 실습해봅시다.</p>
<p>Pod의 이미지를 nginx:latest 에서 nginx:1.9.1으로 변경해봅니다.</p>
<p>변경에 대한 이력을 기록하기 위해 annotations에 change-cause을 추가할 수도 있습니다. 이것은 추후에 이력조회시 변경내용으로 조회되는 항목입니다.</p>
<pre><code class="line-numbers"># gedit /lab/deployment/nginx-deployment.yaml
</code></pre>
<pre><code class="line-numbers">apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-deployment
  annotations:
    kubernetes.io/change-cause: "set image nginx 1.9.1"
spec:
  selector:
    matchLabels:
      run: my-nginx
  replicas: 4
  template:
    metadata:
      labels:
        run: my-nginx
    spec:
      containers:
      - name: my-nginx-container
        image: nginx:1.9.1
        imagePullPolicy: Always
        ports:
        - containerPort: 80
</code></pre>
<p>Deployment 생성</p>
<pre><code class="line-numbers"># kubectl apply -f /lab/deployment/nginx-deployment.yaml
</code></pre>
<p>결과확인</p>
<pre><code class="line-numbers">root@master:/k8s/metallb# kubectl get deployment
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
curl                  1         1         1            1           110m
my-nginx-deployment   2         2         2            2           15s

root@master:/k8s/metallb# kubectl get rs
NAME                             DESIRED   CURRENT   READY   AGE
curl-5cc7b478b6                  1         1         1       111m
my-nginx-deployment-6877c7847d   2         2         2       65s

root@master:/k8s/metallb# kubectl get pod
NAME                                   READY   STATUS    RESTARTS   AGE
curl-5cc7b478b6-vwtmj                  1/1     Running   2          111m
my-nginx-deployment-6877c7847d-j6nml   1/1     Running   0          71s
my-nginx-deployment-6877c7847d-wr7c9   1/1     Running   0          71s
</code></pre>
<p>Deployment이력조회</p>
<pre><code class="line-numbers"># kubectl rollout history deployment.v1.apps/my-nginx-deployment
deployment.apps/my-nginx-deployment 
REVISION  CHANGE-CAUSE
1         kubectl apply --filename=/lab/deployment/nginx-deployment.yaml --record=true
2         set image nginx 1.9.1


상세조회를 위해서는 버전옵션을 추가할 수 있습니다.
# kubectl rollout history deployment.v1.apps/my-nginx-deployment --revision=2
deployment.apps/my-nginx-deployment with revision #2
Pod Template:
  Labels:   pod-template-hash=846f7cc5d6
    run=my-nginx
  Annotations:  kubernetes.io/change-cause: set image nginx 1.9.1
  Containers:
   my-nginx-container:
    Image:  nginx:1.9.1
    Port:   80/TCP
    Host Port:  0/TCP
    Environment:    <none>
    Mounts: <none>
  Volumes:  <none>
</code></pre>
<p>그럼 이제 버전1로 롤백을 해봅시다.</p>
<pre><code class="line-numbers"># kubectl rollout undo deployment.v1.apps/my-nginx-deployment --to-revision=1
</code></pre>
<h3>4-4. Delete Deployment</h3>
<p>위에서 언급했지만 Deployment 는 하위의 ReplicaSet과 Pod를 관리하는 리소스입니다. 따라서 Deployment를 삭제하면 하위의  ReplicaSet과 Pod이 함께 삭제됩니다.</p>
<pre><code class="line-numbers"># kubectl delete deployment my-nginx-deployment
deployment.extensions "my-nginx-deployment" deleted

# kubectl get rs
No resources found.

# kubectl get pods
NAME                                   READY   STATUS        RESTARTS   AGE
my-nginx-deployment-6877c7847d-sm4cs   0/1     Terminating   0          2m35s
my-nginx-deployment-6877c7847d-zbqxk   0/1     Terminating   0          2m38s
my-nginx-deployment-6877c7847d-zxhlq   0/1     Terminating   0          2m38s
</code></pre>
<h2>5. 마치며..</h2>
<p>이번시간에는 Pod의 ReplicaSet을 지정하며 배포를 해보고 해당 리비전으로 롤백해보고, 각 Deployment yaml 파일을 업데이트해서 재배포 해보는 내용을 정리해봤습니다. 확실히 쿠버네티스를 사용하면서 오케스트레이션의 강력함을 배우게 되는것 같습니다. 손쉽게 다수의 VM안에 docker container를 배포해주고 또 자동적으로 관리를 해주면서 해당 POD을 교체해주는 면에 있어서 정말로 편리한것 같습니다.</p>
<p>다음 이시간에는 <code>Pod Configuration</code>에 대해서 알아보는 시간을 갖겠습니다.</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/09/17/kubernetes-deployment/">[Kubernetes] 쿠버네티스 Deployment 란?</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/09/17/kubernetes-deployment/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">829</post-id>	</item>
		<item>
		<title>[Kubernetes] 쿠버네티스 Service 란?</title>
		<link>https://blog.wonizz.com/2019/08/21/kubernetes-service/</link>
					<comments>https://blog.wonizz.com/2019/08/21/kubernetes-service/#comments</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Wed, 21 Aug 2019 05:36:48 +0000</pubDate>
				<category><![CDATA[kubernetes]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[도커]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=752</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 지난시간에는 쿠버네티스 POD라는 개념에 대해서 알아봤는데요. 이번시간에는 이러한 POD들을 어떻게 서비스를 해주는 지에 대한 관점인 Service에 대해서 알아보는 시간을 가져보도록 하겠습니다. 지난 글들은 아래를 참고 해주시면 됩니다. 쿠버네티스 1편 : 설치 가이드 쿠버네티스 2편 : pod 쿠버네티스 3편 : service 쿠버네티스 4편 : deployment 쿠버네티스 5편 : pod 설정 쿠버네티스&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/21/kubernetes-service/">[Kubernetes] 쿠버네티스 Service 란?</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 지난시간에는 쿠버네티스 <code>POD</code>라는 개념에 대해서 알아봤는데요. 이번시간에는 이러한 <code>POD</code>들을 어떻게 서비스를 해주는 지에 대한 관점인 <code>Service</code>에 대해서 알아보는 시간을 가져보도록 하겠습니다.</p>
<p>지난 글들은 아래를 참고 해주시면 됩니다.</p>
<ul>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/16/kubenetes-install-guide/">쿠버네티스 1편 : 설치 가이드</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/19/kubernetes-pod/">쿠버네티스 2편 : pod</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/21/kubernetes-service/">쿠버네티스 3편 : service</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/09/17/kubernetes-deployment/">쿠버네티스 4편 : deployment</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/10/28/kubernetes-pod-configuration/">쿠버네티스 5편 : pod 설정 </a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/01/kubernetes-deployment-strategies/">쿠버네티스 6편 : 배포 전략</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/07/kubernetes-volume/">쿠버네티스 7편 : volume</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/15/kubernetes-daemonset/">쿠버네티스 8편 : daemonset</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/27/kubernetes-cluster-terraform/">쿠버네티스 9편 : 테라폼을 통한 클러스터 구성</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/28/kubernetes-aws-eks-volume/">쿠버네티스 10편 : eks에서 volume 사용하기</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/12/20/kubernetes-helm/">쿠버네티스 11편 : helm</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/01/03/kubernetes-helm-chart-template/">쿠버네티스 12편 : helm chart template</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/01/14/kubernetes-helm-deploy/">쿠버네티스 13편 : helm deploy</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/05/26/kubernetes-fluentd-logging/">쿠버네티스 14편 : fluentd를 통한 log수집</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/06/03/kubernetes-helm-chartmuseum/">쿠버네티스 15편 : chartmuseum</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/06/05/kubernetes-deploy-tool-argocd/">쿠버네티스 16편 : 배포툴(ArgoCD 설치방법/사용법)</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2020/06/15/kubernetes-deploy-tool-notification//">쿠버네티스 17편 : 배포툴(ArgoCD 구성/알람)</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/08/24/kubernetes-autoscaling-hpa/">쿠버네티스 18편 : 쿠버네티스 Autoscailing</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2020/10/14/kubernetes-logging-architecture/">쿠버네티스 19편 : 쿠버네티스 로깅 아키텍처</a></li>
</ul>
<p>필자가 속한 프로젝트에서는 아직 쿠버네티스를 사용하고 있지 않습니다. 그래서 개인적으로 쿠버네티스 클러스터를 연결해서 nginx POD 를 생성해서 배포까지 해봤습니다. 그런데 여기서 <code>POD</code> 가 여러개라면 그 앞에 관문 역할을 하는 것이 필요할 것입니다.</p>
<p>이러한 개념이 바로 <code>Service</code> 입니다.</p>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_architecture.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 1" /></p>
<h2>1. Service Template 작성</h2>
<p>서비스 템플릿이란 쿠버네티스에서 <code>Service</code>를 생성하기 위한 <code>YML</code> 로 작성된 파일을 말합니다. 다음은 예시입니다.</p>
<pre><code class="line-numbers">apiVersion: v1
kind: Service
metadata:
  name: my-nginx
  labels:
    run: my-nginx
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
  selector:
    run: my-nginx
</code></pre>
<p>그럼 위의 내용을 한줄 씩 설명해드리겠습니다.</p>
<ul>
<li>서비스 이름</li>
</ul>
<pre><code class="line-numbers">metadata:
  name: my-nginx

</code></pre>
<p>서비스의 이름은 <code>my-nginx</code>이고, <code>labels</code>는 해당 POD에 대해서 라벨링을 해두는것인데, 여기서는 <code>run: my-nginx</code>라고 해두었습니다.</p>
<ul>
<li>타입</li>
</ul>
<pre><code class="line-numbers">spec:
  type: NodePort

</code></pre>
<p><code>Service</code>는 유형(<code>ClusterIP</code>, <code>NodePort</code>, <code>LoadBalancer</code>) 을 갖고 있는데, <code>Node Port</code>를 여기서 사용하고있습니다.</p>
<ul>
<li>포트</li>
</ul>
<pre><code class="line-numbers">  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
</code></pre>
<p>클러스터 port는 <code>8080</code> 이고 실제 nginx POD가 서비스 되는 포트는 <code>80</code> 포트입니다.</p>
<ul>
<li>셀렉터</li>
</ul>
<pre><code class="line-numbers">  selector:
    run: my-nginx
</code></pre>
<p>이 서비스는 Pod중에서 label 값이 <code>run: my-nginx</code> 인 pod쪽으로 서비스 합니다.</p>
<h2>2. Service Object 의 특징</h2>
<ul>
<li>서비스 타입 종류
<ul>
<li>Cluster IP</li>
<li>NodePort</li>
<li>LoadBalancer</li>
</ul>
</li>
<li>Label Selector 통해서 Pod 타겟팅 + 로드밸런싱</li>
<li>Service yaml 파일에 기술된 name로 쿠버네티스 클러스터상에 DNS를 생성할 수 있습니다.</li>
</ul>
<h3>2-1. 서비스 타입</h3>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_type.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 2" /></p>
<ol>
<li>ClusterIP : 쿠버네티스의 디폴트 설정으로 외부에서 접근가능한 IP를 할당받지 않기 때문에 Cluster내에서만 해당 서비스를 노출할 때 사용되는 Type</li>
<li>NodePort : 해당 서비스를 외부로 노출시키고자 할 때 사용되는 Service Type으로 외부에 Node IP와 Port를 노출시키는 것으로 아래 그림과 같이 쿠버네티스 클러스터 상에 있는 모든 노드(VM)에 대해서 노출 시킵니다.</li>
</ol>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_nodeport.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 3" /></p>
<ol start="3">
<li>LoadBalancer : 클라우드상에 존재하는 LoadBalancer에 연결하고자 할 때 사용되는 Service Type으로 LoadBalancer의 외부 External IP를 통해 접근이 가능합니다.</li>
</ol>
<h3>2-2. 서비스 네임 : DNS</h3>
<p>Kubernetes는 자체 DNS서버를 가지고 있어 클러스터 내부에서만 사용가능한 DNS를 설정해서 사용할 수 있습니다. 이것은 Kubernetes상에서 통신할때 IP기반이 아닌 DNS를 통해 연결할 수 있음을 뜻하며 아래 그림과 같이 Pod에서 다른 Pod의 서비스를 연결할때 사용됩니다.</p>
<h2>3. Ingress</h2>
<p>Ingress는 Kubernetes v1.1 추가된 기능으로 <code>NodePort</code> 와<code>LoadBalancer</code> 와 마찬가지로 애플리케이션의 Service를 외부로 노출할때 사용되는 리소스입니다.</p>
<p>외부에서 들어온 HTTP와 HTTPS 트래픽을 ingress resouce를 생성하여 Cluster내부의 Service로 L7영역에서 라우팅하며  로드밸런싱, TLS, 도메인 기반의 Virtual Hosting을 제공합니다.</p>
<p>이러한 기능은 NodePort로 서비스를 노출하는 것에 비해 외부의 서비스를 보다 손쉽게 관리할 수 있도록해줍니다.</p>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/matthewpalmer.net/kubernetes-app-developer/articles/ingress.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 4" /></p>
<p>Ingress는 실질적인 라우팅 기능을 제공하는 Ingress Controller와 Ingress  리소스로 구성할 수 있는데, ingress 리소스는 외부의 URLs을 Cluster 내부의 Service로 라우팅하는 rule이 정의되어 있으며, Ingress Controller에는 다양한 구현체가 존재하며, 여기서는 nginx ingress controller를 설치해 실습해 보도록하겠습니다.</p>
<h3>3-1. Single Service Ingress</h3>
<pre><code class="line-numbers">apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: single-ingress
spec:
  backend:
    serviceName: my-nginx-svc
    servicePort: 80
</code></pre>
<pre><code class="line-numbers">root@master:/lab/service/ingress# kubectl get ingress
NAME             HOSTS   ADDRESS         PORTS   AGE
single-ingress   *       192.168.1.240   80      2m17s
root@master:/lab/service/ingress# curl http://192.168.1.240
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.

For online documentation and support please refer to
<a href="http://nginx.org/" target="_blank" rel="noopener">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/" target="_blank" rel="noopener">nginx.com</a>.

<em>Thank you for using nginx.</em>
</body>
</html>
</code></pre>
<h2>4. 실습</h2>
<p>앞서 이야기했던 <code>Service</code> 들에 대해서 개별적으로 실습해보는 내용들을 정리해보겠습니다. 우선 아래와 같이 폴더 구조를 생성하였고, 각 타입에 맞추어 <code>pod</code>과 <code>serivce</code>를 생성하여 실습을 했습니다.</p>
<pre><code class="line-numbers">lab
 └── service
     │
     ├── clusterip
     │   ├── nginx-pod.yaml
     │   └── nginx-svc.yaml
     │
     ├── loadbalancer
     │   ├── nginx-pod.yaml
     │   └── nginx-svc.yaml
     │
     └── nodeport
         ├── nginx-pod.yaml
         └── nginx-svc.yaml

# pod & service 배포
# cd /lab/sercie/{servicetype폴더}
# kubectl apply -f .

</code></pre>
<h3>4-1. Cluster IP</h3>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_Clusterip.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 5" /></p>
<ul>
<li>파드 생성하기</li>
</ul>
<pre><code class="line-numbers">root@master:~# gedit /lab/service/clusterip/nginx-pod.yaml

</code></pre>
<pre><code class="line-numbers">apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-nginx
  name: my-nginx-pod
  namespace: default
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: my-nginx-container
    ports:
    - containerPort: 80
      protocol: TCP

</code></pre>
<ul>
<li>서비스 생성하기</li>
</ul>
<pre><code class="line-numbers">root@master:~# kubectl apply -f /lab/service/clusterip

</code></pre>
<ul>
<li>결과 확인</li>
</ul>
<p>Service를 조회해보면 Cluster 내부에서만 사용가능한 Cluster IP가 할당된 것을 확인 할 수 있으며, 클러스터에서 curl 명령을 통해 접근가능한 것을 확인 할 수 있습니다.</p>
<pre><code class="line-numbers">root@master:/lab# kubectl get svc -o wide
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE   SELECTOR
kubernetes     ClusterIP   172.168.1.1     <none>        443/TCP   80m   <none>
my-nginx-svc   ClusterIP   172.168.1.240   <none>        80/TCP    74m   run=my-nginx

root@master:/lab# kubectl describe svc my-nginx-svc
Name:              my-nginx-svc
Namespace:         default
Labels:            run=my-nginx
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"run":"my-nginx"},"name":"my-nginx-svc","namespace":"default"},...
Selector:          run=my-nginx
Type:              ClusterIP
IP:                172.168.1.240        # ClusterIP
Port:              <unset>  80/TCP      # Cluster Port
TargetPort:        80/TCP               # Container Port
Endpoints:         10.32.0.5:80         # Container IP
Session Affinity:  None
</code></pre>
<ul>
<li>파드 DNS</li>
</ul>
<pre><code class="line-numbers">[ root@curl-5cc7b478b6-rjq5d:/ ]$ nslookup my-nginx-svc
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name:      my-nginx-svc
Address 1: 10.101.62.208 my-nginx-svc.default.svc.cluster.local

[ root@curl-5cc7b478b6-kb8w8:/ ]$ curl my-nginx-svc.default.svc.cluster.local
</code></pre>
<p>이러한 내부 DNS로 아래 그림과 같이 Pod에서 다른 서비스 또는 다른 Pod로 통신이 가능합니다.</p>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_architecture.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 6" /></p>
<ul>
<li>Namespaces and DNS</li>
</ul>
<p>Service Object를 생성하면 해당 Service의 name으로 <namespace-name>를 포함해 아래와 같은 규칙을 가진 DNS가 cluster 내에 생성됩니다. 이것은 어떤 container(pod)에서 해당 service를 DNS로 호출하는 경우에  개발계, 운영계 등과 같이 multiful namespace를 구성했을때 동일한 설정의 구성을 가능하게 합니다. 이것은 만약 다른 namespace 예를 들면 개발계에서 운영계의 Service를 호출하고자 할때는 FQDN을 사용해야 한다는 뜻입니다.</p>
<pre><code class="line-numbers"><service-name>.<namespace-name>.svc.cluster.local 

</code></pre>
<h3>4-2. NodePort</h3>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_type.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 7" /></p>
<ul>
<li>파드 생성하기</li>
</ul>
<pre><code class="line-numbers">root@master:~# gedit /lab/service/nodeport/nginx-pod.yaml
</code></pre>
<pre><code class="line-numbers">apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-nginx
  name: my-nginx-pod
  namespace: default
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: my-nginx-container
    ports:
    - containerPort: 80
      protocol: TCP
</code></pre>
<ul>
<li>서비스 생성하기</li>
</ul>
<pre><code class="line-numbers"># gedit /lab/service/nodeport/nginx-svc.yaml
</code></pre>
<pre><code class="line-numbers">apiVersion: v1
kind: Service
metadata:
  name: my-nginx-svc
  labels:
    run: my-nginx
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
  selector:
    run: my-nginx
</code></pre>
<pre><code class="line-numbers">kubectl apply -f /lab/service/nodeport/
</code></pre>
<ul>
<li>결과 확인</li>
</ul>
<p>NodePort로 service를 생성하게 되면 자동으로 3XXXX대의 포트를 확인 할 수 있습니다. 이 Port가 모든 VM에 노출된 Node Port이고 Cluster 외부인 어느 VM에서나 접근이 가능합니다.</p>
<pre><code class="line-numbers">root@master:/lab# kubectl get svc
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
my-nginx-svc   NodePort    172.168.1.240   <none>        8080:31331/TCP   140m


root@master:/lab# kubectl describe svc my-nginx-svc
Name:                     my-nginx-svc
Namespace:                default
Labels:                   run=my-nginx
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                            {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"run":"my-nginx"},"name":"my-nginx-svc","namespace":"default"},...
Selector:                 run=my-nginx
Type:                     NodePort
IP:                       172.168.1.240       # Cluster IP
Port:                     <unset>  8080/TCP   # Cluster Port
TargetPort:               80/TCP              # Container Port
NodePort:                 <unset>  31331/TCP  # Node Port
Endpoints:                10.32.0.5:80        # Container IP, Port
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

> VM IP로 접근
# curl localhost:31331

> Mater, Node 등 모든 node VM내의 Firefox에서 아래 url로 접근가능
http://localhost:31331

</code></pre>
<h3>4-3. LoadBalancer</h3>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2019/08/K8S_Service_type.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 Service 란? 설명 이미지 8" /></p>
<ul>
<li>파드 생성하기</li>
</ul>
<pre><code class="line-numbers">root@master:~# gedit /lab/service/loadbalancer/nginx-pod.yaml

</code></pre>
<pre><code class="line-numbers">apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-nginx
  name: my-nginx-pod
  namespace: default
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: my-nginx-container
    ports:
    - containerPort: 80
      protocol: TCP
</code></pre>
<ul>
<li>서비스 생성하기</li>
</ul>
<pre><code class="line-numbers"># gedit /lab/service/loadbalancer/nginx-svc.yaml
</code></pre>
<pre><code class="line-numbers">apiVersion: v1
kind: Service
metadata:
  name: my-nginx-svc
  labels:
    run: my-nginx
spec:
  type: LoadBalancer
  ports:
  - port: 3000
    targetPort: 80
    protocol: TCP
  selector:
    run: my-nginx
</code></pre>
<pre><code class="line-numbers">kubectl apply -f /lab/service/loadbalancer
</code></pre>
<ul>
<li>결과 확인</li>
</ul>
<p>VM상에 가상으로 설치한 loadbalancer에 서비스가 매핑된것을 확인 할 수 있습니다.</p>
<p>가상으로 설치한 loadbalancer의 IP는 192.168.1.240 이며, Cluster상에서 해당IP로 nginx 서비스에 접근이 가능합니다.(crul http://192.168.1.240:8080), 이 IP는 실제 클라우드 상에서는 클라우드 벤더가 제공하는 로드밸런서 장비의 외부로 노출된 공인IP입니다.</p>
<pre><code class="line-numbers">root@master:/lab/service/loadbalancer# kubectl get svc
NAME           TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
kubernetes     ClusterIP      172.168.1.1     <none>          443/TCP          7m1s
my-nginx-svc   LoadBalancer   172.168.1.240   192.168.1.240   3000:30947/TCP   30s

root@master:/lab/service/loadbalancer# kubectl describe svc my-nginx-svc
Name:                     my-nginx-svc
Namespace:                default
Labels:                   run=my-nginx
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                            {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"run":"my-nginx"},"name":"my-nginx-svc","namespace":"default"},...
Selector:                 run=my-nginx
Type:                     LoadBalancer
IP:                       172.168.1.240
LoadBalancer Ingress:     192.168.1.240
Port:                     <unset>  3000/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  30947/TCP
Endpoints:                10.32.0.5:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason       Age   From                Message
  ----    ------       ----  ----                -------
  Normal  IPAllocated  44s   metallb-controller  Assigned IP "192.168.1.240"

root@master:/lab/service/loadbalancer# curl http://192.168.1.240:3000
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
</code></pre>
<ul>
<li>외부 네임 생성하기</li>
</ul>
<p>여기서는 추가적으로 외부에 노출되는 name에 대해서 정리했습니다.</p>
<pre><code class="line-numbers"># gedit /lab/service/external/external-svc.yaml
</code></pre>
<pre><code class="line-numbers">kind: Service
apiVersion: v1
metadata:
  name: myservice
spec:
  type: ExternalName
  externalName: www.github.com
  ports:
  - port: 80
</code></pre>
<p>오브젝트 생성</p>
<pre><code class="line-numbers">kubectl apply -f /lab/service/external/external-svc.yaml
</code></pre>
<h2>5. 마치며..</h2>
<p>필자가 쿠버네티스의 개념에 대해서 정리를 하면서 한개씩 실습을 진행했는데, 위의 내용중 <code>Service</code>의 유형에 대해서 시도해보다가, <code>NodePort</code>만으로 실습을 진행했습니다.</p>
<p>필자가 원하는 방향은 외부에 노출되는 port에 대해서는 fix시켜서 지정을 하고싶어, <code>LoadBalancer</code>타입으로 해봤으나, <code>External-IP</code>가 <code>Pending</code>상태가 지속되면서 연결이 안되었습니다.</p>
<p>또한, <code>Ingress</code> layer를 service 앞단에 연결하였으나, 역시 동작하지 않았습니다.<br />
이부분에 대해서 현재 정리중이며, 위의 내용을 보완해서 정리하도록 하겠습니다.</p>
<p><a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a><br />
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a></p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/21/kubernetes-service/">[Kubernetes] 쿠버네티스 Service 란?</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/08/21/kubernetes-service/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">752</post-id>	</item>
		<item>
		<title>[Kubernetes] 쿠버네티스 POD 란?</title>
		<link>https://blog.wonizz.com/2019/08/19/kubernetes-pod/</link>
					<comments>https://blog.wonizz.com/2019/08/19/kubernetes-pod/#comments</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Mon, 19 Aug 2019 02:20:25 +0000</pubDate>
				<category><![CDATA[kubernetes]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=746</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번시간에는 쿠버네티스 에서 가장 기본적인 개념인 POD에 대해서 알아보는 시간을 갖도록 하겠습니다. 지난 글들은 아래를 참고 해주시면 됩니다. 쿠버네티스 1편 : 설치 가이드 쿠버네티스 2편 : pod 쿠버네티스 3편 : service 쿠버네티스 4편 : deployment 쿠버네티스 5편 : pod 설정 쿠버네티스 6편 : 배포 전략 쿠버네티스 7편 : volume 쿠버네티스&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/19/kubernetes-pod/">[Kubernetes] 쿠버네티스 POD 란?</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>안녕하세요? 정리하는 개발자 워니즈 입니다. 이번시간에는 쿠버네티스 에서 가장 기본적인 개념인 <code>POD</code>에 대해서 알아보는 시간을 갖도록 하겠습니다.</p>
<p>지난 글들은 아래를 참고 해주시면 됩니다.</p>
<ul>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/16/kubenetes-install-guide/">쿠버네티스 1편 : 설치 가이드</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/19/kubernetes-pod/">쿠버네티스 2편 : pod</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/08/21/kubernetes-service/">쿠버네티스 3편 : service</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/09/17/kubernetes-deployment/">쿠버네티스 4편 : deployment</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/10/28/kubernetes-pod-configuration/">쿠버네티스 5편 : pod 설정 </a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/01/kubernetes-deployment-strategies/">쿠버네티스 6편 : 배포 전략</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/07/kubernetes-volume/">쿠버네티스 7편 : volume</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/15/kubernetes-daemonset/">쿠버네티스 8편 : daemonset</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/27/kubernetes-cluster-terraform/">쿠버네티스 9편 : 테라폼을 통한 클러스터 구성</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/11/28/kubernetes-aws-eks-volume/">쿠버네티스 10편 : eks에서 volume 사용하기</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2019/12/20/kubernetes-helm/">쿠버네티스 11편 : helm</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/01/03/kubernetes-helm-chart-template/">쿠버네티스 12편 : helm chart template</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/01/14/kubernetes-helm-deploy/">쿠버네티스 13편 : helm deploy</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/05/26/kubernetes-fluentd-logging/">쿠버네티스 14편 : fluentd를 통한 log수집</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/06/03/kubernetes-helm-chartmuseum/">쿠버네티스 15편 : chartmuseum</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/06/05/kubernetes-deploy-tool-argocd/">쿠버네티스 16편 : 배포툴(ArgoCD 설치방법/사용법)</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2020/06/15/kubernetes-deploy-tool-notification//">쿠버네티스 17편 : 배포툴(ArgoCD 구성/알람)</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="http://blog.wonizz.com/2020/08/24/kubernetes-autoscaling-hpa/">쿠버네티스 18편 : 쿠버네티스 Autoscailing</a></li>
<li><input style="margin-right:5px" type="checkbox" class="task-list-item-checkbox" checked disabled /><a class="wp-editor-md-post-content-link" href="https://blog.wonizz.com/2020/10/14/kubernetes-logging-architecture/">쿠버네티스 19편 : 쿠버네티스 로깅 아키텍처</a></li>
</ul>
<p><strong>Pod는 쿠버네티스 에서 이용되는 Container의 관리단위로 생성/관리/배포가능한 가장작은 단위의 유닛이며 Cluster내에서 실제 Application 구동되는 Object입니다.</strong></p>
<p>실질적으로 도커를 공부하신 분들이면 <code>컨테이너</code>의 개념을 알것입니다. 그런데 이 <code>POD</code>라는 개념이 조금은 다른게, 여러개의 컨테이너들을 담을 수 있고 심지어 <code>Volume</code>도 내부 컨테이너끼리 공유해서 사용할 수 있습니다.</p>
<p>따라서 Pod는 하나 이상의 Container로 구성되며, 동일한 Pod 내에서는 storage/network를 공유 할 수 있습니다.<br />
Kubernetes에서는 Docker가 가장 많이 쓰이는 Container Runtime 모듈이지만, 다른 Container Runtime 모듈도 지원합니다.</p>
<p><img decoding="async" src="https://d33wubrfki0l68.cloudfront.net/5cb72d407cbe2755e581b6de757e0d81760d5b86/a9df9/docs/tutorials/kubernetes-basics/public/images/module_03_nodes.svg" alt="POD 의 생김새" /></p>
<h2>1. POD  네트워킹</h2>
<p>Docker에서는 Container들과의 통신을 위해 동일한 Network상에 구성해야 하나 Pod은 개별 IP를 가지며, Pod내의 Container는 동일한 IP를 가집니다. 즉, 내부적으로 할당 받은 IP는 컨테이너로 분산되어 들어갑니다.</p>
<p>하지만 Pod은 언제든지 Scale Out/In이 가능하고, 삭제/복제가 가능하므로 자체IP를 가지고 있음에도 불구하고 다른 Pod들과의 통신을 위해서는 반드시 Service Object를 통해 통신해야 합니다.</p>
<h3>1-1. 도커 VS 쿠버네티스 컨테이너 네트워크</h3>
<ul>
<li>Docker Container Network</li>
</ul>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/cdn-images-1.medium.com/max/1000/1%2AZdgIoY6tuOqK-r6wgL7d5A.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 POD 란? 설명 이미지 1" /></p>
<ul>
<li>Kubernetes POD Network</li>
</ul>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/cdn-images-1.medium.com/max/1000/1%2A7JLi1Rl0G0FAeu-hiTGSGQ.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 POD 란? 설명 이미지 2" /></p>
<p>차이가 보이시나요? 도커에서의 컨테이너는 각 개별로 IP를 할당받아서 내부적으로 사용을 하지만, 쿠버네티스 같은 경우는 <code>POD</code>라는 개념으로 한번 wrapping이 되어서 상위에 IP가 할당이 됩니다.</p>
<h2>2. POD Template</h2>
<p>Pod는 위에서 보았듯이 Pod Object안에 여러개의 Container를 담을 수 잇는 구조로 되어 있습니다. Yaml 파일도 그에 맞게 Pod의 스펙으로 여러개의 Container를 Spec으로 구성할 수 있도록 되어 있습니다.</p>
<pre><code class="line-numbers">apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-nginx
  name: my-nginx
  namespace: default        
spec:
  containers:
  - image: nginx:1.14.1
    imagePullPolicy: Always
    name: my-nginx
    ports:
    - containerPort: 80
      protocol: TCP
</code></pre>
<h2>3. Pod Lifecycle</h2>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/www.oreilly.com/library/view/kubernetes-for-developers/9781788834759/assets/ab64835b-8b77-4df5-8e09-b3f564cea9c8.png?w=1200&#038;ssl=1" alt="Kubernetes 쿠버네티스 POD 란? 설명 이미지 3" /></p>
<p>이번에는 Kubernetes에서 Pod를 배포한 이후의 Pod의 라이프사이클에 대해 알아봅시다. Kubernetes에서 Pod를 배포하고 kubectl get pod 명령어를 통해 배포된 결과를 조회하면 아래와 같이 Pod의 상태를 볼수 있는 필드를 볼 수 있습니다.</p>
<pre><code class="line-numbers">root@master:~# kubectl get pod
NAME                       READY   STATUS    RESTARTS   AGE
my-nginx-589ffc477-22xvz   1/1     Running   0          42s
my-nginx-589ffc477-4947h   1/1     Running   0          31s
my-nginx-589ffc477-8ll5t   1/1     Running   0          36s
my-nginx-589ffc477-md2l4   1/1     Running   0          48s
</code></pre>
<p>아래는 주요한 Pod의 상태는 Pod의 배포결과를 표시하는 필드로 아래와 같은 상태를 가집니다.</p>
<table>
<thead>
<tr>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Pending</code></td>
<td>Pod 배포명령을 내린 직후 Pod의 상태를 조회해보면 Pending이라는 상태를 확인 할 수 있습니다. 이 상태를 Pod내의 Container 이미지가 다운로드되기전의 대기 상태를 뜻합니다.</td>
</tr>
<tr>
<td><code>Running</code></td>
<td>Pod의 Container가 Node에 정상적으로 생성되어 그 안의 프로세스가 정상적으로 동작하고 있는 상태로일반적인 Pod의 경우 정상적으로 Pod가 배포되면 Running상태가 됩니다.</td>
</tr>
<tr>
<td><code>Succeeded</code></td>
<td>주로 Job과 같은 Pod리소스에서 확인할 수 있는 형태로 Pod의 Containers 컨테이너가 생성되어 프로세스를 실행하고 정상적으로 종료된 상태입니다.</td>
</tr>
<tr>
<td><code>Failed</code></td>
<td>Pod안의 모든 Containers가 종료되었으나 한개 이상의 Container가 정상적으로 종료되지 않은 상태입니다.</td>
</tr>
<tr>
<td><code>Unknown</code></td>
<td>Pod의 상태를 확인할 수 없는 상태로, 주로 Host 머신과의 통신에 문제가 발생했을때 표시됩니다.</td>
</tr>
</tbody>
</table>
<h2>4. Service Accounts for Pods</h2>
<p>Kubernetes에서는 계정 및 권한을 관리함에 있어 User Account와 Service Account 두가지로 구분하여 관리되어 집니다. 예를 들어<code>kubectl</code> 등의 명령어로 Cluster에 접근할때 Apiserver를 통해 특정 User Account로 인증과정을 거치게 되고,(별도의 설정을 하지 않는다면<code>admin</code>계정) Container안의 Process들은 Apiserver에 접근할 수 있는데, 이때 특정 Service Account로 인증을 받습니다.</p>
<p>여기서는 Pod에서 실행되는 프로세스가 Kubernetes API 접근시 사용되는 Service Account에 대해 살펴보겠습니다.</p>
<h3>4-1.Use the Default Service Account to access the API server.</h3>
<p>Pod가 생성될때, Service Account를 명세하지 않았다면 자동으로 <code>default</code> 계정을 할당받아 Pod 내부에서 API로 접근할 수 있습니다.(default 계정의 권한은 클러스터 관리자가 설정할 수 있으므로 설정여부에 따라 권한 및 역할이 다를 수 있습니다.)</p>
<pre><code class="line-numbers">root@master:/lab/service/clusterip# kubectl get pod my-nginx-pod -o yaml
apiVersion: v1
kind: Pod
metadata:
...
spec:
  containers:
  - image: nginx
 ...
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
...
</code></pre>
<pre><code class="line-numbers"># kubectl get serviceAccounts
NAME      SECRETS   AGE
default   1         25h
</code></pre>
<p>이렇게 생성된 Service Account는 Pod안에서 특정위치에 자동으로 마운트되어 Api 접속시 사용되어 집니다.</p>
<pre><code class="line-numbers"># kubectl apply -f https://k8s.io/examples/pods/storage/redis.yaml

# kubectl exec -it redis -- /bin/bash

# root@redis:/var/run/secrets/kubernetes.io# tree
.
`-- serviceaccount
    |-- ca.crt -> ..data/ca.crt
    |-- namespace -> ..data/namespace
    `-- token -> ..data/token
</code></pre>
<h2>5. 컨테이너</h2>
<h3>5-1. 이미지 변경</h3>
<p>Kubernetes에서 Image배포시 Kubelet에서는 기본설정값으로 배포하려는 Images가 Node에 존재할 경우 이미지 다운로드를 skip합니다. 이러한 설정값은 Pod의 container spec에 imagePullPolicy 설정 값으로 정의 할 수 있으며, 아래와 같이 설정이 가능합니다.</p>
<h3>5-2. 이미지 정책</h3>
<ul>
<li>Always : 배포시마다 레지스트리에서 이미지를 다운로드 받습니다.</li>
<li>Never : 배포시 레지스트리에서 이미지를 다운로드 받지 않고 Node에 존재하는 이미지를 사용합니다. 만약 Node에 Image가 존재하지 않는다면 에러가 발생합니다.</li>
<li>IfNotPresent : Default설정값으로 배포하려는 Images가 Node에 존재할 경우 이미지 다운로드를 skip합니다.</li>
</ul>
<h3>5-3. Private Registry</h3>
<p>사내 ReDii와 같은 Private Registry를 이용하기 위해서는 다운로드 권한이 저장된 Secret을 생성하여 Container Image Spec에 해당 Key를 ImagePullSecrets 항목으로 설정해주어야 합니다.</p>
<pre><code class="line-numbers">apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: <your-private-image>
  imagePullSecrets:
  - name: regcred
</code></pre>
<p>Kubernetes Cluster에서 아래 명령어로 Secret을 생성해주면 됩니다.</p>
<pre><code class="line-numbers">kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
</code></pre>
<ul>
<li><your-registry-server>` is your Private Docker Registry FQDN.</li>
<li><code><your-name></code> is your Docker username.</li>
<li><code><your-pword></code> is your Docker password.</li>
<li><code><your-email></code> is your Docker email.</li>
</ul>
<h2>6. 마치며..</h2>
<p>쿠버네티스에서 가장 기본이 되는 개념입니다. <code>POD</code> 의 개념을 먼저 이해하고 나서 <code>Service</code>라는 개념에 대해서 알아보도록 하겠습니다. 모두들 위의 글을 읽고 이해하셨나요?</p>
<p>도커를 처음 공부할때 Container의 개념이 너무 재밌고, 신기했습니다. 그런데 이러한 컨테이너들을 클러스터링 해주고, 관리를 해주는 <code>쿠버네티스</code> 가 있다는 것에 대해서 놀랐습니다. 구글은 수년간 이것을 내부적으로 사용해 왔다고 합니다.</p>
<p>쿠버네티스의 걸음마 단계로 다음시간에는 <code>Service</code> 에 대해서 알아보는 시간을 갖도록 하겠습니다.</p>
<p><a href="http://blog.wonizz.com" title="워니즈 블로그">워니즈 블로그</a><br />
<a href="http://github.com/wonizz" title="워니즈 깃헙" target="_blank" rel="noopener">워니즈 깃헙</a></p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/08/19/kubernetes-pod/">[Kubernetes] 쿠버네티스 POD 란?</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/08/19/kubernetes-pod/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">746</post-id>	</item>
	</channel>
</rss>
