Skip to content

Commit f793b29

Browse files
committed
added kubernetes lab
1 parent 5a96560 commit f793b29

3 files changed

Lines changed: 129 additions & 4 deletions

File tree

kubernetes/09.md

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,96 @@
22

33
The Nautilus DevOps team needs a time check pod created in a specific Kubernetes namespace for logging purposes. Initially, it's for testing, but it may be integrated into an existing cluster later. Here's what's required:
44

5-
Create a pod called time-check in the devops namespace. The pod should contain a container named time-check, utilizing the busybox image with the latest tag (specify as busybox:latest).
5+
Create a pod called `time-check` in the `nautilus` namespace. The pod should contain a container named `time-check`, utilizing the `busybox` image with the latest tag (specify as `busybox:latest`).
66

7-
- Create a config map named time-config with the data TIME_FREQ=10 in the same namespace.
7+
- Create a config map named `time-config` with the data `TIME_FREQ=7` in the same namespace.
88

9-
- Configure the time-check container to execute the command: while true; do date; sleep $TIME_FREQ;done. Ensure the result is written /opt/finance/time/time-check.log. Also, add an environmental variable TIME_FREQ in the container, fetching its value from the config map TIME_FREQ key.
9+
- Configure the `time-check` container to execute the command: `while true; do date; sleep $TIME_FREQ;done`. Ensure the result is written `/opt/finance/time/time-check.log`. Also, add an environmental variable `TIME_FREQ` in the container, fetching its value from the config map `TIME_FREQ` key.
1010

11-
- Create a volume log-volume and mount it at /opt/finance/time within the container.
11+
- Create a volume `log-volume` and mount it at `/opt/finance/time` within the container.
1212

1313
> Note: The kubectl utility on jump_host is configured to operate with the Kubernetes cluster.
1414
1515
## Steps
1616

17+
1. Let's check namespace and create `nautilus` namespace
18+
19+
```sh
20+
kubectl get ns
21+
kubectl create ns nautilus
22+
```
23+
24+
2. Let's create the `k3s.yml` file using [this contents](./09.yml)
25+
26+
```YAML
27+
# ConfigMap
28+
apiVersion: v1
29+
kind: ConfigMap
30+
metadata:
31+
name: time-config
32+
namespace: nautilus
33+
data:
34+
TIME_FREQ: "7"
35+
36+
---
37+
38+
apiVersion: v1
39+
kind: Pod
40+
metadata:
41+
name: time-check
42+
namespace: nautilus
43+
labels:
44+
app: time-check
45+
spec:
46+
containers:
47+
- name: time-check
48+
image: busybox:latest
49+
command: ["/bin/sh", "-c", "while true; do date >> /opt/finance/time/time-check.log; sleep ${TIME_FREQ}; done"]
50+
env:
51+
- name: TIME_FREQ
52+
valueFrom:
53+
configMapKeyRef:
54+
name: time-config
55+
key: TIME_FREQ
56+
volumeMounts:
57+
- name: log-volume
58+
mountPath: /opt/finance/time
59+
resources:
60+
limits:
61+
cpu: 100m
62+
memory: 128Mi
63+
requests:
64+
cpu: 100m
65+
memory: 128Mi
66+
volumes:
67+
- name: log-volume
68+
emptyDir: {}
69+
```
70+
71+
3. Let's run the following command:
72+
73+
```sh
74+
kubectl apply -f k3s.yml
75+
```
76+
77+
> It will create configmap and pod
78+
79+
4. We can verify
80+
81+
```sh
82+
kubectl get pods -n nautilus
83+
```
84+
85+
```shell
86+
kubectl get pods -n nautilus
87+
NAME READY STATUS RESTARTS AGE
88+
time-check 1/1 Running 0 19s
89+
```
90+
91+
5. Verify log:
92+
To verify log, we can execute the container of the pods and inside we can check our log files.
93+
94+
```sh
95+
kubectl exec -it time-check -n nautilus /bin/sh
96+
cat /opt/finance/time/time-check.log
97+
```

kubernetes/09.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ConfigMap
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: time-config
6+
namespace: nautilus
7+
data:
8+
TIME_FREQ: "7"
9+
10+
---
11+
12+
apiVersion: v1
13+
kind: Pod
14+
metadata:
15+
name: time-check
16+
namespace: nautilus
17+
labels:
18+
app: time-check
19+
spec:
20+
containers:
21+
- name: time-check
22+
image: busybox:latest
23+
command: ["/bin/sh", "-c", "while true; do date >> /opt/finance/time/time-check.log; sleep ${TIME_FREQ}; done"]
24+
env:
25+
- name: TIME_FREQ
26+
valueFrom:
27+
configMapKeyRef:
28+
name: time-config
29+
key: TIME_FREQ
30+
volumeMounts:
31+
- name: log-volume
32+
mountPath: /opt/finance/time
33+
resources:
34+
limits:
35+
cpu: 100m
36+
memory: 128Mi
37+
requests:
38+
cpu: 100m
39+
memory: 128Mi
40+
volumes:
41+
- name: log-volume
42+
emptyDir: {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Design and Deploy a Two-Tier Wordpress Application High Availabiltiy on AWS Cloud
2+

0 commit comments

Comments
 (0)