Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
banderlog committed Dec 30, 2021
1 parent 5de2c93 commit a275009
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 398 deletions.
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,38 @@

![globohomo art style](pic/header.png)

Powered with cutting edge *Foretold Termination™* technology, famous "less than 10 seconds" calculator on kubernetes.
*Foretold Termination™* technology saves time on container unload.
Powered with cutting edge *Foretold Termination™* technology (saves time on container unload), famous "less than 10 seconds" calculator on kubernetes.

>Deploying applications to Kubernetes is not a straightforward process

### Cluster creation with `kind`
## Prerequisites

+ [docker](https://docs.docker.com/engine/install/ubuntu/)
+ [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) (or any other k8s cluster)
+ [kubectl](https://kubernetes.io/docs/tasks/tools/)
+ [helm](https://helm.sh/docs/intro/install/)


## Installation and usage

```
# cluster creation with `kind`
kind create cluster --config=./kind.yaml
# installlation
helm install k8-calc k8-calc/
# verification -- should output "69"
curl http://localhost:30000/
```

### Folders
For different calculation *simply* run `kubectl edit configmap calculateme-configmap` and change `calculateme: 60+9` line.

Run `kind delete cluster` to remove everything.


**NB:** each folder has it's own README.md
## How it works

+ arraysurfer -- k8s version with init pod
+ bc_container -- from scratch docker container for calculations
+ compose -- docker compose version
+ k8-calc -- help chart ready folder of k8s folder
+ k8s -- k8s version with reloader and nginx
- There is env string variable `calculateme` defined in the ConfigMap
- A [busybox](https://busybox.net/) pod runs it through [bc](https://www.gnu.org/software/bc/), writes an answer to a file in the mounted volume and dies
- A [nginx](https://www.nginx.com/) pod mounts this file as index.html, so it is accessible via an HTTP request
- The [Reloader](https://github.com/stakater/Reloader) watches ConfigMap and restarts busybox pod if it changed
4 changes: 0 additions & 4 deletions TODO.md

This file was deleted.

6 changes: 0 additions & 6 deletions arraysurfer/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions arraysurfer/calc-vars.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions arraysurfer/calculation.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions bc_container/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions bc_container/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions bc_container/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions bc_container/prepare_bc.sh

This file was deleted.

12 changes: 0 additions & 12 deletions compose/Makefile

This file was deleted.

9 changes: 0 additions & 9 deletions compose/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions compose/compose-bc.yml

This file was deleted.

22 changes: 0 additions & 22 deletions compose/compose-busybox.yml

This file was deleted.

2 changes: 0 additions & 2 deletions compose/compose.env

This file was deleted.

22 changes: 2 additions & 20 deletions k8-calc/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
apiVersion: v2
name: k8_calc
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
description: https://github.com/banderlog/k8s_calc
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "1.0.0"

dependencies:
- name: reloader
Expand Down
11 changes: 0 additions & 11 deletions k8-calc/README.md

This file was deleted.

38 changes: 16 additions & 22 deletions k8-calc/templates/bc-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ metadata:
name: bc
spec:
replicas: 1
# strategy:
# type: Recreate
selector:
matchLabels:
app: bc
Expand All @@ -18,25 +16,21 @@ spec:
labels:
app: bc
spec:
# https://stackoverflow.com/questions/63400156/configure-restart-policy-of-pod-from-deployment-config
# restartPolicy: Never
containers:
- name: bc
image: busybox
command: ['sh']
# args: ["-c", "echo WOLOLO; echo ${INPUT} | bc > '/tmp/index.html' && ping 8.8.8.8"]
args: ["-c", "echo WOLOLO; echo ${INPUT} | bc -l > '/tmp/index.html'"]
env:
- name: INPUT
valueFrom:
configMapKeyRef:
name: calculateme-configmap
key: calculateme
volumeMounts:
- mountPath: /tmp
name: exch-vol
restartPolicy: Always
- name: bc
image: busybox
env:
- name: INPUT
valueFrom:
configMapKeyRef:
name: calculateme-configmap
key: calculateme
command: ['sh']
args: ["-c", "echo ${INPUT} | bc -l > '/tmp/index.html'"]
volumeMounts:
- mountPath: /tmp
name: exch-vol
volumes:
- name: exch-vol
persistentVolumeClaim:
claimName: exch-vol
- name: exch-vol
persistentVolumeClaim:
claimName: exch-vol
2 changes: 1 addition & 1 deletion k8-calc/templates/exch-vol-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: exch-vol
spec:
accessModes:
- ReadWriteOnce
- ReadWriteOnce
resources:
requests:
storage: 1Mi
26 changes: 12 additions & 14 deletions k8-calc/templates/http-output-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ spec:
app: output
spec:
containers:
- name: output
image: nginx
# command: ['sh']
# args: ["-c", "cat /tmp/out.txt > /usr/share/nginx/html/index.html && ping 8.8.8.8"]
volumeMounts:
- mountPath: /usr/share/nginx/html/
name: exch-vol
- name: output
image: nginx
volumeMounts:
- mountPath: /usr/share/nginx/html/
name: exch-vol
volumes:
- name: exch-vol
persistentVolumeClaim:
claimName: exch-vol
- name: exch-vol
persistentVolumeClaim:
claimName: exch-vol
---
apiVersion: v1
kind: Service
Expand All @@ -36,7 +34,7 @@ spec:
selector:
app: output
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 32000
- protocol: TCP
port: 80
targetPort: 80
nodePort: 32000
17 changes: 0 additions & 17 deletions k8s/README.md

This file was deleted.

Loading

0 comments on commit a275009

Please sign in to comment.