-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpod.txt
50 lines (42 loc) · 1.45 KB
/
pod.txt
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# create pods using for loop
for i in `seq 1 5`; do k run nginx$i --image=nginx -l app=v1 ; done
# manifest file for pod
apiVersion: v1
kind: Pod
metadata:
mane: my-pod
spec:
containers:
- name: my-container
image: nginx:latest
kubectl create -f pod-manifest-file.yaml
kubectl get pods
kubectl describe pod pod-name
kubectl exec -it pod-name -- pwd #cmd run your pod
kubectl exec pod-name -- $cmd_that_we_want_to_run #e.g whoami
kubectl get pod webapp-color -o yaml > pod.yaml # to save yaml file of existing pod
kubectl run pod-name --image=nginx --dry-run=client -o yaml #command to generate pod yaml file
kubectl exec ubuntu-sleeper -- whoami
#pod labels
k get po --show-labels -l app=v3
k get po --show-labels --selector=app=v2
k label po -l "app in (v2,v3)" tier=web
k label po -l "tier in (web)" evn=prod
k get po --show-labels
k describe po nginx2 | grep -i "labels"
# pod annotations
k annotate po -l app=v2 owner=marketing
k annotate po nginx{1..3} description='my description'
k annotate po nginx4 nginx4 description='my description'
k describe po nginx3 | grep -i 'annotations'
# pod commands to remove labels
k label po nginx1 nginx2 app-
k label po nginx{1..4} app-
k label po -l app app-
# pod
kubectl edit pod my-pod -n my-namespace
kubectl replace -f elephant.yaml --force
kubectl replace -f pod.yaml --force
kubectl apply -f pod.yaml --force
kubectl -n my-namespace logs my-pod
kubectl exec -it my-pod -n my-namespace -- cat /log/app.log