기타/자격증

[CKA][실습] 1. Core Concepts

백곰곰 2023. 2. 4. 23:06
728x90
반응형

CKA 취득을 위해 Kodecloud의 CKA 실습 내용을 정리한 글 입니다.

 

Practice Test - PODs

alias k=kubectl
k run nginx --image=nginx

#Pod의 이미지 확인
k describe po [이름] -n [ns]

#Pod가 배포된 노드 확인
k get po -n [ns] -o wide

k delete po webapp

#Pod 수정
k run redis --image=redis123
k edit po redis

오류 케이스 :

  • 존재하지 않는 image로 Pod를 만든 경우

Practice Test - ReplicaSets

k get rs
k get rs -o wide
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml
k scale rs new-replica-set --replicas=5

오류 케이스 :

  • yaml에 api version을 잘못 기재

Practice Test - Deployments

k get deploy frontend-deployment -o wide
k create deploy httpd-frontend --image=httpd:2.4-alpine --replicas=3 --dry-run=client -o yaml >> my-deploy.yaml
k apply -f my-deploy.yaml

오류 케이스 :

  • yaml에 kind를 잘못 기재 (ex. deployment -> Deployment 수정)

기타 명령어 Tip

  • run은 pod만 생성할 수 있다.
$ k run --help
Create and run a particular image in a pod.
  • create는 --dry-run을 활용하기에 좋은데 적용 가능한 자원이 제한적이라 확인이 필요하다.
$ k create --help
Create a resource from a file or from stdin.

 JSON and YAML formats are accepted.

Examples:
  # Create a pod using the data in pod.json
  kubectl create -f ./pod.json

  # Create a pod based on the JSON passed into stdin
  cat pod.json | kubectl create -f -

  # Edit the data in registry.yaml in JSON then create the resource using the edited data
  kubectl create -f registry.yaml --edit -o json

Available Commands:
  clusterrole           Create a cluster role
  clusterrolebinding    Create a cluster role binding for a particular cluster role
  configmap             Create a config map from a local file, directory or literal value
  cronjob               Create a cron job with the specified name
  deployment            Create a deployment with the specified name
  ingress               Create an ingress with the specified name
  job                   Create a job with the specified name
  namespace             Create a namespace with the specified name
  poddisruptionbudget   Create a pod disruption budget with the specified name
  priorityclass         Create a priority class with the specified name
  quota                 Create a quota with the specified name
  role                  Create a role with single rule
  rolebinding           Create a role binding for a particular role or cluster role
  secret                Create a secret using specified subcommand
  service               Create a service using a specified subcommand
  serviceaccount        Create a service account with the specified name
  token                 Request a service account token
  • rollout은 재시작, 롤백 등에 사용할 수 있는데 deploymens, daemonsets, statefulsets에만 적용 가능하다.
$ k rollout --help
Manage the rollout of one or many resources.

 Valid resource types include:

  *  deployments
  *  daemonsets
  *  statefulsets
728x90