Post

Lightening lab 2

Lightening lab 2

**Commands’’:

1
controlplane $ for i in $(ls *.yaml); do echo filename: $i;echo "---" ;cat $i; done
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
filename: 2.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx1401
  namespace: dev1401
spec:
  containers:
  - image: kodekloud/nginx
    imagePullPolicy: IfNotPresent
    name: nginx
    ports:
    - containerPort: 9080
      protocol: TCP
    livenessProbe:
      exec:
        command:
        - ls
        - /var/www/html/file_check
      initialDelaySeconds: 10
      periodSeconds: 60
    readinessProbe:
      failureThreshold: 3
      httpGet:
        path: /
        port: 9080
        scheme: HTTP
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 1
    resources: {}
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-xfbcr
      readOnly: true
  nodeName: node01
  volumes:
  - name: default-token-xfbcr
    secret:
      defaultMode: 420
      secretName: default-token-xfbcr
filename: 3.yaml
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  creationTimestamp: null
  name: dice
spec:
  jobTemplate:
    metadata:
      creationTimestamp: null
      name: dice
    spec:
      completions: 1
      backoffLimit: 25
      activeDeadlineSeconds: 20

      template:
        metadata:
          creationTimestamp: null
        spec:
          containers:
          - image: kodekloud/throw-dice
            name: throw-dice-pod
            resources: {}
          restartPolicy: Never
  schedule: '*/1 * * * *'
status: {}

filename: 4.yaml
---
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: my-busybox
  name: my-busybox
  namespace: dev2406
spec:
  volumes:
  - name: secret-volume
    secret:
      secretName: dotfile-secret
  nodeName: controlplane
  containers:
  - image: busybox
    name: secret
    resources: {}
    volumeMounts:
    - name: secret-volume
      mountPath: "/etc/secret-volume"
    command: ["sh", "-c", "sleep 3600"]
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
filename: 5.yaml
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-vh-routing
spec:
  rules:
  - host: "watch.ecom-store.com"
    http:
      paths:
      - pathType: Prefix
        path: "/video"
        backend:
          service:
            name: video-service
            port:
              number: 8080
  - host: "apparels.ecom-store.com"
    http:
      paths:
      - pathType: Prefix
        path: "/wear"
        backend:
          service:
            name: apparels-service
            port:
              number: 8080


filename: throw-a-dice.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: throw-dice-pod
spec:
  containers:
  -  image: kodekloud/throw-dice
     name: throw-dice
  restartPolicy: Never
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
kubectl  get pod -n dev1401       nginx1401  -o yaml > 2.yaml
vim 2.yaml
kubectl  delete pod -n dev1401       nginx1401
kubectl  create cronjob dice --help
kubectl  create cronjob dice --schedule="*/1 * * * *" -o yaml --dry-run=client
kubectl  create cronjob dice --image=nginx --schedule="*/1 * * * *" -o yaml --dry-run=client
kubectl  create cronjob dice --image=nginx --schedule="*/1 * * * *" -o yaml --dry-run=client > 3.yaml
vim 3.yaml
kubectl create -f  3.yaml
kubectl create -f  2.yaml
vim 3.yaml
kubectl create -f  3.yaml
kubectl  get pods
kubectl  get pods -A
kubectl  run my-busybox -n dev2406 --image=busybox -- sleep 3600 --dry-run=client -o yaml
kubectl  get pods -n dev2406
kubectl  delete pod my-busybox -n dev2406
kubectl  get pods -A
kubectl  run my-busybox -n dev2406 --image=busybox  --dry-run=client -o yaml
kubectl  run my-busybox -n dev2406 --image=busybox  --dry-run=client -o yaml > 4.yaml
vim 4.yaml
kubectl create  -f  4.yaml
vim 2.yaml
kubectl  delete pod my-busybox -n dev2406
kubectl  delete pod -n dev1401       nginx1401
vim 5.yaml
kubectl  create -f 5.yaml
kubectl  create -f 2.yaml
kubectl  describe ing ingress-vh-routing
curl http://watch.ecom-store.com:30093/video
curl http://watch.ecom-store.com:30093/video -IL
http://apparels.ecom-store.com:30093/wear
curl http://apparels.ecom-store.com:30093/wear
curl http://apparels.ecom-store.com:30093/wear -IL
curl http://apparels.ecom-store.com:30093/weasasar -IL
kubectl get pods -A
kubectl  logs -f dev-pod-dind-878516
kubectl  logs -f dev-pod-dind-878516 -c log-x
kubectl  logs -f dev-pod-dind-878516 -c log-x > /opt/dind-878516_logs.txt
kubectl  logs  dev-pod-dind-878516 -c log-x > /opt/dind-878516_logs.txt
kubectl  get pod -n dev2406
vim 4.yaml
kubectl  create -f 4.yaml
kubectl delete pod secret -n dev2406
vim 4.yaml
kubectl  create -f 4.yaml
kubectl get pods -n dev2406
for i in $(ls *.yaml); do echo filename: $i;echo "---" ;cat $i; done

This post is licensed under CC BY 4.0 by the author.