Skip to content

Latest commit

 

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

devops-kubernetes

Submissions for the DevOps with Kubernetes course at the University of Helsinki

Setup

1. Install prerequisites

Verify the installation:

docker --version
kubectl version --client
k3d version
sops --version --check-for-updates

2. Create a Kubernetes cluster

k3d cluster create --port 8082:30080@agent:0 -p 8081:80@loadbalancer --agents 2
# create folder for PersistentVolume
docker exec k3d-k3s-default-agent-0 mkdir -p /tmp/kube

The manifests include a local PersistentVolume that is pinned to the first k3d agent node:

k3d-k3s-default-agent-0

If your cluster/node names are different, update manifests/persistentvolume.yaml before applying it.

3. Apply manifests

kubectl apply -f manifests/

export SOPS_AGE_KEY_FILE=$(pwd)/secrets/key.txt
sops --decrypt pingpong/manifests/enc/secret.enc.yaml | kubectl apply -f -
sops --decrypt todo_backend/manifests/enc/secret.enc.yaml | kubectl apply -f -

kubectl apply -f todo_app/manifests/todoapp-config.yaml
kubectl apply -f todo_app/manifests/persistentvolumeclaim.yaml
kubectl apply -f todo_app/manifests

kubectl apply -f todo_backend/manifests/todobackeng-config.yaml
kubectl apply -f todo_backend/manifests/database.yaml
kubectl apply -f todo_backend/manifests

kubectl apply -f log_output/manifests/logoutput-config.yaml
kubectl apply -f log_output/manifests

kubectl apply -f pingpong/manifests/pingpong-config.yaml
kubectl apply -f pingpong/manifests/database.yaml
kubectl apply -f pingpong/manifests

kubectl apply -f  todo_cron/manifests/todo-cron.yaml

Check that the storage and pods are ready:

kubectl get pv,pvc
kubectl get pods

The PVC should be Bound before the pods that mount it can start.

4. Access the applications

kubectl get svc,ing

Open the apps through Ingress:

5. Enable monitoring using Grafana

Follow instractions from monitoring README.md

Course tasks

Exercise Tag Description
1.1 1.1 Deploy an app (Log output) that generates a random string on startup, stores this string into memory, and outputs it every 5 seconds with a timestamp into a Kubernetes cluster.
1.2 1.2 Deploy a web server (Todo app) that outputs "Server started in port NNNN" when it is started.
1.3 1.3 Log output app: move the deployment into a declarative file.
1.4 1.4 Todo app: move the deployment into a declarative file.
1.5 1.5 Todo app: add GET / endpoint.
1.6 1.6 Use a NodePort Service to enable access to the Todo app.
1.7 1.7 Add an endpoint to request the current status in the Log output app and an Ingress to access it with a browser.
1.8 1.8 Switch to using Ingress instead of NodePort to access the Todo app.
1.9 1.9 Develop a second application that simply responds with "pong 0" to a GET request and increases a counter.
1.10 1.10 Split the Log output app into two containers in one pod and add a shared volume (emptyDir).
1.11 1.11 Share data between "Ping-pong" and "Log output" applications using persistent volumes.
1.12 1.12 Get a random picture from Lorem Picsum and display it in Todo app, update picture every 10 minutes.
1.13 1.13 Update a Todo app functionality.
2.1 2.1 Connect the Log output application and the Ping-pong application with HTTP. Remove the shared volume between those two applications.
2.2 2.2 Create a Todo backend service. It should have a GET /todos endpoint for fetching the list of todos and a POST /todos endpoint for creating a new todo.
2.3 2.3 Move the Log output and Pingpong apps to exercises namespace.
2.4 2.4 Move the Todo client and Todo backend to project namespace.
2.5 2.5 Create a ConfigMap for the Log output application to define one file information.txt and env variable MESSAGE.
2.6 2.6 Pass all the configurations to Todo as env variables that are defined either in a config map or in deployments.
2.7 2.7 Run a Postgres database as a stateful set (with one replica) and save the Pingpong application counter into the database.
2.8 2.8 Run a Postgres database as a stateful set (with one replica) and save the Todo tasks into the database.
2.9 2.9 Create a CronJob that generates a new todo every hour to remind to read a random wikipedia article.
2.10 2.10 Add request logging so that you can monitor every todo that is sent to the backend.

About

Submissions for the DevOps with Kubernetes course at the University of Helsinki

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages