본문 바로가기

엔지니어/Kubernetes

kubernetes 명령어 모음

728x90
반응형

pods 정보
kubectl get pods -A
kubectl get pods -o wide
kubectl get pods -n istio-system -o wide
kubectl get pod -n istio-system -l istio=ingressgateway
kubectl describe pods

네임스페이스 정보
kubectl get ns

virtual server 정보
kubectl get vs

서비스 라벨 보기
kubectl get svc istio-ingressgateway -n istio-system --show-labels

서비스 보기
kubectl -n istio-system get service
kubectl get svc/istio-ingressgateway -n istio-system
kubectl -n istio-system get service istio-ingressgateway


yaml 파일 apply , yaml 파일 delete
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl delete -f samples/bookinfo/platform/kube/bookinfo.yaml


istio-injection 라벨 생성 및 삭제
kubectl label namespace default istio-injection=enabled
kubectl label --overwrite ns default istio-injection-

이벤트 로그
kubectl get event

namespace 를 강제 삭제
kubectl get namespace "$namespace" -o json \
  | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \
  | kubectl replace --raw /api/v1/namespaces/"$namespace"/finalize -f -.

kubectl get namespace istio-system -o json \
  | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \
  | kubectl replace --raw /api/v1/namespaces/istio-system/finalize -f -

pod 강제 삭제
kubectl delete -n $namespace po/$pod-name --grace-period=0 --force
kubectl delete -n istio-system pod/kiali-7ccbd65c99-2dzdn --grace-period=0 --force
kubectl delete pod/gitlab-webservice-default-54c4db9b44-zw6jb -n gitlab --grace-period=0 --force
kubectl delete pod/productpage-v1-d4f8dfd97-lnz7t --grace-period=0 --force
kubectl delete pod/reviews-v1-5896f547f5-pdzhj --grace-period=0 --force
kubectl delete pod/reviews-v2-5d99885bc9-6snmg --grace-period=0 --force
kubectl delete pod/reviews-v3-589cb4d56c-jpgb4 --grace-period=0 --force
##pv강제삭제
kubectl delete pv <pv_name> --grace-period=0 --force
kubectl delete pv gitlab/repo-data-gitlab-gitaly-0 --grace-period=0 --force

이후 
kubectl patch pv <pv_name> -p '{"metadata": {"finalizers": null}}'

kubectl patch pv gitlab/repo-data-gitlab-gitaly-0 -p '{"metadata": {"finalizers": null}}'


export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}')




kubectl get deployment -n rook-ceph



CRI-O와 함께 사용 가능한 툴: Buildah, Podman, Skopeo
Podman은 pull 및 tag 지정과 같은 OCI 컨테이너 이미지를 유지관리
Buildah는 CRI-O에서 이미지를 빌드할 때 도커의 종속성을 제거하기 위해 개발
Skopeo는 이미지 저장소에서 다양한 작업을 수행하는 명령줄 도구

calico - 보안 cni
istio - 게이트웨이 , 네트워크 모니터링 cni
metallb - LB

istio gateway 는 vs 로 연동해야댐


client -> metallb -> istio-ingressgateway -> virtualserver -> container


kubectl delete -n istio-system -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: prometheus
spec:
  hosts:
  - "*"
  gateways:
  - default-gateway
  http:
  - match:
    - uri:
        prefix: /prometheus
    route:
    - destination:
        port:
          number: 20001
        host: prometheus
EOF


kubectl apply -n istio-system -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: prometheus
spec:
  hosts:
  - "*"
  gateways:
  - default-gateway
  http:
  - match:
    - uri:
        prefix: /prometheus
    route:
    - destination:
        port:
          number: 20001
        host: prometheus
EOF





##ceph console 접속
 kubectl -n rook-ceph exec -it $(kubectl -n rook-ceph get pod -l "app=rook-ceph-tools" -o jsonpath='{.items[0].metadata.name}') bash

## 인증서 도메인.crt 형식으로 저장하기
kubectl create secret generic harbor-crt  --from-file=harbor.xxx.com.crt=/root/gitlab/_wildcard_xxx_com.crt

반응형

'엔지니어 > Kubernetes' 카테고리의 다른 글

CI / CD 구성  (0) 2023.11.06
Harbor  (0) 2023.11.06
Helm  (0) 2023.11.06
Istio  (0) 2023.11.06
Calico CNI  (0) 2023.11.06