티스토리 뷰
Specific Pod`s Full YAML
kubectl get po jordi-4bxm8 -o yaml
Specific Pod`s Full JSON
kubectl get po jordi-4bxm8 -o json
Pod`s separate Fields Information
kubectl explain pods
Pod`s detailed fields Information
kubectl explain pod.spec
Examples of YAML file.
apiVersion: v1
kind: Pod
metadata:
name: kubia-manual-test
spec:
containers:
- image: bearstark/jordi
name: jordi
ports:
- containerPort: 8080
protocol: TCP
Create a Pods using YAML.
kubectl create -f <yaml file dir.>
Check a specific Pod`s Log
kubectl logs <pod
s id>`
kubectl logs <pods id> -c <containers id>
When a request is received, a command about turning over toward specific ports.
kubectl port-forwarding <pod
s id>
Examples of YAML file included labels
apiVersion: v1
kind: Pod
metadata:
name: kubia-manual-v2
labels:
creation_method: manual
env: prod
spec:
containers:
- image: bearstark/jordi
name: jordi
ports:
- containerPort: 8080
protocol: TCP
After Creating a Pod, Checking a label of pods
kubectl get po --show-labels
kubectl get po -L creation_method,env
Modifing labels of existing pods
kubectl label pods <name of pods> <sort of label>=<content of label>
ex > kubectl label po kubia-manual creation_method=manual
Overwriting labels of Existing Pods
kubectl label po <name of pods> <sort of label>=<content of label> --overwrite
- 예시
kubectl label po kubia-manual-v2 env=debug --overwrite
Listing a pods using label selector
Value Comparison
kubectl get po -l <sort of label>=<content of label>
kubectl get po -l <sort of label>!=<content of label>
Specific Categorization
kubectl get po -l env
ex> kubectl get po -l creation_method=manual
Denially Specific Categorization
kubectl get po -l '!env
'
In Comparision
kubectl get po -l env in (prod, devel)
kubectl get po -l env notin (prod, devel)
Multi Conditions of In Comparision
kubectl get po -l env in (prod, devel),creation_method=manual
kubectl get po -l env notin (prod, devel),creation_method=manual
Config Label to Nodes
kubectl label node <node name> <sort of label>=<value of label>
예시
kubectl label node gke-jordi-default-pool-08313642-c93c gpu=true
Listing a Nodes using Label Selector
kubectl get nodes -l gpu=true
Listing a pods with detailed information and sorting
kubectl get pods -o wide --sort-by="{.spec.nodeName}"
Listing a pods with detailed information
kubectl get pods -o wide
Differences between label and annotation
Annotation is not for Identifying Informations.
Annotation can`t groups objects.
Annotation is not a selector.
Annotation can hlod much larger pieces of information.
Annotation primarily differentiate versions of Objects.
ex) alpha, beta, deprecated etc..
Label is for Identifying Informations.
Label can groups objects.
Label is a selector.
Config a Annotation to specific Pods
kubectl annotate pod kubia-manual [jorid.com/annotation="cute"](http://jorid.com/annotation=%22cute%22)
Check a Annotation of pods
kubectl describe po kubia-manual
About Namespaces(ns)
Necessity
- 개발, 운영, 테스트 등으로 나눠진 복잡한 시스템은 여러 구성요소들로 구성되어져 있다.
- 그 구성요소들을 분명하게 작은 그룹으로 나누어준다.
- 중복이 많은 Label과 달리, 특정 네임스페이스 내에 자원들에 중복이 없다.
Definition
- 수 많은 구성요소, 객체들을 명확히 나누어 주는 역할.
- In Namespace, Object is not overlapping. So 'resource name' can`t be not same between objects in namespace.
Methods(Commands)
Listing Namespaces(ns)
kubectl get ns
Listing Pods In specific Namespaces
kubectl get po --namespace kube-system
kubectl get po -n kube-system
Examples of Yaml for Creaing Namespace
apiVersion: v1
kind: Namespace
metadata:
name: custom-namespace
# kubectl create -f <this-file-name>
Commands for Creating Namespace
kubectl create ns custom-namespace
Creating a pod in specific Namespace
kubectl create -f kubia-manual.yaml -n custom-namespace
Listing a pods in all namespaces
kubectl get pods --all-namespaces
Modifying Default Namespace
kubectl config set-context --current --namespace=default
Setting Alias for Modeling Default Namespace
alias kcd='kubectl config set-context $(kubectl config current-context) --namespace'
What is $()?
print out a result of
Network Isolation
Basically each pods network that belong to other group are isolated each other.
But, Depending on network isolation settings, communication availability will be decided.
Deleting a pod
kubectl delete po <pod
s name>`
kubectl delete po -l <sort of label>=<value of label>
kubectl delete ns <namespace
a name>`
kubectl delete po --all
Deleting all objects
kubectl delete all --all
but the command can`t delete all of object absolutely.
'Infra > Kubernetes' 카테고리의 다른 글
About Service(1), Basic Concept (0) | 2019.11.19 |
---|---|
검색어 필터링 후 컴포넌트 삭제 Deleting components which are filtered by search text (0) | 2019.11.15 |
About Daemon Set (2) | 2019.11.12 |
About Replication Controller (0) | 2019.11.08 |
Differences Between Replica Set and Replica Controller (0) | 2019.11.01 |
- Total
- Today
- Yesterday
- POD
- Delete
- Replication Controller
- k8s
- Java
- kubernetes
- JVM
- JMM
- Java Memory Structure
- Effective Java
- 자바 메모리 구조
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |