Skip to content

Commit f074d3d

Browse files
authored
Merge pull request #9 from kolayne-IU-assignments/lab9
Lab9
2 parents 314f56c + bbb83c2 commit f074d3d

File tree

6 files changed

+209
-0
lines changed

6 files changed

+209
-0
lines changed

k8s/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Kubernetes
2+
3+
## Manual setup
4+
5+
```
6+
$ kubectl get pods,svc
7+
NAME READY STATUS RESTARTS AGE
8+
pod/web-app-py-64bf47b878-9gb7c 1/1 Running 0 62s
9+
10+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
11+
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 22m
12+
service/web-app-py LoadBalancer 10.109.167.161 <pending> 80:30520/TCP 39s
13+
```
14+
15+
## Manifest-based setup
16+
17+
```
18+
$ kubectl get pods,svc
19+
NAME READY STATUS RESTARTS AGE
20+
pod/web-app-py-54bf57f5d4-g8ktf 1/1 Running 0 3m23s
21+
pod/web-app-py-54bf57f5d4-k8ngh 1/1 Running 0 3m23s
22+
pod/web-app-py-54bf57f5d4-p4d6p 1/1 Running 0 3m23s
23+
24+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
25+
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4m43s
26+
service/web-app-py LoadBalancer 10.105.228.85 <pending> 5000:31951/TCP 3m23s
27+
$ minikube service --all
28+
|-----------|------------|-------------|--------------|
29+
| NAMESPACE | NAME | TARGET PORT | URL |
30+
|-----------|------------|-------------|--------------|
31+
| default | kubernetes | | No node port |
32+
|-----------|------------|-------------|--------------|
33+
😿 service default/kubernetes has no node port
34+
|-----------|------------|-------------|---------------------------|
35+
| NAMESPACE | NAME | TARGET PORT | URL |
36+
|-----------|------------|-------------|---------------------------|
37+
| default | web-app-py | 5000 | http://192.168.49.2:31951 |
38+
|-----------|------------|-------------|---------------------------|
39+
🎉 Opening service default/web-app-py in default browser...
40+
Opening in existing browser session.
41+
$
42+
```
43+
44+
## Ingress
45+
46+
```
47+
$ curl --resolve "kolay.ne:80:$( minikube ip )" --verbose http://kolay.ne/ ; echo
48+
* Added kolay.ne:80:192.168.49.2 to DNS cache
49+
* Hostname kolay.ne was found in DNS cache
50+
* Trying 192.168.49.2:80...
51+
* Connected to kolay.ne (192.168.49.2) port 80
52+
> GET / HTTP/1.1
53+
> Host: kolay.ne
54+
> User-Agent: curl/8.7.1
55+
> Accept: */*
56+
>
57+
* Request completely sent off
58+
< HTTP/1.1 404 Not Found
59+
< Date: Fri, 29 Mar 2024 13:58:46 GMT
60+
< Content-Type: text/html
61+
< Content-Length: 146
62+
< Connection: keep-alive
63+
<
64+
<html>
65+
<head><title>404 Not Found</title></head>
66+
<body>
67+
<center><h1>404 Not Found</h1></center>
68+
<hr><center>nginx</center>
69+
</body>
70+
</html>
71+
* Connection #0 to host kolay.ne left intact
72+
73+
$ curl --resolve "kolay.ne:80:$( minikube ip )" --verbose http://kolay.ne/time ; echo
74+
* Added kolay.ne:80:192.168.49.2 to DNS cache
75+
* Hostname kolay.ne was found in DNS cache
76+
* Trying 192.168.49.2:80...
77+
* Connected to kolay.ne (192.168.49.2) port 80
78+
> GET /time HTTP/1.1
79+
> Host: kolay.ne
80+
> User-Agent: curl/8.7.1
81+
> Accept: */*
82+
>
83+
* Request completely sent off
84+
< HTTP/1.1 200 OK
85+
< Date: Fri, 29 Mar 2024 13:58:51 GMT
86+
< Content-Type: text/html; charset=utf-8
87+
< Content-Length: 60
88+
< Connection: keep-alive
89+
<
90+
* Connection #0 to host kolay.ne left intact
91+
In MSK it's 16:57:49. Have you brushed your teeth today yet?
92+
$ curl --resolve "kolay.ne:80:$( minikube ip )" --verbose http://kolay.ne/cats ; echo
93+
* Added kolay.ne:80:192.168.49.2 to DNS cache
94+
* Hostname kolay.ne was found in DNS cache
95+
* Trying 192.168.49.2:80...
96+
* Connected to kolay.ne (192.168.49.2) port 80
97+
> GET /cats HTTP/1.1
98+
> Host: kolay.ne
99+
> User-Agent: curl/8.7.1
100+
> Accept: */*
101+
>
102+
* Request completely sent off
103+
< HTTP/1.1 200 OK
104+
< Date: Fri, 29 Mar 2024 13:58:56 GMT
105+
< Content-Type: text/plain; charset=utf-8
106+
< Content-Length: 162
107+
< Connection: keep-alive
108+
<
109+
* Connection #0 to host kolay.ne left intact
110+
There is a species of cat smaller than the average housecat. It is native to Africa and it is the Black-footed cat (Felis nigripes). Its top weight is 5.5 pounds.
111+
$
112+
```
113+
114+
Note: 5.5 pounds is about 2.49 kilograms

k8s/ingress.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: combined-web-app
5+
annotations:
6+
nginx.ingress.kubernetes.io/rewrite-target: /
7+
spec:
8+
rules:
9+
- host: kolay.ne
10+
http:
11+
paths:
12+
- path: /time
13+
pathType: Prefix
14+
backend:
15+
service:
16+
name: web-app-py
17+
port: {number: 5000}
18+
- path: /cats
19+
pathType: Prefix
20+
backend:
21+
service:
22+
name: web-app-go
23+
port: {number: 5050}

k8s/web-app-go-deployment.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: web-app-go
5+
spec:
6+
replicas: 3
7+
selector:
8+
matchLabels:
9+
app: web-app-go
10+
template:
11+
metadata:
12+
labels:
13+
app: web-app-go
14+
spec:
15+
containers:
16+
- name: web-app-go
17+
image: kolay0ne/app_go:lab8
18+
ports:
19+
- containerPort: 5000
20+
name: web-ui
21+
strategy:
22+
type: RollingUpdate
23+
rollingUpdate:
24+
maxUnavailable: 1

k8s/web-app-go-service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: web-app-go
5+
spec:
6+
selector:
7+
app: web-app-go
8+
ports:
9+
- protocol: TCP
10+
port: 5050
11+
targetPort: web-ui
12+
type: LoadBalancer

k8s/web-app-py-deployment.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: web-app-py
5+
spec:
6+
replicas: 3
7+
selector:
8+
matchLabels:
9+
app: web-app-py
10+
template:
11+
metadata:
12+
labels:
13+
app: web-app-py
14+
spec:
15+
containers:
16+
- name: web-app-py
17+
image: kolay0ne/app_py:lab8
18+
ports:
19+
- containerPort: 5000
20+
name: web-ui
21+
strategy:
22+
type: RollingUpdate
23+
rollingUpdate:
24+
maxUnavailable: 1

k8s/web-app-py-service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: web-app-py
5+
spec:
6+
selector:
7+
app: web-app-py
8+
ports:
9+
- protocol: TCP
10+
port: 5000
11+
targetPort: web-ui
12+
type: LoadBalancer

0 commit comments

Comments
 (0)