mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
1 line
82 KiB
JSON
1 line
82 KiB
JSON
{"pageProps":{"metadata":{"date":"\"2021-06-08 23:23:35 +08:00\"","date_modified":"\"2021-07-07 16:33:05 +08:00\"","language":"en","source":""},"title":"Solutions to SUSE Cloud native fundamentals scholarship exercises","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"note-on-my-personal-setup"},"children":[{"type":"text","value":"Note on my personal setup"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#note-on-my-personal-setup"},"children":[{"type":"text","value":"Note on my personal setup"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"trade-offs-for-monoliths-and-microservices"},"children":[{"type":"text","value":"Trade-offs for monoliths and microservices"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#trade-offs-for-monoliths-and-microservices"},"children":[{"type":"text","value":"Trade-offs for monoliths and microservices"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution"},"children":[{"type":"text","value":"Solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"endpoints-for-an-application-status"},"children":[{"type":"text","value":"Endpoints for an application status"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#endpoints-for-an-application-status"},"children":[{"type":"text","value":"Endpoints for an application status"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-1"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-1"},"children":[{"type":"text","value":"Solution"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution"},"children":[{"type":"text","value":"Findings after solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#findings-after-solution"},"children":[{"type":"text","value":"Findings after solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"application-logging"},"children":[{"type":"text","value":"Application logging"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#application-logging"},"children":[{"type":"text","value":"Application logging"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-2"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-2"},"children":[{"type":"text","value":"Solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"docker-for-application-packaging"},"children":[{"type":"text","value":"Docker for application packaging"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#docker-for-application-packaging"},"children":[{"type":"text","value":"Docker for application packaging"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"first-working-solution"},"children":[{"type":"text","value":"First working solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#first-working-solution"},"children":[{"type":"text","value":"First working solution"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution-1"},"children":[{"type":"text","value":"Findings after solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#findings-after-solution-1"},"children":[{"type":"text","value":"Findings after solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"deploy-your-first-kubernetes-cluster"},"children":[{"type":"text","value":"Deploy your first Kubernetes cluster"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#deploy-your-first-kubernetes-cluster"},"children":[{"type":"text","value":"Deploy your first Kubernetes cluster"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-3"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-3"},"children":[{"type":"text","value":"Solution"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution-2"},"children":[{"type":"text","value":"Findings after solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#findings-after-solution-2"},"children":[{"type":"text","value":"Findings after solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"kubernetes-resources"},"children":[{"type":"text","value":"Kubernetes resources"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#kubernetes-resources"},"children":[{"type":"text","value":"Kubernetes resources"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-4"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-4"},"children":[{"type":"text","value":"Solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"declarative-kubernetes-manifests"},"children":[{"type":"text","value":"Declarative Kubernetes manifests"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#declarative-kubernetes-manifests"},"children":[{"type":"text","value":"Declarative Kubernetes manifests"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-5"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-5"},"children":[{"type":"text","value":"Solution"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution-3"},"children":[{"type":"text","value":"Findings after solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#findings-after-solution-3"},"children":[{"type":"text","value":"Findings after solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"continuous-application-deployment"},"children":[{"type":"text","value":"Continuous application deployment"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#continuous-application-deployment"},"children":[{"type":"text","value":"Continuous application deployment"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-6"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-6"},"children":[{"type":"text","value":"Solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"the-cd-fundamentals"},"children":[{"type":"text","value":"The CD fundamentals"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#the-cd-fundamentals"},"children":[{"type":"text","value":"The CD fundamentals"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-7"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-7"},"children":[{"type":"text","value":"Solution"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"configuration-managers"},"children":[{"type":"text","value":"Configuration managers"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#configuration-managers"},"children":[{"type":"text","value":"Configuration managers"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"solution-8"},"children":[{"type":"text","value":"Solution"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/challenges.suse-cloud-native-fundamentals-scholarship-program#solution-8"},"children":[{"type":"text","value":"Solution"}]}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"I'll attempt to archive my answers to exercise here in one Org mode document.\nLet's see the reproducibility capability of this thing.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For future references, the lessons have their repo.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://github.com/udacity/nd064_course_1"},"children":[{"type":"text","value":"Lesson 1 exercises"}]}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"note-on-my-personal-setup"},"children":[{"type":"text","value":"Note on my personal setup"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For this program, I'm using Podman instead of Docker.\nThere are subtle differences when using with Podman — the biggest difference being it is not attached to the Docker registry by default.\n"}]},{"type":"element","tagName":"table","properties":{},"children":[{"type":"element","tagName":"thead","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Docker"}]},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Podman"}]}]}]},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"docker pull alpine"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"podman pull docker.io/alpine"}]}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"docker search alpine"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"podman search docker.io/alpine"}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since Podman is not attached to the Docker registry by default, you also have to specify this in Dockerfiles.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-docker"]},"children":[{"type":"text","value":"FROM docker.io/alpine\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can make Podman search through DockerHub by setting it as one of the fallback registries.\nJust set "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"unqualified-search-registries"}]},{"type":"text","value":" from your container configuration (see "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"containers-registries.conf.5"}]},{"type":"text","value":" manual page for more details).\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-toml"]},"children":[{"type":"text","value":"unqualified-search-registries = ['docker.io']\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Don't forget to login to DockerHub (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"podman login docker.io"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"h1","properties":{"id":"trade-offs-for-monoliths-and-microservices"},"children":[{"type":"text","value":"Trade-offs for monoliths and microservices"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"From the early stages of application development, it is fundamental to understand the requirements and available resources.\nOverall, these will contour the architecture decisions.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Imagine this scenario: you are part of the team that needs to outline the structure of a centralized system to book flight tickets for different airlines.\nAt this stage, the clients require the front-end(UI), payment, and customer functionalities to be designed.\nAlso, these are the individual requirements of each airline:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Airline A - payments should be allowed only through PayPal\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Airline B - payments should be disabled (bookings will be exclusively in person or via telephone)\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Airline C - payments should be allowed to use PayPal and debit cards\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Using the above requirements, outline the application architecture.\nAlso, elaborate your reasoning on choosing a microservice or monolith based approach.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"solution"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Considering that the airlines has an overlap of use cases particularly with Airline A and C both allowing Paypal, we're leaning into considering a microservice architecture.\nEach component in the service can then be configured individually by the development team of each airline.\nWe could also take in the factor if one of the airline changes its requirements, we would only have to inspect one component.\nHaving an monolith would be nice that all of the requirements of the airlines is wrapped in one package but if one team would have to maintain it, it would require them to go through the entire stack of each airline.\nIn this case, they would have to do it three times.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In my opinion, microservices would be a better choice.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's the summarized outline of the application design we're going to develop.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each component of the application would have to be stored with their own repository.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The front-end can be developed in parallel as we prioritize the payment system.\n We can then improve it as we develop the other and ideally make it easy for the clients to modify it for their own needs.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The payment system can then be configured to integrate with different services or be disabled entirely.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Set up individual pipelines for each component as we can test them individually at different pace.\n"}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"endpoints-for-an-application-status"},"children":[{"type":"text","value":"Endpoints for an application status"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This exercise can be located in the Lesson 1 exercise repo at "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"exercises/python-helloworld"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Extend the Python Flask application with /status and /metrics endpoints, considering the following requirements:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Both endpoints should return an HTTP 200 status code\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Both endpoints should return a JSON response e.g. "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"{\"user\": \"admin\"}"}]},{"type":"text","value":". (Note: the JSON response can be hardcoded at this stage)\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/status"}]},{"type":"text","value":" endpoint should return a response similar to this example: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"result: OK - healthy"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/metrics"}]},{"type":"text","value":" endpoint should return a response similar to this example: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"data: {UserCount: 140, UserCountActive: 23}"}]}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"solution-1"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For the prerequisites, you can just install Flask and you're mostly done.\nFor future references, here are the version of the tools I've used at the time.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"nix-shell -p 'python3Packages.flask' entr --run 'flask --version'\n"}]}]},{"type":"element","tagName":"pre","properties":{"className":["fixed-width"]},"children":[{"type":"text","value":"Python 3.8.9\nFlask 1.1.2\nWerkzeug 1.0.1"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\nAs for the solution:\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-python"]},"children":[{"type":"text","value":"from flask import Flask\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n return \"Hello World!\"\n\n@app.route(\"/status\")\ndef health_check():\n return { \"result\": \"OK - healthy\" }\n\n@app.route(\"/metrics\")\ndef metrics():\n return { \"data\": { \"UserCount\": 140, \"UserCountActive\": 23} }\n\nif __name__ == \"__main__\":\n app.run(host='0.0.0.0')\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution"},"children":[{"type":"text","value":"Findings after solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Comparing my solution from the solution shown in the video, I found out that Flask converts Python dictionaries into JSON.\nWe're still good on that note.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"application-logging"},"children":[{"type":"text","value":"Application logging"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Logging is a core factor in increasing the visibility and transparency of an application.\nWhen in troubleshooting or debugging scenarios, it is paramount to pin-point the functionality that impacted the service.\nThis exercise will focus on bringing the logging capabilities to an application.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"At this stage, you have extended the Hello World application to handle different endpoints.\nOnce an endpoint is reached, a log line should be recorded showcasing this operation.\nIn this exercise, you need to further develop the Hello World application collect logs, with the following requirements:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A log line should be recorded the timestamp and the requested endpoint e.g. "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"\"{{TIMESTAMP}}, {{ ENDPOINT_NAME}} endpoint was reached\""}]},{"type":"text","value":".\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The logs should be stored in a file with the name "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"app.log"}]},{"type":"text","value":".\n Refer to the logging Python module for more details.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Enable the collection of Python logs at the DEBUG level.\n Refer to the logging Python module for more details.\n"}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"solution-2"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Continuing from "},{"type":"element","tagName":"a","properties":{"href":"/Endpoints%20for%20an%20application%20status"},"children":[{"type":"text","value":"Endpoints for an application status"}]},{"type":"text","value":", here is the resulting Python code.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-python"]},"children":[{"type":"text","value":"import logging\nfrom flask import Flask\n\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n logging.info(\"/ endpoint was reached\")\n return \"Hello World!\"\n\n@app.route(\"/status\")\ndef health_check():\n logging.info(\"/status endpoint was reached\")\n return { \"result\": \"OK - healthy\" }\n\n@app.route(\"/metrics\")\ndef metrics():\n logging.info(\"/metrics endpoint was reached\")\n return { \"data\": { \"UserCount\": 140, \"UserCountActive\": 23} }\n\nif __name__ == \"__main__\":\n logging.basicConfig(format=\"%(asctime)s, %(message)s\", level=logging.DEBUG, filename=\"app.log\")\n app.run(host='0.0.0.0')\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"docker-for-application-packaging"},"children":[{"type":"text","value":"Docker for application packaging"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create the Docker image for the Go web application and push it to DockerHub, considering the following requirements:\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Dockerfile:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"use the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"golang:alpine"}]},{"type":"text","value":" base image\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"set the working directory to "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/go/src/app"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"make sure to copy all the files from the current directory to the container working directory (e.g. "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/go/src/app"}]},{"type":"text","value":")\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"to build the application, use "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"go build -o helloworld"}]},{"type":"text","value":" command, where "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-o helloworld"}]},{"type":"text","value":" will create the binary of the application with the name "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"helloworld"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"the application should be accessible on port "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"6111"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"and lastly, the command to start the container is to invoke the binary created earlier, which is "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"./helloworld"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Docker image:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"should have the name "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"go-helloworld"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"should have a valid tag, and a version with a major, minor, and patch included\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"should be available in DockerHub, under your username e.g. "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"pixelpotato/go-helloworld"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Docker container:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"should be running on your local machine, by referencing the image from the DockerHub with a valid tag e.g. "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"pixelpotato/go-helloworld:v5.12.3"}]}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"first-working-solution"},"children":[{"type":"text","value":"First working solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This should be simple enough as we can see from the file structure.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"go-helloworld\n├── main.go\n└── README.md\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As for the Dockerfile, I've made the following:\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-docker"]},"children":[{"type":"text","value":"FROM docker.io/golang:alpine\n\nCOPY . /go/src/app\nWORKDIR /go/src/app\nRUN go build -o helloworld main.go\nCMD [\"./helloworld\"]\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As for the requirements of the images and running the containerized app, we'll summarize it with the following Bash script.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"OWNER=\"foodogsquared\"\nIMG=\"go-helloworld\"\nVERSION=\"1.0.0\"\nREMOTE_IMG=\"${OWNER}/${IMG}:v${VERSION}\"\n\n# Build the image with the tag already in place.\npodman build --tag \"$IMG\" .\n\n# Run the packaged app.\npodman run -d -p 6111:6111 \"$IMG\"\n\n# Verify it's running.\npodman ps\n\n# Create another image to push it into the Docker registry with the proper naming.\npodman tag \"$IMG\" \"$REMOTE_IMG\"\n\n# Push the image to the Docker registry.\npodman push \"$REMOTE_IMG\"\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution-1"},"children":[{"type":"text","value":"Findings after solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"I guess my solution is close enough, I didn't realize the application should be configured its port to be exposed already in the Dockerfile and not when running the containerized app.\nWhoops!\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Apparently, there is the "},{"type":"element","tagName":"a","properties":{"href":"https://docs.docker.com/engine/reference/builder/#expose"},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"EXPOSE"}]}]},{"type":"text","value":" instruction, just requiring a port number.\nI also tested the Dockerfile from the solution and it still gave me an error from build time.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"I also didn't realize the solution is pretty much how the instructions laid it out.\nAt the end, it should look like the following code.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-docker"]},"children":[{"type":"text","value":"FROM docker.io/golang:alpine\n\nWORKDIR /go/src/app\nADD . .\n\nRUN go build -o helloworld main.go\nEXPOSE 6111\nCMD [\"./helloworld\"]\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"deploy-your-first-kubernetes-cluster"},"children":[{"type":"text","value":"Deploy your first Kubernetes cluster"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now you should have a Kubernetes cluster up and running.\nExamine the cluster and identity of the following details.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"From the kubeconfig, identify:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"the IP and port of the API server\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"authentication mechanism\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"From the cluster using kubectl commands to identify:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"endpoints of the control plane and add-ons\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"amount of nodes\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"node internal IP\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"the pod CIDR allocate to the node\n"}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"solution-3"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"From my setup with the given Vagrantfile from the lesson repo — i.e., after installing k3s in the virtual machine — you can inspect the kubeconfig located at "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/etc/rancher/k3s/k3s.yaml"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The IP and the port of the API server is visible from there.\nIn my case, it is 127.0.0.1 at port 6443.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As for the authentication mechanism, I'm not sure.\nBoth the cluster and the user have an attached certificate data.\nIt seems to be using matching certificate data from the user and the cluster.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As for getting cluster-related information.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Getting the endpoints of the control plane and the add-ons through "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl cluster-info"}]},{"type":"text","value":".\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One way of getting the amount of nodes is through "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl get nodes"}]},{"type":"text","value":" where it will print the nodes and their information one line at a time.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For the node's internal IP and the pod CIDR, both of them can be extracted with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl describe node ${NODE_NAME}"}]},{"type":"text","value":".\n"}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution-2"},"children":[{"type":"text","value":"Findings after solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"I mostly got it right.\nIt turns out there are "},{"type":"element","tagName":"a","properties":{"href":"https://kubernetes.io/docs/reference/access-authn-authz/authentication/"},"children":[{"type":"text","value":"different methods for authentication"}]},{"type":"text","value":".\nWhile the solution gave it as user and passwords, the kubeconfig I have seem to be using keys and certificates. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Also, you can get the configuration of the cluster with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl config view"}]},{"type":"text","value":".\nPretty handy.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"kubernetes-resources"},"children":[{"type":"text","value":"Kubernetes resources"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now you have learned many Kubernetes recourses, in this exercise, you will deploy the following resources using the kubectl command.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a namespace\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"demo"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"label: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"tier: test"}]}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a deployment:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"nginx:alpine"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"nginx-apline"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"demo"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"replicas: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"3"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"labels: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"app: nginx, tag: alpine"}]}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a service:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"expose the above deployment on port 8111\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"demo"}]}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a configmap:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"nginx-version"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"containing key-value pair: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"version=alpine"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"demo"}]}]}]}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"solution-4"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is practical test but it can summarized with a shell script.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"# Create the namespace with the specified label.\nkubectl create namespaces demo\nkubectl label namespaces demo tier=test\n\n# Create the specified deployment.\nkubectl create deployment nginx-alpine --image=nginx:alpine --replicas=3 --namespace=demo\nkubectl label deployment nginx-alpine app=nginx tag=alpine --namespace=demo\n\n# Expose the deployment as a service.\nkubectl expose deployment nginx-alpine --namespace=demo --port=8111\n\n# Create the config map.\nkubectl create configmaps nginx-version --namespace=demo --from-literal=version=alpine\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"declarative-kubernetes-manifests"},"children":[{"type":"text","value":"Declarative Kubernetes manifests"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Kubernetes is widely known for its imperative and declarative management techniques.\nIn the previous exercise, you have deployed the following resources using the imperative approach.\nNow deploy them using the declarative approach.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a namespace\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name: demo\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"label: tier: test\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a deployment:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image: nginx:alpine\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name:nginx-apline\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace: demo\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"replicas: 3\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"labels: app: nginx, tag: alpine\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a service:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"expose the above deployment on port 8111\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace: demo\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"a configmap:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name: nginx-version\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"containing key-value pair: version=alpine\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace: demo\n"}]}]}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"solution-5"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since they ask for 4 resources, we need 4 manifests.\nWe'll create four YAML manifests for this exercise.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The following manifests are created with the option to print the resources in YAML format with some modifications.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's one for the namespace.\nThe command used to make the template is "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl create namespace demo --dry-run=client --output=yaml"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\nkind: Namespace\nmetadata:\n creationTimestamp: null\n name: demo\n labels:\n tier: test\nspec: {}\nstatus: {}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The manifest for the deployment.\nThe command used to create the starting template is "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl create deployment nginx-alpine --namespace=demo --replicas=3 --image=nginx:alpine --dry-run=client --output=yaml"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: apps/v1\nkind: Deployment\nmetadata:\n creationTimestamp: null\n labels:\n app: nginx\n tag: alpine\n name: nginx-alpine\n namespace: demo\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: nginx-alpine\n strategy: {}\n template:\n metadata:\n creationTimestamp: null\n labels:\n app: nginx-alpine\n spec:\n containers:\n - image: nginx:alpine\n name: nginx\n resources: {}\nstatus: {}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The service manifest should be created after the deployment manifest is applied (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl apply -f deployment.yaml"}]},{"type":"text","value":").\nIt is created with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl expose deploy nginx-alpine --port=8111 --dry-run=client --output=yaml --namespace=demo"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\nkind: Service\nmetadata:\n creationTimestamp: null\n labels:\n app: nginx\n tag: alpine\n name: nginx-alpine\n namespace: demo\nspec:\n ports:\n - port: 8111\n protocol: TCP\n targetPort: 8111\n selector:\n app: nginx-alpine\nstatus:\n loadBalancer: {}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The resulting YAML output is from running the command (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl create configmap nginx-version --from-literal=version=alpine --dry-run=client --output=yaml --namespace=demo"}]},{"type":"text","value":").\nNo cleaning up is required.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\ndata:\n version: alpine\nkind: ConfigMap\nmetadata:\n creationTimestamp: null\n name: nginx-version\n namespace: demo\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"findings-after-solution-3"},"children":[{"type":"text","value":"Findings after solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Aside from the mostly correct answers, I also found out "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"kubectl get all -n demo"}]},{"type":"text","value":" to get all of the resources in the specified namespace.\nPretty handy for inspecting application-specific resources.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"continuous-application-deployment"},"children":[{"type":"text","value":"Continuous application deployment"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create a new GitHub Actions in the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/.github/workflows/docker-build.yml"}]},{"type":"text","value":" that will build and push the Docker image for a Python web application, with the following requirements:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Image name: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"python-helloworld"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Tag: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"latest"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Platforms: "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"platforms: linux/amd64,linux/arm64"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"GitHub marketplace has a rich suite of upstream actions that can be easily integrated within a repository.\nOne of the upstream action is "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/marketplace/actions/build-and-push-docker-images"},"children":[{"type":"text","value":"Build and Push Docker images"}]},{"type":"text","value":", which can be used to implement the required CI task.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The above GitHub action uses DockerHub Tokens and encrypted GitHub secrets to login into DockerHub and to push new images.\nTo set up these credentials refer to the following resources:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create "},{"type":"element","tagName":"a","properties":{"href":"https://www.docker.com/blog/docker-hub-new-personal-access-tokens/"},"children":[{"type":"text","value":"DockerHub Tokens"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create "},{"type":"element","tagName":"a","properties":{"href":"https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets"},"children":[{"type":"text","value":"GitHub encrypted secrets"}]}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"solution-6"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After creating a DockerHub access token (that serves as an alternative to passwords) and creating a GitHub encrypted secret, the workflow should now work.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's the resulting GitHub Actions workflow file:\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"name: Docker build image\non: [push]\njobs:\n docker:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n - name: Set up QEMU\n uses: docker/setup-qemu-action@v1\n - name: Setup Docker Buildx\n uses: docker/setup-buildx-action@v1\n - name: Login to DockerHub\n uses: docker/login-action@v1\n with:\n username: ${{ secrets.DOCKERHUB_USERNAME }}\n password: ${{ secrets.DOCKERHUB_TOKEN }}\n - name: Build and push\n id: docker_build\n uses: docker/build-push-action@v2\n with:\n push: true\n tags: ${{ secrets.DOCKERHUB_USERNAME }}/python-helloworld:latest\n platforms: linux/amd64,linux/arm64\n - name: Image digest\n run: echo ${{ steps.docker_build.outputs.digest }}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is shamelessly ripped off from the sample from the "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/marketplace/actions/build-and-push-docker-images"},"children":[{"type":"text","value":"GitHub Actions page"}]},{"type":"text","value":".\nI realized it's basically the answer for this exercise.\nEmbarrassing that I spent an hour for this.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"the-cd-fundamentals"},"children":[{"type":"text","value":"The CD fundamentals"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Continuous Delivery (CD) is the ability to get code changes reliably to production environments.\nThis practice should be automated and should enable developers to provide value to consumers efficiently.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this exercise, you will use ArgoCD to automate the delivery of an application to a Kubernetes cluster.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"solution-7"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The manifest is really the same as the example manifest from the walkthrough except with a different path pointing to the required manifests.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n name: ngnix-alpine\n namespace: argocd\nspec:\n destination:\n namespace: default\n server: https://kubernetes.default.svc\n project: default\n source:\n path: exercises/manifests\n repoURL: https://github.com/udacity/nd064_course_1\n targetRevision: HEAD\n syncPolicy: {}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then integrate it into the cluster with the following command.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"kubectl apply -f argocd-nginx-alpine.yaml\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You should then see the project on the ArgoCD application list where it requires an initial sync.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For assurance, you can check to see if the resources are deployed.\nContinuing from "},{"type":"element","tagName":"a","properties":{"href":"/Declarative%20Kubernetes%20manifests"},"children":[{"type":"text","value":"Declarative Kubernetes manifests"}]},{"type":"text","value":", the resources are mostly in the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"demo"}]},{"type":"text","value":" namespace.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"kubectl get pod -n demo\nkubectl get deploy -n demo\nkubectl get rs -n demo\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You should see them up and running.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"configuration-managers"},"children":[{"type":"text","value":"Configuration managers"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Using the manifests provided in the course repository, create a helm chart (Chart.yaml, templates, values.yaml) that will template the following parameters:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace name\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"replica count\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"tag\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"pull policy\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"resources\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"requests for CPU and memory\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"service\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"port\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"type (e.g. ClusterIP)\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"configmap data (e.g. the key-value pair)\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The chart details should be as following:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"name: nginx-deployment\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"version: 1.0.0\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"keywords: nginx\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once the Helm chart is available make sure that a default values.yaml file is available. This values file will be used as a default input file for the Helm chart. The values.yaml file should have the following specification:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"values.yaml\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace name: demo\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"replica count: 3\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image repository: nginx\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image tag: alpine\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image pull policy: IfNotPresent\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"resources: CPU 50m and memory 256Mi\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"service type: ClusterIP\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"service port: 8111\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"configmap data: \"version: alpine\"\n"}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, create 2 values files with the following specifications:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"values-staging.yaml\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace name: staging\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"replica count: 1\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image repository: nginx\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image tag: 1.18.0\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"resources: CPU 50m and memory 128Mi\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"configmap data: \"version: 1.18.0\"\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"values-prod.yaml\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"namespace name: prod\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"replica count: 2\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image repository: nginx\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"image tag: 1.17.0\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"resources: CPU 70m and memory 256Mi\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"service port: 80\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"configmap data: \"version: 1.17.0\"\n"}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, using the values files above (values-prod, values-staging), create 2 ArgoCD application, nginx-staging and nginx-prod respectively. These should deploy the nginx Helm Chart referencing each input values files.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"solution-8"},"children":[{"type":"text","value":"Solution"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the given manifests, we'll have to create a Helm package (or a Chart).\nHere's what the file structure of the chart.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"helm-nginx\n├── templates\n│ ├── configmap.yaml\n│ ├── deployment.yaml\n│ ├── namespace.yaml\n│ └── service.yaml\n├── Chart.yaml\n├── values.yaml\n├── values-prod.yaml\n└── values-staging.yaml\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The chart definition is the following file.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\nname: nginx-deployment\nversion: 1.0.0\nkeywords:\n- nginx\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the chart definition, we move on to the values to be used in the templates.\nIt's up to you how to structure the data but here's my solution on it.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"# namespace refers to the Kubernetes namespace resource.\nnamespace:\n name: demo\n\n# replicaCount is the number of instances to run in a replica set.\nreplicaCount: 3\n\n# image contains the detail of the container image to be used\nimage:\n repository: nginx\n tag: alpine\n pullPolicy: IfNotPresent\n\n# resources dictate the amount to spend\nresources:\n cpu: 50m\n memory: 256Mi\n\n# service configures the Kubernetes service resource\nservice:\n type: ClusterIP\n port: 8111\n\n# configmap configures the Kubernetes configmap resource\nconfigmap:\n data: \"version: alpine\"\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As for different versions of the values such as...\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"...for development version ("},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"values-staging.yaml"}]},{"type":"text","value":")...\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"namespace:\n name: staging\nreplicaCount: 1\nimage:\n repository: nginx\n tag: 1.18.0\nresources:\n cpu: 50m\n memory: 128Mi\nconfigmap:\n data: \"version: 1.18.0\"\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"...and for production ("},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"values-prod.yaml"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"namespace:\n name: prod\nreplicaCount: 2\nimage:\n repository: nginx\n tag: 1.17.0\nresources:\n cpu: 70m\n memory: 256Mi\nconfigmap:\n data: \"version: 1.17.0\"\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the templates, it is already given to us from the course exercise repo.\nWe just have to parameterize some of the values from the value file.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's one for the configmap...\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\ndata:\n {{ .Values.configmap.data }}\nkind: ConfigMap\nmetadata:\n name: nginx-version\n namespace: {{ .Values.namespace.name }}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"..., deployment...\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: apps/v1\nkind: Deployment\nmetadata:\n labels:\n app: nginx\n tag: alpine\n name: nginx-alpine\n namespace: {{ .Values.namespace.name }}\nspec:\n replicas: {{ .Values.replicaCount }}\n selector:\n matchLabels:\n app: nginx\n tag: alpine\n strategy:\n rollingUpdate:\n maxSurge: 25%\n maxUnavailable: 25%\n type: RollingUpdate\n template:\n metadata:\n labels:\n app: nginx\n tag: alpine\n spec:\n containers:\n - image: {{ .Values.image.repository }}:{{ .Values.image.tag }}\n imagePullPolicy: {{ .Values.image.pullPolicy }}\n name: nginx-alpine\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"..., namespace...\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\nkind: Namespace\nmetadata:\n labels:\n tier: test\n name: {{ .Values.namespace.name }}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"..., and service.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: v1\nkind: Service\nmetadata:\n labels:\n app: nginx\n tag: alpine\n name: nginx-alpine\n namespace: {{ .Values.namespace.name }}\nspec:\n ports:\n - port: {{ .Values.service.port }}\n protocol: TCP\n targetPort: {{ .Values.service.port }}\n selector:\n app: nginx\n tag: alpine\n type: {{ .Values.service.type }}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To deploy it in ArgoCD, we'll just have to specify it in the ArgoCD manifest.\nSince ArgoCD is heavily a GitOps tool, we have to put the files in a Git repo.\nFor now, let's assume the course repo as ours. "},{"type":"text","value":"\nJust change the Git repo URL and the path if you have your own version.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Additionally, the exercise requires to deploy two ArgoCD applications: one for staging (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"nginx-staging"}]},{"type":"text","value":") and production version (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"nginx-prod"}]},{"type":"text","value":") of the app.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's one for the production version...\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n name: nginx-prod\n namespace: argocd\nspec:\n destination:\n namespace: default\n server: https://kubernetes.default.svc\n project: default\n source:\n helm:\n valueFiles:\n - values-prod.yaml\n path: structured/assets/challenges.suse-cloud-native-fundamentals-scholarship-program/helm-nginx\n repoURL: https://github.com/foo-dogsquared/wiki\n targetRevision: HEAD\n syncPolicy: {}\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"...and the development version.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-yaml"]},"children":[{"type":"text","value":"apiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n name: nginx-staging\n namespace: argocd\nspec:\n destination:\n namespace: default\n server: https://kubernetes.default.svc\n project: default\n source:\n helm:\n valueFiles:\n - values-staging.yaml\n path: structured/assets/challenges.suse-cloud-native-fundamentals-scholarship-program/helm-nginx\n repoURL: https://github.com/foo-dogsquared/wiki\n targetRevision: HEAD\n syncPolicy: {}\n"}]}]}]},"backlinks":[{"path":"/literature.suse-cloud-native-fundamentals-scholarship-program","title":"SUSE Cloud native fundamentals scholarship program"}]},"__N_SSG":true} |