Post

Lightening lab 1

Lightening lab 1

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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: nginx-deploy
  name: nginx-deploy
spec:
  replicas: 4
  selector:
    matchLabels:
      app: nginx-deploy
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx-deploy
    spec:
      containers:
      - image: nginx:1.16
        name: nginx
        resources: {}
status: {}

---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: x-network-policy
  namespace: default
spec:
  podSelector:
    matchLabels:
      run: secure-pod
  policyTypes:
  - Ingress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          name: webapp-color
    ports:
    - protocol: TCP
      port: 80

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: log-volume
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  storageClassName: "manual"
  hostPath:
    path: "/opt/volume/nginx"


---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: log-claim
spec:
  storageClassName: "manual"
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 200Mi

---
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: logger
  name: logger
spec:
  volumes:
  - name: vol
    persistentVolumeClaim:
      claimName: log-claim
  containers:
  - image: nginx:alpine
    name: logger
    resources: {}
    volumeMounts:
    - name: vol
      mountPath: "/var/www/nginx"
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

---
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: redis
  name: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: redis
    spec:
      nodeName: controlplane
      volumes:
      - name: data
        emptyDir: {}
      - name: redis-config
        configMap:
          name: redis-config
      containers:
      - image: redis:alpine
        name: redis
        ports:
        - containerPort: 6397
        volumeMounts:
        - name: data
          mountPath: "/redis-master-data"
        - name: redis-config
          mountPath: "/redis-master"
        resources:
          requests:
            cpu: 0.2

status: {}

---
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: time-check
  name: time-check
  namespace: dvl1987
spec:

  volumes:
  - name: temp
    emptyDir: {}
  containers:
  - image: busybox
    name: time-check
    command: ["sh", "-c", "while true; do date; sleep $TIME_FREQ;done > /opt/time/time-check.log"]
    env:
      # Define the environment variable
      - name: TIME_FREQ  # Notice that the case is different here
                                   # from the key name in the ConfigMap.
        valueFrom:
          configMapKeyRef:
            name: time-config           # The ConfigMap this value comes from.
            key: TIME_FREQ
    volumeMounts:
    - name: temp
      mountPath: "/opt/time"
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
controlplane $
controlplane $
This post is licensed under CC BY 4.0 by the author.