Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info
iconfalse

Table of Contents

Apple M2 에서 kubectl command 자동완성 및 alias k를 설정 하고 싶어.

Code Block
$ vi ~/.zshrc

autoload -Uz compinit
compinit
source <(kubectl completion zsh)
compdef __start_kubectl k

alias k=kubectl

$ source ~/.zshrc


CronJob을 수동 실행 하고 싶어요.

Code Block
kubectl create job --from=cronjob/kubernetes-cron-job manual-cron-job

Secret Password를 인코딩 할래요.

Code Block
echo -n "{PASSWORD}" | base64'{PASSWORD}' | base64

Network 점검 할 수 있는 Pod가 필요해요.

Info
iconfalse
Code Block
kubectl run nettools --image=jrecord/nettools -- sleep 48000
Code Block
apiVersion: v1
kind: Pod
metadata:
  name: nettools
  namespace: default
spec:
  containers:
  - name: nettools
    image: jrecord/nettools:latest
    command:
      - sleep
      - "48000"
    imagePullPolicy: IfNotPresent
  restartPolicy: Never

모든 Pod(Deployment)의 ResourceQuate설정 정보를 보고 싶어요.

Code Block
kubectl get deploy -o=custom-columns="Name:.metadata.name,CPU-Limit:.spec.template.spec.containers[*].resources.limits.cpu,Memory-Limit:.spec.template.spec.containers[*].resources.limits.memory"
------------------------------------------------

Name                 CPU-Limit   Memory-Limit
admin-auth           500m        2Gi
admin-batch          1           2Gi
admin-bff            500m        2Gi
admin-gw             500m        2Gi
admin-web            500m        2Gi

Node별 리소스사용량을 보고 싶어요.

Code Block
kubectl describe node | grep -A7 Resource
-------------------------------------------------

  Resource                       Requests       Limits
  --------                       --------       ------
  cpu                            6450m (82%)    6750m (86%)
  memory                         10590Mi (38%)  10790Mi (38%)
  ephemeral-storage              0 (0%)         0 (0%)
  hugepages-1Gi                  0 (0%)         0 (0%)
  hugepages-2Mi                  0 (0%)         0 (0%)
  attachable-volumes-azure-disk  0              0
--
  Resource                       Requests      Limits
  --------                       --------      ------
  cpu                            6050m (77%)   6250m (79%)
  memory                         8632Mi (31%)  8742Mi (31%)
  ephemeral-storage              0 (0%)        0 (0%)
  hugepages-1Gi                  0 (0%)        0 (0%)
  hugepages-2Mi                  0 (0%)        0 (0%)
  attachable-volumes-azure-disk  0             0
Code Block
kubectl describe node | grep -A15 Namespace
-------------------------------------------------

 Namespace                   Name                                        CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age
  ---------                   ----                                        ------------  ----------  ---------------  -------------  ---
  default                     aaaaa-web-6744c99f5f-pqdtb                  500m (6%)     500m (6%)   2Gi (7%)         2Gi (7%)       31h
  default                     bbbb-api-597dcd86c6-7s7pk                   2 (25%)       2 (25%)     2Gi (7%)         2Gi (7%)       30h
  default                     ccccccc-api-7f88b87977-7rkd2                500m (6%)     500m (6%)   2Gi (7%)         2Gi (7%)       31h
  default                     dddddd-api-gw-6d554944d5-pm6fh              2 (25%)       2 (25%)     2Gi (7%)         2Gi (7%)       31h
  default                     eeee-65b99c49bf-92b8k                       1 (12%)       1 (12%)     2Gi (7%)         2Gi (7%)       77d
  kube-system                 azure-cni-networkmonitor-cwd2d              0 (0%)        0 (0%)      0 (0%)           0 (0%)         173d
  kube-system                 azure-ip-masq-agent-hmzdp                   100m (1%)     500m (6%)   50Mi (0%)        250Mi (0%)     16d
  kube-system                 azure-npm-p2z7v                             250m (3%)     250m (3%)   300Mi (1%)       300Mi (1%)     106d
  kube-system                 kube-proxy-mgh87                            100m (1%)     0 (0%)      0 (0%)           0 (0%)         113d
  logging                     collect-dep-zcp-fluent-bit-hrw58            0 (0%)        0 (0%)      0 (0%)           0 (0%)         132d
  monitoring                  prometheus-alertmanager-6f98d49b99-c7prc    0 (0%)        0 (0%)      0 (0%)           0 (0%)         213d
  monitoring                  prometheus-node-exporter-jpptq              0 (0%)        0 (0%)      0 (0%)           0 (0%)         215d