From c2ee6b023817a903450def82a425ad0d947f0b6e Mon Sep 17 00:00:00 2001 From: Aliaksei Karneyeu Date: Sat, 2 Mar 2024 01:49:07 +0100 Subject: [PATCH] improve tasks 2 and 3 --- .../2021-02-01-phase2-task4-setup-ci-cd.md | 3 ++- ...hase3-task2-run-blog-engine-on-k8s-pods.md | 7 +++-- ...ask3-run-blog-engine-on-k8s-deployments.md | 26 ++++++------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/tasks/_posts/2021-02-01-phase2-task4-setup-ci-cd.md b/tasks/_posts/2021-02-01-phase2-task4-setup-ci-cd.md index 6146005..5e3a7b4 100644 --- a/tasks/_posts/2021-02-01-phase2-task4-setup-ci-cd.md +++ b/tasks/_posts/2021-02-01-phase2-task4-setup-ci-cd.md @@ -42,7 +42,8 @@ Job should do following: #### 4.1. Update `build_wp_image` stage. -- **Build docker wordpress docker image with newly created plugin**: build wordpress image with provided version of plugin. +- **Build docker wordpress image with newly created plugin**: build wordpress image with provided version of plugin. +- **Push docker wordpress image with plugin to Docker Hub** #### 4.2. Run docker-compose with new wordpress image. diff --git a/tasks/_posts/2021-03-01-phase3-task2-run-blog-engine-on-k8s-pods.md b/tasks/_posts/2021-03-01-phase3-task2-run-blog-engine-on-k8s-pods.md index 6592274..b2ad4e9 100644 --- a/tasks/_posts/2021-03-01-phase3-task2-run-blog-engine-on-k8s-pods.md +++ b/tasks/_posts/2021-03-01-phase3-task2-run-blog-engine-on-k8s-pods.md @@ -34,7 +34,7 @@ You started learning Kubernetes from the Pods. So your first idea was to run "Vi - **Run pod with MySQL database**: Update `database.yaml` so that there would be pod `database` with `mysql` container that works on port `3306`. Password and other parameters should be hardcoded in manifest. - **Check that `database` pod is running**. -- **Run pod with Wordpress**: Update `wordpress.yaml` so that there would be pod `wordpress` with `app` container that works on port `80`. Password and other parameters should be hardcoded in manifest. Use `database` pod's address as your database. +- **Run pod with Wordpress**: Update `wordpress.yaml` so that there would be pod `wordpress` with `app` container that works on port `80`. Password and other parameters should be hardcoded in manifest. Use `database` pod's hostname as your database. - **Check that wordpress pod is running**. ### 4. Run Init container inside WordPress pod. @@ -55,6 +55,9 @@ Create Pull Request with changes on files: - `database.yaml` - `wordpress.yaml` + +### 6. Cleanup created resources + ### Additional tasks if you feel that it was too easy. 1. Resources and limits: Before running any container it's always nice to limit it's resources usage so that it doesn't allocate all of them. Try to use it. @@ -63,7 +66,7 @@ Create Pull Request with changes on files: ### Tips: -- _N/A_ +- Try to find info, how to get pod's hostname ### Recommended soft: diff --git a/tasks/_posts/2021-03-01-phase3-task3-run-blog-engine-on-k8s-deployments.md b/tasks/_posts/2021-03-01-phase3-task3-run-blog-engine-on-k8s-deployments.md index 26a145e..2c74170 100644 --- a/tasks/_posts/2021-03-01-phase3-task3-run-blog-engine-on-k8s-deployments.md +++ b/tasks/_posts/2021-03-01-phase3-task3-run-blog-engine-on-k8s-deployments.md @@ -35,24 +35,12 @@ Now it's time to scale your application to be able to handle load. So you decide ### 3. Run local WordPress setup in couple pods using Deployment. - Create Deployment with following parameters: + - deployment name: `wordpress` - replicas: `2` - pods labels `app: wordpress` - - container port should be `80` - - image for wordpress container should be `korney4eg/wordpress-empty:latest` - - pods selector should look for pods labeled `app: wordpress` - - pod name: `wordpress` + - use `wordpress` pod manifest from previous task as a template for deployment -### 4. Run Init container inside WordPress pod. - -{:refdef: style="text-align: center;"} -![Diagramm](assets/ph3_t2_p4.png) -{: refdef} - -- **Build container with wordpress that doesn't have plugin built it**. -- **Replace container image from `app` container with newly built image**. -- **Run Init container `plugin-download` that downloads plugin**: Before `app` container started we need to have [thank-after-post-plugin](https://github.com/korney4eg/thank-after-post-plugin) to be downloaded by `plugin-download` container and later to be mounted in `app` container. Please update `wordpress.yaml` file for this task. - -### 5. Make your work visible. +### 4. Make your work visible. Create Pull Request with changes on files: @@ -60,11 +48,11 @@ Create Pull Request with changes on files: - `database.yaml` - `wordpress.yaml` +### 5. Cleanup created resources + ### Additional tasks if you feel that it was too easy. -1. Resources and limits: Before running any container it's always nice to limit it's resources usage so that it doesn't allocate all of them. Try to use it. -2. Kubernetes has mechanism to check whether container is ready to handle traffic, it's called `readinessProbe`. Try to use it. -3. Kubernetes has mechanism to check whether container is ready to handle traffic, it's called `livenessProbe`. Try to use it. +- _N/A_ ### Tips: @@ -78,6 +66,8 @@ Create Pull Request with changes on files: - [Kuberentes API](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/) - [Kuberentes Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) +- [Kubernetes Service](https://kubernetes.io/docs/concepts/services-networking/service/) +- [Kubernetes StatefulSet](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/) ### FAQ