Skip to content

Commit 138b605

Browse files
committed
ingres and refactoring
1 parent fbe21aa commit 138b605

9 files changed

+88
-44
lines changed

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,34 @@ Powered with cutting edge *Foretold Termination™* technology (saves time on co
1515

1616
## Installation and usage
1717

18-
**Installation example with kind:**
18+
**kind cluster [with ingress preparation](https://kind.sigs.k8s.io/docs/user/ingress/#using-ingress):**
1919
```
2020
# cluster creation with `kind`
2121
kind create cluster --config=./kind.yaml
2222
23+
# ingress NGINX controller
24+
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
25+
26+
# wait until is ready to process requests running
27+
kubectl wait --namespace ingress-nginx \
28+
--for=condition=ready pod \
29+
--selector=app.kubernetes.io/component=controller \
30+
--timeout=90s
31+
```
32+
33+
**k8-calc installation:**
34+
```
2335
# installation
2436
helm install k8-calc k8-calc/
2537
2638
# verification -- should output "69"
27-
curl http://localhost:30000/
39+
curl localhost/k8_calc
2840
```
2941

3042
**For different calculation *simply* do:**
3143
+ run `kubectl edit configmap calculateme-configmap`
3244
+ change `calculateme: 60+9` line, save and exit text editor
33-
+ check `http://localhost:30000/`
45+
+ check `localhost/k8_calc`
3446

3547
**To remove everything:**
3648
+ run `kind delete cluster`

TODO.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [x] Ingres
2+
- [ ] Argo CI/CD
3+
- [ ] Terraform configs for AWS/GCP/Azure

k8-calc/Chart.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v2
23
name: k8_calc
34
description: https://github.com/banderlog/k8s_calc

k8-calc/templates/bc-deployment.yaml

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
@@ -17,20 +18,20 @@ spec:
1718
app: bc
1819
spec:
1920
containers:
20-
- name: bc
21-
image: busybox
22-
env:
23-
- name: INPUT
24-
valueFrom:
25-
configMapKeyRef:
26-
name: calculateme-configmap
27-
key: calculateme
28-
command: ['sh']
29-
args: ["-c", "echo ${INPUT} | bc -l > '/tmp/index.html'"]
30-
volumeMounts:
31-
- mountPath: /tmp
32-
name: exch-vol
21+
- name: bc
22+
image: busybox
23+
env:
24+
- name: INPUT
25+
valueFrom:
26+
configMapKeyRef:
27+
name: calculateme-configmap
28+
key: calculateme
29+
command: ['sh']
30+
args: ["-c", "echo ${INPUT} | bc -l > '/tmp/index.html'"]
31+
volumeMounts:
32+
- mountPath: /tmp
33+
name: exch-vol
3334
volumes:
34-
- name: exch-vol
35-
persistentVolumeClaim:
36-
claimName: exch-vol
35+
- name: exch-vol
36+
persistentVolumeClaim:
37+
claimName: exch-vol

k8-calc/templates/calc-vars.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: ConfigMap
34
metadata:

k8-calc/templates/exch-vol-persistentvolumeclaim.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: PersistentVolumeClaim
34
metadata:
@@ -7,7 +8,7 @@ metadata:
78
name: exch-vol
89
spec:
910
accessModes:
10-
- ReadWriteOnce
11+
- ReadWriteOnce
1112
resources:
1213
requests:
1314
storage: 1Mi
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
@@ -15,26 +16,25 @@ spec:
1516
app: output
1617
spec:
1718
containers:
18-
- name: output
19-
image: nginx
20-
volumeMounts:
21-
- mountPath: /usr/share/nginx/html/
22-
name: exch-vol
19+
- name: output
20+
image: nginx
21+
volumeMounts:
22+
- mountPath: /usr/share/nginx/html/
23+
name: exch-vol
2324
volumes:
24-
- name: exch-vol
25-
persistentVolumeClaim:
26-
claimName: exch-vol
25+
- name: exch-vol
26+
persistentVolumeClaim:
27+
claimName: exch-vol
2728
---
2829
apiVersion: v1
2930
kind: Service
3031
metadata:
3132
name: output-service
3233
spec:
33-
type: NodePort
3434
selector:
3535
app: output
3636
ports:
37-
- protocol: TCP
38-
port: 80
39-
targetPort: 80
40-
nodePort: 32000
37+
# Default port used by the image (for Pod)
38+
- targetPort: 80
39+
# port on the Service
40+
port: 5678

k8-calc/templates/ingres.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: minimal-ingress
6+
annotations:
7+
# overcome the exposed URL in the backend service
8+
nginx.ingress.kubernetes.io/rewrite-target: "/"
9+
spec:
10+
rules:
11+
- http:
12+
paths:
13+
- pathType: Prefix
14+
path: "/k8_calc"
15+
backend:
16+
service:
17+
name: output-service
18+
port:
19+
number: 5678

kind.yaml

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
# for proper NodePort mapping
2-
# kind create cluster --config=./kind.yaml
3-
# https://stackoverflow.com/questions/62432961/how-to-use-nodeport-with-kind
4-
apiVersion: kind.x-k8s.io/v1alpha4
1+
# from https://kind.sigs.k8s.io/docs/user/ingress/
2+
---
53
kind: Cluster
4+
apiVersion: kind.x-k8s.io/v1alpha4
65
nodes:
7-
- role: control-plane
8-
extraPortMappings:
9-
- containerPort: 32000
10-
hostPort: 30000
11-
listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0"
12-
protocol: tcp # Optional, defaults to tcp
13-
- role: worker
6+
- role: control-plane
7+
kubeadmConfigPatches:
8+
- |
9+
kind: InitConfiguration
10+
nodeRegistration:
11+
kubeletExtraArgs:
12+
node-labels: "ingress-ready=true"
13+
extraPortMappings:
14+
- containerPort: 80
15+
hostPort: 80
16+
protocol: TCP
17+
- containerPort: 443
18+
hostPort: 443
19+
protocol: TCP

0 commit comments

Comments
 (0)