티스토리 뷰

▶ client 확인사항

>> kubelet / containerd / kube-proxy 3가지

 

 

○ iptables 체크 [ 복잡하다 / kube-proxy 가 자동으로 관리를 해준다 ]

[vagrant@wk2 ~]$ sudo iptables -t nat -L -n

 

 

● wide 로 가로로 자세하게 확인하여 잘 작동되는지 확인

[vagrant@ms ~]$ kubectl get pods -o wide
NAME                   READY   STATUS    RESTARTS     AGE   IP            NODE              NOMINATED NODE   READINESS GATES
apache-replica-2fc6d   1/1     Running   1 (9h ago)   15h   10.244.1.11   wk1.example.com   <none>           <none>
apache-replica-8qs4p   1/1     Running   1 (9h ago)   15h   10.244.2.6    wk2.example.com   <none>           <none>
apache-replica-9wpvx   1/1     Running   1 (9h ago)   15h   10.244.1.9    wk1.example.com   <none>           <none>
myapache               1/1     Running   1 (9h ago)   15h   10.244.1.10   wk1.example.com   <none>           <none>

 

 

 

● 파드 삭제해도 replica 가 3으로 지정되어 있어서 apache-replica 는 살아난다 ( 안정적 운영 )

kubectl delete pod --all
kubectl get pods
kubectl get replicasets.apps

 

 

# 전에 만들어둔 replica.yml

더보기

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: apache-replica
spec:
  replicas: 3
  selector:
    matchLabels:
      app: apache-replica-test
  template:
    metadata:
      labels:
        app: apache-replica-test
    spec:
      containers:
      - name: myweb-container2
        image: httpd:2.4
        ports:
        - containerPort: 80

 

 

 

● replica.yml 을 수정하여 재적용 가능

>> replica.yml 에서 replicas : 5 로변경하였다

[vagrant@ms work]$ kubectl apply -f replica.yml
replicaset.apps/apache-replica configured

 

● dsecribe 뒤에는 타입을 적는다 ( 이번에는 replicasets.apps 지정 )

>> replica 설정파일

[vagrant@ms work]$ kubectl describe replicasets.apps apache-replica

 

 

 

○ 설정을 만들어서 바꾼다

[vagrant@ms work]$ export EDIATOR='vim'
[vagrant@ms work]$ kubectl edit replicasets.apps

○ export EDITOR를 변경하면 반짝반짝한 vim으로 컬러풀하게 나옴

 

○ replicas: 5 를 2로 변경한다

>> 2로 직접 수정했다

 

 

○ 수정이 완료되자마자 바로 적용된다

[vagrant@ms work]$ kubectl edit replicasets.apps
replicaset.apps/apache-replica edited
[vagrant@ms work]$ kubectl get pods
NAME                   READY   STATUS    RESTARTS   AGE
apache-replica-4lmhm   1/1     Running   0          20m
apache-replica-xhlrz   1/1     Running   0          20m

 

 

● 명령어로 바로 10개로 늘리기도 가능하다

>> 적절하게 부하가 분산되었음을 확인 가능하다

[vagrant@ms work]$ kubectl scale --replicas 10 replicaset apache-replica
replicaset.apps/apache-replica scaled

[vagrant@ms work]$ kubectl get pods -o wide
NAME                   READY   STATUS    RESTARTS   AGE   IP            NODE              NOMINATED NODE   READINESS GATES
apache-replica-4lmhm   1/1     Running   0          37m   10.244.2.8    wk2.example.com   <none>           <none>
apache-replica-5dnbf   1/1     Running   0          6s    10.244.1.17   wk1.example.com   <none>           <none>
apache-replica-5dzvp   1/1     Running   0          6s    10.244.2.10   wk2.example.com   <none>           <none>
apache-replica-5sxc7   1/1     Running   0          6s    10.244.1.16   wk1.example.com   <none>           <none>
apache-replica-jlrg4   1/1     Running   0          6s    10.244.1.18   wk1.example.com   <none>           <none>
apache-replica-lhftz   1/1     Running   0          6s    10.244.2.11   wk2.example.com   <none>           <none>
apache-replica-mqtxd   1/1     Running   0          6s    10.244.1.15   wk1.example.com   <none>           <none>
apache-replica-vdvzv   1/1     Running   0          6s    10.244.2.12   wk2.example.com   <none>           <none>
apache-replica-vh7nq   1/1     Running   0          6s    10.244.2.13   wk2.example.com   <none>           <none>
apache-replica-xhlrz   1/1     Running   0          37m   10.244.1.12   wk1.example.com   <none>           <none>

[vagrant@ms work]$ kubectl get replicasets.apps
NAME             DESIRED   CURRENT   READY   AGE
apache-replica   10        10        10      16h

 

○ 삭제해도 새로운 이름으로 다시 올라온다

 

 

 

 

● replica 개수를 0으로 수정해서 삭제 가능하다

>> 하지만 replica 자체는 남아있다 ( 상위 오브젝트인 replica 는 존재하므로 pod만 0으로 지정되어있는 것 )

[vagrant@ms work]$ kubectl scale --replicas 0 replicaset apache-replica
replicaset.apps/apache-replica scaled
[vagrant@ms work]$ kubeclt get pods
-bash: kubeclt: command not found

 

 

 

● 상위 오브젝트인 replicasets.apps 를 삭제해버리면 완전 삭제가 된다

[vagrant@ms work]$ kubectl get pods
NAME                   READY   STATUS    RESTARTS   AGE
apache-replica-hpl4x   1/1     Running   0          3s
apache-replica-j98f8   1/1     Running   0          3s
apache-replica-tmtx8   1/1     Running   0          3s
[vagrant@ms work]$ kubectl delete replicasets.apps apache-replica
replicaset.apps "apache-replica" deleted
[vagrant@ms work]$ kubectl get pods
No resources found in myns namespace.

 

● 오브젝트 상관 관계

오브젝트 순서 : cluster - node - namespace - repicaset - pod

# 상위를 삭제하면 하위가 다 삭제된다

 

○ namespace 가 없으면 default 로 지정되어 있다

더보기

[vagrant@ms work]$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://192.168.98.10:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    namespace: myns
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: DATA+OMITTED
    client-key-data: DATA+OMITTED

'Kubernetes [ 쿠버네티스 ]' 카테고리의 다른 글

Kubernetes deployment  (0) 2024.03.08
Kubernetes 상위 오브젝트와 리소스  (0) 2024.03.08
Kubernetes ReplicaSet  (0) 2024.03.07
Kubernetes - pods  (0) 2024.03.07
Kubernetes 기본 개념 / namespace  (0) 2024.03.07
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/03   »
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
글 보관함