티스토리 뷰
https://www.youtube.com/watch?v=uuLU6A2NKk8
Q. how many pods exist on the system ?
in the current (default) namespace.
얼마나 많은 pod 가 시스템에 존재 하느냐 !
현재 namespace 존재!
A:조회 가능 방법
# kubectl get pod (pod 를 조회 해주세요~)
> no resources found in defult name space.
Q. How many replicaSets exist on the system ?(이 시스템에 리플리카 셋이 얼마나 존재 하느냐>)
in the current(default) namespace
A:조회 가능 방법
#kube get rs
https://kubernetes.io/ko/docs/concepts/workloads/controllers/replicaset/
replicaset?
replicaset의 목적: replicaset pod 집합의 실행을 항상 안정적으로 유지하는 것이다.
#frontend.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# 케이스에 따라 레플리카를 수정한다.
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
#적용하기 apply
kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml
#현재 배포된 레플리카셋을 확인할 수 있다.
kubectl get rs
# Desired 3/ Current 3 / Ready 3 아래 name 은 위의 label 명과 돌일함을 확인 해야 한다. !
NAME DESIRED CURRENT READY AGE
frontend 3 3 3 6s
# 레플리카셋의 상태를 확인할 수 있다.
kubectl describe rs/frontend
# Describe 확인 내용
Name: frontend
Namespace: default
Selector: tier=frontend
Labels: app=guestbook
tier=frontend
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"apps/v1","kind":"ReplicaSet","metadata":{"annotations":{},"labels":{"app":"guestbook","tier":"frontend"},"name":"frontend",...
Replicas: 3 current / 3 desired
Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: tier=frontend
Containers:
php-redis:
Image: gcr.io/google_samples/gb-frontend:v3
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 117s replicaset-controller Created pod: frontend-wtsmm
Normal SuccessfulCreate 116s replicaset-controller Created pod: frontend-b2zdv
Normal SuccessfulCreate 116s replicaset-controller Created pod: frontend-vcmts
마지막으로 pod 가 올라왔는지 확인 한다
kubectl get pods
NAME READY STATUS RESTARTS AGE
frontend-b2zdv 1/1 Running 0 6m36s
frontend-vcmts 1/1 Running 0 6m36s
frontend-wtsmm 1/1 Running 0 6m36s
# kubectl get pods frontend-b2zdv -o yaml
piVersion: v1
kind: Pod
metadata:
creationTimestamp: "2020-02-12T07:06:16Z"
generateName: frontend-
labels:
tier: frontend
name: frontend-b2zdv
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: ReplicaSet
name: frontend
uid: f391f6db-bb9b-4c09-ae74-6a1f77f3d5cf
...
Q. How many Deployments exist on the system ?( 이 시스템에 Deployment가 몇개나 있습니까?
A:조회 가능 방법
#kube get deploy ?
디플로이먼트디플로이먼트(Deployment) 는 파드와 레플리카셋(ReplicaSet)에 대한 선언적 업데이트를 제공한다.디플로이먼트에서 의도하는 상태 를 설명하고, 디플로이먼트 컨트롤러(Controller)는 현재 상태에서 의도하는 상태로 비율을 조정하며 변경한다. 새 레플리카셋을 생성하는 디플로이먼트를 정의하거나 기존 디플로이먼트를 제거하고, 모든 리소스를 새 디플로이먼트에 적용할 수 있다. 참고: 디플로이먼트가 소유하는 레플리카셋은 관리하지 말아야 한다. 사용자의 유스케이스가 다음에 포함되지 않는 경우 쿠버네티스 리포지터리에 이슈를 올릴 수 있다.
유스케이스다음은 디플로이먼트의 일반적인 유스케이스이다.
|
디플로이먼트 생성
#nginx-deployment.yaml
다음은 디플로이먼트의 예시이다. 예시는 3개의 nginx 파드를 불러오기 위한 레플리카셋을 생성한다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
# deploy apply 적용
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml
kubectl get deployments 을 실행해서 디플로이먼트가 생성되었는지 확인한다.
만약 디플로이먼트가 여전히 생성 중이면, 다음과 유사하게 출력된다.
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deployment 0/3 0 0 1s
# nginx:1.14.2 => nginx:1.16.1 이미지를 사용하도록 nginx 파드를 업데이트 방법
kubectl set image deployment.v1.apps/nginx-deployment nginx=nginx:1.16.1
또는
kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
# 출력 결과
다음과 유사하게 출력된다.
deployment.apps/nginx-deployment image updated
대안으로 디플로이먼트를 edit 해서 .spec.template.spec.containers[0].image
를 nginx:1.14.2 에서 nginx:1.16.1 로 변경한다.
#kubectl edit deployment/nginx-deployment
#deployment.apps/nginx-deployment edited
롤아웃 상태를 보려면 다음을 실행한다.
#kubectl rollout status deployment/nginx-deployment
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
deployment "nginx-deployment" successfully rolled out
롤아웃이 성공하면 kubectl get deployments 를 실행해서 디플로이먼트를 볼 수 있다.
이와 유사하게 출력된다.
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deployment 3/3 3 3 36s
# 추가 설명
#kubectl get rs 를 실행해서 디플로이먼트가 새 레플리카셋을 생성해서
파드를 업데이트 했는지 볼 수 있고, 새 레플리카셋을 최대 3개의 레플리카로 스케일 업,
이전 레플리카셋을 0개의 레플리카로 스케일 다운한다.
#kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-1564180365 3 3 3 6s
nginx-deployment-2035384211 0 0 0 36s
get pods 를 실행하면 새 파드만 표시된다.
#kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-1564180365-khku8 1/1 Running 0 14s
nginx-deployment-1564180365-nacti 1/1 Running 0 14s
nginx-deployment-1564180365-z9gth 1/1 Running 0
#kubectl describe deployments (디플로이먼트의 세부 정보 가져오기 )
#kubectl describe deployments
Name: nginx-deployment
Namespace: default
CreationTimestamp: Thu, 30 Nov 2017 10:56:25 +0000
Labels: app=nginx
Annotations: deployment.kubernetes.io/revision=2
Selector: app=nginx
Replicas: 3 desired | 3 updated | 3 total | 3 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx
Containers:
nginx:
Image: nginx:1.16.1
Port: 80/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: nginx-deployment-1564180365 (3/3 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 2m deployment-controller Scaled up replica set nginx-deployment-2035384211 to 3
Normal ScalingReplicaSet 24s deployment-controller Scaled up replica set nginx-deployment-1564180365 to 1
Normal ScalingReplicaSet 22s deployment-controller Scaled down replica set nginx-deployment-2035384211 to 2
Normal ScalingReplicaSet 22s deployment-controller Scaled up replica set nginx-deployment-1564180365 to 2
Normal ScalingReplicaSet 19s deployment-controller Scaled down replica set nginx-deployment-2035384211 to 1
Normal ScalingReplicaSet 19s deployment-controller Scaled up replica set nginx-deployment-1564180365 to 3
Normal ScalingReplicaSet 14s deployment-controller Scaled down replica set nginx-deployment-2035384211 to 0
Q: How many Deployment exist on the system now ? We just created a Deployment Cheak again!
(현재 시스템에 Deploy 가 몇개나 존재 합니까?
A:조회 가능 방법
# Kube get deploy 조회
1개의 nginx-deployment deploy가 만들어져 있네요
NAME READY UP-TO-DATE AVAILABLE AGE
frontend-deployment-56d8ff5458 3/3 3 3 36s
Q: How many relpicaSet exist on the system now?
A:조회 가능 방법
#kube get rs
정답은 1개 만들어 졌고, deploy 만들면 RS도 이렇게 하나씩 만들어짐.
NAME DESIRED CURRENT READY AGE
frontend-deployment-56d8ff5458 3 3 3 6s
Q: How many Pods exist on the system now ?
A:조회 가능 방법
#kubectl get pods
!여기서 잠깐.
https://kubernetes.io/ko/docs/reference/kubectl/cheatsheet/
Kubectl 자동 완성
BASH
source <(kubectl completion bash) # bash-completion 패키지를 먼저 설치한 후, bash의 자동 완성을 현재 셸에 설정한다
echo "source <(kubectl completion bash)" >> ~/.bashrc # 자동 완성을 bash 셸에 영구적으로 추가한다
또한, kubectl의 의미로 사용되는 약칭을 사용할 수 있다.
alias k=kubectl
complete -F __start_kubectl k
Q. What is the image used to create the pods in the now deployment ?
(Deploy 에서 사용한 이미지는 무엇인가?)
A:조회 가능 방법
# k get deploy
# k describe deploy
#kubectl describe deploy
Pod Template:
Labels: name=busybox-pod
Containers:
busybox-container:
Image: busybox888
Port: <none>
Host port : <none>
command :
sh
-c
echo Hello kubernetes ! && sleep 3600
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: frontend-deployment-56d8ff5458 (4/4 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 2m5s deployment-controller Scaled u
p replica set frontend-deployment-56d8ff5458 to 4
Q: Why do you think the deployment is not ready?(왜 deploy가 ready가 안되었는가?)
아마도 위에 the image busybox888 이 존재 하지 않습니다.
Q: Create a new Deployment using the deployment-definition-1.yml file locate at /root/.
(deloyment-definition-1.yml 파일을 이용해서 deploy 만들어라)
(there is an issue with the file, so try to fix it. 파일에 문제가 있으니 고쳐보시오)
#ls
deployment-definition-1.yaml
#kube apply -f deployment-definition-1.yaml
Error form server (Badrequest): error when createing "deployment-definition-1.yaml ":
deployment in version "v1" cannot be handled as a Deployment : do kind "deployment" is
registered for version " apps/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:
30"
Error form server (Badrequest): error when createing "deployment-definition-1.yaml ":
deployment in version "v1" cannot be handled as a Deployment : do kind "deployment" is
registered for version " apps/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:
30" 대문자 확인!
A:조회 가능 방법
#vi deployment-definition-1.yaml
#vi deployment-definition-1.yaml
apiVersion: apps/v1
kind: Deployment <==
metadata:
name:deployment-1
spec:
replicas: 2
selector:
matchLabels:
name : busybox-pod
template:
metadata:
labels:
name : busybox-pod
spec:
containers:
- name: busybox-container
image: busybox888
command:
- sh
- "-c"
- echo Hello kubernetes! && sleep 3600
ports:
- containerPort: 80
[간단설명]
1. metadata.name 필드에 따라 Deployment-1 이름으로 deployment 생성
2. spec.replicas 필드에 따라 deployment는 2개의 replica pod 생성
3. spec.selector 필드는 deployment 가 관리할 pod를 찾는 방법을 정의
4. pod template 에 정의된 레이블(busybox-pod)을 선택한다.
그러나 파드 템플릿 자체의 규칙이 만족되는 한, 보다 정교한 선택 규칙의 적용이 가능하다.
template 필드에는 다음 하위 필드가 포함되어있다.
5. pod 는 .metadata.labels 필드를 사용해서 name: busybox888 라는 레이블을 붙인다.
6. pod template 사양 또는 .template.spec 필드는 파드가 도커 허브의 busybox888이미지를 실행하는
busybox 컨테이너 1개를 실행하는 것을 나타낸다.
7. container 1개를 생성하고, .spec.template.spec.containers[0].name 필드를 사용해서 buxybox 이름을 붙인다.
8. 아래 명령을 이용하여 yaml 파일로 명시한 시방서로 디플로이먼트를 생성한다.
#kube apply -f deployment-definition-1.yaml
deployment.app/deployment-1 created
Q: Create a new Deployment with the below attribute using your own deployment definition file .
deploy 를 아래의 파일을 사용하여 생성해보세요
Name : httpd-fronted ;
replicas 3 ;
image : httpd:2.4-alpine
A:조회 및 수정
# vi deploy2.yaml 아래 내용 수정 <==
#vi deploy2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: <==
spec:
replicas: 3 <==
selector:
matchLabels:
name : httpd <==
template:
metadata:
labels:
name : httpd <==
spec:
containers:
- name: httpd <==
image: httpd:2.4-alpine <==
command:
- sh
- "-c"
- echo Hello kubernetes! && sleep 3600
ports:
- containerPort: 80
# kube apply -f deploy2.yaml
deployment.app/httpd-fronted created
#kube get deploy
name ready up-to-date available age
fronted-deployment 0/4 4 0 7m28s
deployment-1 0/2 2 0 3m
httpd-frontend 0/3 3 0 9s <==
name ready up-to-date available age
fronted-deployment 0/4 4 0 7m28s
deployment-1 0/2 2 0 3m
httpd-frontend 3/3 3 3 9s <==
감사합니다.
- Total
- Today
- Yesterday
- 커널
- [오라클 튜닝] sql 튜닝
- 여러서버 컨트롤
- 버쳐박스
- 키알리
- Oracle
- ORACLE 트러블 슈팅(성능 고도화 원리와 해법!)
- MSA
- (InstantClient) 설치하기(HP-UX)
- 코로나19
- 5.4.0.1072
- 설치하기(HP-UX)
- K8s
- 테라폼
- 쿠버네티스
- directory copy 후 startup 에러
- CVE 취약점 점검
- 오라클 인스턴트클라이언트(InstantClient) 설치하기(HP-UX)
- ubuntu
- 스토리지 클레스
- 트리이스
- startup 에러
- 우분투
- [오라클 튜닝] instance 튜닝2
- 오라클 트러블 슈팅(성능 고도화 원리와 해법!)
- 앤시블
- 오라클
- pod 상태
- 오라클 홈디렉토리 copy 후 startup 에러
- 튜닝
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |