<삭제시>
kubectl delete pod podname
<강제 삭제시>
kubectl delete pod podname --grace-period=0 --force
kubectl get pod --show-labels
: 모든 라벨값 확인 가능1) namespace 지정
[root@k8s-master] # kubectl create namespace infra-team-ns1
[root@k8s-master] # get namespaces
2) yaml file 작성
[root@k8s-master label-1]# vi label-1.yaml
apiVersion: v1
kind: Pod
metadata:
name: label-pod-a
namespace: infra-team-ns1
labels:
types: infra1
spec:
containers:
- image: dbgurum/k8s-lab:initial
name: pod-a-container
---
apiVersion: v1
kind: Pod
metadata:
name: label-pod-b
namespace: infra-team-ns1
labels:
types: infra1
spec:
containers:
- image: dbgurum/k8s-lab:initial
name: pod-b-container
---
apiVersion: v1
kind: Pod
metadata:
name: label-pod-c
namespace: infra-team-ns1
labels:
types: infra1
spec:
containers:
- image: dbgurum/k8s-lab:initial
name: pod-c-container
---
apiVersion: v1
kind: Service
metadata:
name: infra-svc1
namespace: infra-team-ns1
spec:
selector:
type: infra1
ports:
- port: 7777
3) 작성한 yaml file 로 pod, svc 생성
[root@k8s-master label-1]# kubectl apply -f label-1.yaml
4) 확인
[root@k8s-master label-1]# kubectl get po,svc -o wide -n infra-team-ns1
[root@k8s-master label-1]# kubectl get all -n infra-team-ns1
[root@k8s-master label-1]# kubectl describe service/infra-svc1 -n infra-team-ns1
### 방법1) node scheduler yaml code
apiVersion: v1
kind: Pod
metadata:
name: nosch-pod1
spec:
nodeSelector:
kubernetes.io/hostname: k8s-node1
containers:
- image: dbgurum/k8s-lab:initial
name: nosch-container
### 방법2) node scheduler yaml code
apiVersion: v1
kind: Pod
metadata:
name: nosch-pod1
spec:
nodeName: k8s-node1
containers:
- image: dbgurum/k8s-lab:initial
name: nosch-container
kubectl logs pod명 : container가 만들어진 상태에서 확인 가능