tag:blogger.com,1999:blog-35321887050979411072024-03-17T20:14:05.934-07:00shawonruet | Tech BlogTech Blog & TutorialsAshadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.comBlogger494125tag:blogger.com,1999:blog-3532188705097941107.post-15642193031275287272024-03-07T20:36:00.000-08:002024-03-07T21:07:46.161-08:00Day-3: Connecting Docker Containers (Module-3- Docker Zero To Hero Bangla Course)<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNc6gsMa_96wr9qMlr_cCBAudbp_oQ3ruOr6okcGvIB1gUEIbN6p7Y5suQXFe3pz6sxfobCRt8oGlaAO8zXXr8T6tqsIbx4rLHXfG6ABajiSrWpTuy9jPZBvfDyV8KvTf-NcEHVbuYGio8ipGEJnhVZrXg7HMY80WE91bALOJZM9Jd-VyjZ6AZeAc3cdeS/s1280/Module-3-Connecting-Docker-Containers.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNc6gsMa_96wr9qMlr_cCBAudbp_oQ3ruOr6okcGvIB1gUEIbN6p7Y5suQXFe3pz6sxfobCRt8oGlaAO8zXXr8T6tqsIbx4rLHXfG6ABajiSrWpTuy9jPZBvfDyV8KvTf-NcEHVbuYGio8ipGEJnhVZrXg7HMY80WE91bALOJZM9Jd-VyjZ6AZeAc3cdeS/w640-h360/Module-3-Connecting-Docker-Containers.jpg" width="640" /></a></div><p></p><p><br /></p><p style="text-align: left;"><span style="font-size: medium;"><b> Create a Common Network for PHP & MySQL container</b></span></p><ol style="text-align: left;"><li><span style="font-size: medium;"><b> </b><span style="white-space: pre;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker network create chatbot</span></span></span></li></ol><p style="text-align: left;"><span style="font-size: medium;"><b> PHP Container</b><br /></span></p><ol style="text-align: left;"><li><span style="font-size: medium;"> <span><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">At first clone this repo </span><a href="https://github.com/shawon100/RUET-ChatBot" style="text-decoration: none;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #009668; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">https://github.com/shawon100/RUET-ChatBot</span></a></span></span></li><li role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Then go to the folder. Change the host name from localhost to <b>db</b> and add password <b>1test2</b> in <b>config.php</b></span></span></li><li><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Build the image</span><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></li><li><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> docker build -t chatbotimage .</span></span></li><li><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Finally Run the Image</span></span></li><li><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker run -d -p 5400:80 --name chatbotapp --network chatbot chatbotimage</span></span></li></ol><p style="text-align: left;"><span style="font-size: medium;"><b> MySQL Container</b></span></p><p style="text-align: left;"><span style="font-size: medium;"> Pull mysql image and then Run<br /></span></p><ol id="docs-internal-guid-92a81ca0-7fff-d8cd-81ea-9f37495e765d" style="margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px; text-align: left;"><li aria-level="1" style="background-color: transparent; color: #695d46; font-family: "Open Sans", sans-serif; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;"><p role="presentation" style="line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker pull mysql</span></span></p></li><li aria-level="1" style="background-color: transparent; color: #695d46; font-family: "Open Sans", sans-serif; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;"><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker run -d -p 3306:3306 --name db --network chatbot -e MYSQL_ROOT_PASSWORD=1test2 -e MYSQL_DATABASE=chat mysql</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Exec into mysql container</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker exec -it db bash</span></b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Login to mysql and database</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">mysql -u root -p</span></b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b>use chat;</b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"> </span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;">Run the sql commands from the database/chat.sql to create user & </span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;">insert data</span><span style="font-size: medium;"><br /></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Go to http://localhost:5400 </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b>Video tutorial</b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b> </b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b> </b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><b></b></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-size: medium;"><b><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/IR7cqi0RRRg" width="520" youtube-src-id="IR7cqi0RRRg"></iframe></b></span></div><span style="font-size: medium;"><b><br /> </b></span><br /><p></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><br /></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: medium;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p></li></ol>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-930396222352876622024-02-25T08:23:00.000-08:002024-02-25T08:34:20.429-08:00Day-2:Docker Zero To Hero Bangla Course (Module-2- Multistage Docker Images & Containers) <p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihGLzpu0FtiDXDDEx5H0cp_Tpgn6ZhRWXsPBPXXlHZzamXN8FfXHhb4RFDxjpGztyGYVUn1-Mg4UNSn16zElfhqXErwhwUblFpqoDDf7KJDAHurtnJeAEWXf56szkR6_BVZQwnoxunub8v5TNLxRRqB-WmqS81Fz55LshBS3R8IPeKVyXt5Hy3fGVBQS7P/s1280/Module-2-Docker%20Zero%20To%20Hero%20Bangla%20Course.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihGLzpu0FtiDXDDEx5H0cp_Tpgn6ZhRWXsPBPXXlHZzamXN8FfXHhb4RFDxjpGztyGYVUn1-Mg4UNSn16zElfhqXErwhwUblFpqoDDf7KJDAHurtnJeAEWXf56szkR6_BVZQwnoxunub8v5TNLxRRqB-WmqS81Fz55LshBS3R8IPeKVyXt5Hy3fGVBQS7P/w640-h360/Module-2-Docker%20Zero%20To%20Hero%20Bangla%20Course.jpg" width="640" /></a></div><p></p><p><br /></p><p style="text-align: center;"><b>Docker Architecture</b></p><p><br /></p><p><img height="359px;" id="docs-internal-guid-aba6a89a-7fff-099c-c8ea-f018fbe3fcc4" src="https://lh7-us.googleusercontent.com/pEz_lbMIkGOwUR9-vs9oMOcF_fvSQsqT_17Xpol11rRIAeYIVyTlfpkSzndhGxaC_dlzbdSdlPrJNluI05VJ2gbBar46gqmYku3geNFKU3Q-lxZCcXse8-waaSX1XaJPzKrnfcplDYq895kMiS3mty5izQ=s2048" width="666px;" /> <b> </b></p><p><b>Docker Daemon (dockerd)</b>:
At the core of Docker's architecture is the Docker daemon, <code>dockerd</code>. It runs on the host machine and manages Docker objects such as images, containers, networks, and volumes. The daemon listens for Docker API requests and executes them. It's responsible for building, running, and distributing Docker containers.</p><b>Docker Client</b>:
The Docker client is a command-line interface (CLI) tool that allows users to interact with the Docker daemon via the Docker Remote API. Users issue commands to the Docker client, which then communicates with the Docker daemon to perform the requested actions. The client can run on the same machine as the daemon or on a remote machine that connects to the daemon over a network.<p><b>Docker Registries</b>:
Docker registries are repositories for Docker images. They store and
distribute Docker images, allowing users to share and collaborate on
containerized applications. Docker Hub is the default public registry
provided by Docker, which hosts a vast collection of pre-built images
for popular software stacks. Organizations can also set up private
registries to store proprietary or sensitive images within their
infrastructure.</p><p> </p><p style="text-align: center;"><b>Multi Stage Dockerfile </b></p><p>Multi-stage Dockerfile is an essential feature provided by Docker that allows developers to create more efficient and smaller Docker images, resulting in faster builds, reduced image sizes, and improved security. The importance of using multi-stage Dockerfiles can be summarized as follows:</p><ol><li><p><b>Reduced Image Size</b>:
Multi-stage builds enable developers to build images with only the necessary dependencies and artifacts needed for runtime. By using separate stages in the Dockerfile, you can build your application in one stage and then copy only the compiled binary or artifacts into a new stage. This approach helps to minimize the final image size by eliminating unnecessary build-time dependencies and intermediate files, resulting in smaller and more lightweight images.</p></li><li><p><b>Faster Build Times</b>:
With multi-stage builds, Docker can execute multiple build stages concurrently, optimizing the build process and reducing overall build times. By separating the build environment from the runtime environment, you can take advantage of caching mechanisms provided by Docker. This means that subsequent builds only need to rebuild the stages that have changed, resulting in faster iterative development cycles and quicker deployment of updates.</p></li><li><p><b>Improved Security</b>:
Multi-stage builds promote better security practices by reducing the attack surface of Docker images. By segregating the build environment from the runtime environment, you can ensure that only the necessary dependencies and runtime libraries are included in the final image. This helps to mitigate security vulnerabilities and potential exploits that may exist in the development and build tools used during the build process.</p></li><li><p><b>Simplified Build Pipeline</b>:
Multi-stage Dockerfiles simplify the build pipeline by encapsulating the entire build process within a single Dockerfile. This makes it easier to manage and maintain the build process, as all the necessary steps for building, testing, and packaging the application are defined in one place. Additionally, multi-stage builds make it easier to share and collaborate on Dockerfiles, as they encapsulate best practices and standardize the build process across different environments.</p></li><li><p><b>Portability and Consistency</b>:
Multi-stage Dockerfiles promote portability and consistency across different deployment environments. By defining the build environment and runtime environment separately, you can ensure that the application behaves consistently across different platforms and deployment scenarios. This simplifies the process of deploying applications to production, testing, and staging environments, reducing the risk of compatibility issues and runtime errors.</p></li></ol><p><b> </b></p><p>Clone the Repo: git clone <a href="https://github.com/shawon100/Angular-CRUD">https://github.com/shawon100/Angular-CRUD</a></p><p>Go to Angular-CRUD folder</p><p><b>cd Angular-CRUD </b><br /></p><p>Remove existing Dockerfile and Create a New Dockerfile</p><div style="background-color: #1f1f1f; color: #cccccc; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">### STAGE 1: Build ###</span></div><div><span style="color: #c586c0;">FROM</span><span style="color: #cccccc;"> </span><span style="color: #4ec9b0;">node</span><span style="color: #cccccc;">:</span><span style="color: #9cdcfe;">10-alpine</span><span style="color: #cccccc;"> </span><span style="color: #c586c0;">AS</span><span style="color: #cccccc;"> </span><span style="color: #4ec9b0;">build</span></div><div><span style="color: #c586c0;">WORKDIR</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">/usr/src/app</span><span style="color: #cccccc;"> </span></div><div><span style="color: #c586c0;">COPY</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">.</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">/usr/src/app</span><span style="color: #cccccc;"> </span></div><div><span style="color: #c586c0;">RUN</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">npm</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">install</span><span style="color: #cccccc;"> </span></div><div><span style="color: #c586c0;">RUN</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">npm</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">run</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">build</span><span style="color: #cccccc;"> </span></div><br /><div><span style="color: #6a9955;">### STAGE 2: RUN ###</span></div><div><span style="color: #c586c0;">FROM</span><span style="color: #cccccc;"> </span><span style="color: #4ec9b0;">nginx</span><span style="color: #cccccc;">:</span><span style="color: #9cdcfe;">1.17.1-alpine</span></div><div><span style="color: #c586c0;">ADD</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">https://raw.githubusercontent.com/shawon100/Angular-CRUD/master/nginx.conf</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">/etc/nginx/nginx.conf</span></div><div><span style="color: #c586c0;">COPY</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">--from</span><span style="color: #d4d4d4;">=</span><span style="color: #9cdcfe;">build</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">/usr/src/app/dist/crud</span><span style="color: #cccccc;"> </span><span style="color: #9cdcfe;">/usr/share/nginx/html</span></div></div><p> Build the Docker Image</p><p><b> docker build -t angularcrud .</b></p><p><b> </b>Run the Docker Container</p><p><b> docker run -d -p 4200:80 --name angularapp angularcrud</b></p><p><b> </b>Access the application</p><p><b> http://localhost:4200</b></p><p><b><br /></b></p><p><b>Video Tutorial</b></p><p><b><br /></b></p><p></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/Q5BE4HL9GVM" width="520" youtube-src-id="Q5BE4HL9GVM"></iframe></div><br /><b><br /></b><p></p><p><b><br /></b></p><p><b><br /></b></p><p> <br /></p><p><br /></p><p><b> </b><br /></p><p> </p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-41008285317983835062024-02-22T20:14:00.000-08:002024-02-24T12:54:29.497-08:00Docker Zero To Hero Bangla Course (Module-1- Getting Started with Docker)<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSEAYmvIvVVdwxTG33Jga6onXSvddcaBQnofqcqLNMe-vRrDFUgxDS0ihYTp-txlfz4HxZ8VFcqI8izaYmVKL9MsP1rdxfkp5ND7-kq5Cd1wkTFG3Lno1LBzgN8xDqhzQRucRQj5tFyLKnBEZeA-Pdfn-sxJ4d0WtZLc6p7E4o0T86_vzEr1wKe5Edxlgx/s1280/Docker%20Zero%20To%20Hero%20Bangla%20Course.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSEAYmvIvVVdwxTG33Jga6onXSvddcaBQnofqcqLNMe-vRrDFUgxDS0ihYTp-txlfz4HxZ8VFcqI8izaYmVKL9MsP1rdxfkp5ND7-kq5Cd1wkTFG3Lno1LBzgN8xDqhzQRucRQj5tFyLKnBEZeA-Pdfn-sxJ4d0WtZLc6p7E4o0T86_vzEr1wKe5Edxlgx/w640-h360/Docker%20Zero%20To%20Hero%20Bangla%20Course.jpg" width="640" /></a></div><p></p><p><br /></p><p><b> Docker Zero To Hero Bangla Course (Module-1- Getting Started with Docker)</b><br /></p><p><br /></p><p>Docker is a platform that allows developers to package, distribute, and
manage applications within containers. These containers encapsulate
everything an application needs to run, including libraries,
dependencies, and runtime environments. Docker utilizes operating
system-level virtualization to provide lightweight and efficient
isolation of application resources.</p><p><br /></p><p><span style="font-size: medium;"><b>Docker Installation in Ubuntu</b></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo apt-get update</span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo apt-get install docker.io</span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo systemctl enable docker </span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo groupadd docker</span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo usermod -aG docker $USER</span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">newgrp docker </span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker --version</span><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: medium;">Repo Link: <a href="https://github.com/shawon100/python_flask_docker" target="_blank">https://github.com/shawon100/python_flask_docker</a><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Clone Repo: git clone</span><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span><span style="font-size: medium;"><a href="https://github.com/shawon100/python_flask_docker" target="_blank">https://github.com/shawon100/python_flask_docker</a><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Go to python_flask_docker folder and Build the Docker Image</span></span></p><p><span style="font-size: medium;"><b><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker build -t pythonflaskdocker .</span></b></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Run the container</span></span></p><p><span style="font-size: medium;"><b><span><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker run -d -p 7000:5000 --name pythonflaskcontainer pythonflaskdocker</span></span></b></span></p><p><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Open your browser<b>: http://localhost:7000</b></span></span></p><p><span style="font-size: medium;"><span><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Logs Checking Command in Docker</span></span></span></p><p><span style="font-size: medium;"><b><span><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker logs -f pythonflaskcontainer</span></span></b></span></p><p><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></b></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Stop Docker Container</span></span></p><p><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker stop pythonflaskcontainer </span></span></b></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Start Docker Container</span></span></p><p><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker start </span></span></b><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pythonflaskcontainer </span></span></b></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Remove Docker Container</span></span></p><p><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker rm </span></span></b><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pythonflaskcontainer</span></span></b></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Remove Docker Images</span></span></p><p><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker rmi </span></span></b><b><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">pythonflaskdocker</span></span></b></p><p><br /></p><p><b><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Video tutorial (Language- Bangla)</span></span><span style="font-size: medium;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></span></b></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></span></p><p><span style="font-size: small;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/eHVkgI_bDas" width="520" youtube-src-id="eHVkgI_bDas"></iframe></span></div><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></span><p>Advantages of Docker:</p><ol><li><p><b>Portability</b>: Docker containers are highly portable and can run on any machine that has the Docker runtime installed, regardless of the underlying operating system. This eliminates the "it works on my machine" problem and ensures consistent behavior across different environments.</p></li><li><p><b>Consistency</b>: With Docker, developers can define the environment and dependencies required for their applications in a Dockerfile. This ensures consistency between development, testing, and production environments, reducing the likelihood of runtime errors due to environmental differences.</p></li><li><p><b>Isolation</b>: Docker containers provide process-level isolation, enabling applications to run independently of one another on the same host. This isolation enhances security by minimizing the impact of any vulnerabilities or issues within one container on others running on the same system.</p></li><li><p><b>Resource Efficiency</b>: Docker containers share the host system's kernel, resulting in lower overhead compared to traditional virtual machines. This allows for higher resource utilization and enables running more containers on the same hardware, leading to better resource efficiency.</p></li><li><p><b>Rapid Deployment</b>: Docker enables rapid deployment of applications by packaging them into lightweight, portable containers. Developers can quickly build, deploy, and scale applications using Docker's streamlined workflows and tools.</p></li><li><p><b>Version Control and Rollback</b>: Docker images are version-controlled, allowing developers to track changes and roll back to previous versions if needed. This facilitates collaboration among team members and ensures reproducibility of builds across different environments.</p></li><li><p><b>Microservices Architecture</b>: Docker is well-suited for microservices architecture, where applications are decomposed into smaller, independently deployable services. Each microservice can run in its own container, making it easier to develop, deploy, and scale complex distributed systems.</p></li><li><p><b>Ecosystem and Community Support</b>: Docker has a vibrant ecosystem and a large community of users and contributors. This ecosystem includes a wide range of tools, plugins, and integrations that extend Docker's capabilities and address various use cases, making it a versatile and flexible platform for building and deploying applications.</p></li></ol><p>Overall, Docker simplifies the process of developing, shipping, and running applications, making it an indispensable tool for modern software development and deployment workflows.</p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p><span style="font-size: small;"><span face="Arial, sans-serif" style="background-color: transparent; color: #595959; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p></p><p><br /></p><p><br /></p><p><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-73639130216916248222024-02-18T10:52:00.000-08:002024-02-18T10:52:03.128-08:00[Interview] Turing DevOps Interview Questions & Solution <p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh30erQjOQcZS4WwMqvOIjq8YXaxnWxEBukgsysrpZOFsrSQlV2Gz4PAcdP_9pSZhrQtTNt7UuE_GUKjVw9RIxDp3muYZxmWSWconJYlyEOX87gwDDURymYgpuVh8eGYjEfymEPKqKgQ9kLAIJiXW4VlVpNY2ptT_EQVQbzlklgqBr8u1tBkwdgF8niwt84/s1024/devops.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="576" data-original-width="1024" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh30erQjOQcZS4WwMqvOIjq8YXaxnWxEBukgsysrpZOFsrSQlV2Gz4PAcdP_9pSZhrQtTNt7UuE_GUKjVw9RIxDp3muYZxmWSWconJYlyEOX87gwDDURymYgpuVh8eGYjEfymEPKqKgQ9kLAIJiXW4VlVpNY2ptT_EQVQbzlklgqBr8u1tBkwdgF8niwt84/w640-h360/devops.jpg" width="640" /></a></div><p></p><p><br /></p><p style="text-align: center;"><b>Turing DevOps Interview Questions & Solution </b></p><br /><font color="red"> </font><a href="https://amzn.to/48X1bHK" target="_blank"><font color="red">Download These Books to Get Turing Interview Solution </font></a><br /><p style="text-align: center;"><b> </b></p><p style="text-align: left;">Question:<br /><b>A web application running in https://mydomain.com needs to access data from https://api.myotherdomain.com but is unable to. Error message "Origin is not allowed by Access-Control-Allow- Origin".<br /></b><br />Options:<br /><br /> mydomain.com needs to explicitly grant permissions to access api.myotherdomain.com via HTTP authorization headers<br /><br /> None of the above<br /><br /> api.myotherdomain.com needs to explicitly grant permissions to mydomain.com to retrieve data via HTTP access control headers<br /><br /> mydomain.com needs to explicitly grant permissions to access api.myotherdomain.com via HTTP cors headers<br /><br /> api.myotherdomain.com needs to explicitly grant permissions to mydomain.com to retrieve data via HTTP authorization headers<br /><br />The correct answer to this question is:<br /><br />"api.myotherdomain.com needs to explicitly grant permissions to mydomain.com to retrieve data via HTTP access control headers".<br /><br /><br />Question:<br /><b>Which of the following k8s resources are not associated with any namespace?</b><br /><br />Options:<br /><br /> Services & Persistent Volumes<br /><br /> ReplicaSets & Services<br /><br /> DaemonSets & Nodes<br /><br /> All of the above<br /><br /> Persistent volumes & Nodes<br /><br />The correct answer to this question is:<br /><br />"Persistent volumes & Nodes".<br /><br /><br />Question:<br /><b>What does kubectl rollout undo deployment/app --to-revision=2 do?</b><br /><br />Options:<br /><br /> It reverts the image of the app container inside deployment to version 2.0.0<br /><br /> It reverts the image of the app container inside deployment to version 2<br /><br /> It reverts the deployment of Kubernetes version to revision 2<br /><br /> It reverts the deployment named app to the configuration in revision 2<br /><br /> None of the above<br /><br />The correct answer to this question is:<br /><br />"It reverts the deployment named app to the configuration in revision 2".<br /><br /><br />Question:<br /><b>What is the difference between Role and ClusterRole in Kubernetes?</b><br /><br />Options:<br /><br /> A role can only be used to grant access to resources within a single namespace.<br /><br /> A Role is tight to a Node, ClusterRole is working on all the Nodes.<br /><br /> A ClusterRole can be used to grant the same permissions as a Role, but because they are node-scoped.<br /><br /> None of the above.<br /><br />The correct answer to this question is:<br /><br />"A role can only be used to grant access to resources within a single namespace."<br /><br /><br /><br />Question:<br /><b>What is an NS record in DNS, for example in mydomain.com?</b><br /><br />Options:<br /><br /> It specifies the IP address for mydomain.com<br /><br /> It specifies the CNAME and the TTL for the A record<br /><br /> It specifies the DNS server that is authoritative for mydomain.com<br /><br /> None of the above<br /><br />The correct answer to this question is:<br /><br />"It specifies the DNS server that is authoritative for mydomain.com".<br /><br /><br /><br />Question:<br /><b>What is execution permissions in a directory in Linux?</b><br /><br />Options:<br /><br /> It is not used.<br /><br /> Allows user/group/others to access that directory but not list.<br /><br /> Allows user/group/others to delete files in that directory.<br /><br /> Allows user/group/others to execute files in that directory.<br /><br />The correct answer to this question is:<br /><br />"Allows user/group/others to access that directory but not list."<br /></p><p style="text-align: left;"><br /></p><p style="text-align: left;">If you want to get the all questions and answers then you can download it from this link: <a href="https://shawon10.gumroad.com/l/turing-devops-question-answers" target="_blank">https://shawon10.gumroad.com/l/turing-devops-question-answers</a></p><p style="text-align: left;"> </p><p style="text-align: left;"> <br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-14938853906117495692024-02-03T16:36:00.000-08:002024-02-04T07:54:24.613-08:00How to Deploy Application In Kubernetes (Local Environment)<p> </p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkpKHyc5jQeYU2latIp9CTiuil3l-Wi8n5p16tIFrbkte9sCqUxEmTJCxkCTs1rZ2DbEGKAF_hF1xer3-zlMofjhC69h5B-kNG8eavHg-HEeEfVp4FLQQx4orkOydNcM77PWBmxz2sGwgkf5KEoil_BJysuzWOs6XjM1Zy7lSoqNorUPYIdCwft-ZoYboN/s1280/deploy-app-kubernetes.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkpKHyc5jQeYU2latIp9CTiuil3l-Wi8n5p16tIFrbkte9sCqUxEmTJCxkCTs1rZ2DbEGKAF_hF1xer3-zlMofjhC69h5B-kNG8eavHg-HEeEfVp4FLQQx4orkOydNcM77PWBmxz2sGwgkf5KEoil_BJysuzWOs6XjM1Zy7lSoqNorUPYIdCwft-ZoYboN/w640-h360/deploy-app-kubernetes.jpg" width="640" /></a></div><p></p><p> </p><p><b>Introduction:</b></p><p>As the demand for scalable and containerized web applications grows, Kubernetes remains a popular choice for orchestrating and deploying containerized workloads. In this guide, we'll walk you through the process of deploying an Angular application on Kubernetes using NodePort, providing a straightforward method to expose your application to the external world.</p><h3>Prerequisites:</h3><p>Ensure you have the following prerequisites in place before starting the deployment process:</p><ol><li>A functioning Kubernetes cluster- <a href="https://www.shawonruet.com/2024/02/how-to-install-kubernetes-easily-in.html" target="_blank">Tutorial to Install Kubernetes Locally</a><br /></li><li>Installed kubectl command-line tool</li><li>Docker installed to containerize your Angular application.</li></ol><h3>Step 1: Clone The Repo<br /></h3><p><b>git clone https://github.com/shawon100/Angular-CRUD</b></p><p><b> </b></p><p><font color="red"> </font><a href="https://amzn.to/3SwRnxo" target="_blank"><font color="red">Download 10+ DevOps Books That You Must Read </font></a></p><p><font color="red"> </font> <br /></p><h3>Step 2: Apply the manifests file<br /></h3><p>Then Go to manifests folder </p><p>At first deploy the <b>deployment.yml </b>file </p><p> </p><div style="background-color: #1f1f1f; color: #cccccc; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #569cd6;">apiVersion</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">apps/v1</span></div><div><span style="color: #569cd6;">kind</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Deployment</span></div><div><span style="color: #569cd6;">metadata</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">webclient-angular-crud</span></div><div><span style="color: #569cd6;">spec</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">selector</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">matchLabels</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">app</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">webclient-angular-crud</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">replicas</span><span style="color: #cccccc;">: </span><span style="color: #b5cea8;">1</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">template</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">metadata</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">labels</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">app</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">webclient-angular-crud</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">spec</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">containers</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">webclient-angular-crud</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">image</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">shawon10/webclient-angular-crud:85</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">imagePullPolicy</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Always</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">ports</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">containerPort</span><span style="color: #cccccc;">: </span><span style="color: #b5cea8;">80</span></div><br /></div><p><b> </b></p><p><b>kubectl apply -f deployment.yml</b></p><p><b> </b></p><p>Then deploy the service.yml</p><div style="background-color: #1f1f1f; color: #cccccc; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #569cd6;">apiVersion</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">v1</span></div><div><span style="color: #569cd6;">kind</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Service</span></div><div><span style="color: #569cd6;">metadata</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">webclient-angular-crud-service</span></div><div><span style="color: #569cd6;">spec</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">selector</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">app</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">webclient-angular-crud</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">ports</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">protocol</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">"TCP"</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">port</span><span style="color: #cccccc;">: </span><span style="color: #b5cea8;">80</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">type</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">NodePort</span></div><br /></div><p><b> <br /></b></p><p><b>kubectl apply -f service.yml</b></p><p><b><br /></b></p><h3>Step 3: Check the Pods, Services, and Ip address</h3><div style="text-align: left;"><span style="font-weight: normal;">Check the pod</span><br /></div><div style="text-align: left;"><b>kubectl get po</b></div><div style="text-align: left;"><span style="font-weight: normal;">Check the Service </span><br /></div><div style="text-align: left;"><b>kubectl get svc</b></div><div style="text-align: left;"><span style="font-weight: normal;">Note down the NodePort</span></div><div style="text-align: left;"><span style="font-weight: normal;">Check the Ip of Node</span></div><div style="text-align: left;"><b>kubectl get nodes -o wide</b></div><h3> </h3><h3>Step 4: Access Your Angular Application:</h3><p>Once the service is created, access your Angular application using the NodePort on any of your cluster's nodes. Find the node's external IP and access the application at </p><p><code>http://<node-ip>:NodePort</code></p><p> </p><h3>Watch The Full Video</h3><h3><br /></h3><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/eH3yuKnrsZ0" width="520" youtube-src-id="eH3yuKnrsZ0"></iframe></div><br /><h3><br /></h3><p></p><p><b> <br /></b></p><p><b> </b></p><p><br /></p><p><br /></p><p> </p><p> </p><p> </p><p></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-36255497541376321932024-02-01T14:21:00.000-08:002024-02-02T08:23:33.885-08:00How to Install Kubernetes Easily in Your Local Environment<p><br /></p><p><b> </b></p><div class="separator" style="clear: both; text-align: center;"><b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZQFoFsBAaaBGa130Bndv6NXZ_6yET5hPnHaQEOgBnThJ-fTUX5dTz8rPBQIQWpzAQf57Gxop2-IHdtukEIws7ONB3PSa_TITZ5O4b4WQI3G_z-0lTEASLe6H4_MqtBzvPAnm0V5oQBHmfZS0q0eJBIHwDD-0__-poPcQCgSdpYCOg5HsZISIFj1JqtpJz/s1280/Kubernetes%20Local.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZQFoFsBAaaBGa130Bndv6NXZ_6yET5hPnHaQEOgBnThJ-fTUX5dTz8rPBQIQWpzAQf57Gxop2-IHdtukEIws7ONB3PSa_TITZ5O4b4WQI3G_z-0lTEASLe6H4_MqtBzvPAnm0V5oQBHmfZS0q0eJBIHwDD-0__-poPcQCgSdpYCOg5HsZISIFj1JqtpJz/w640-h360/Kubernetes%20Local.jpg" width="640" /></a></b></div><b><br /></b><p></p><p><b> </b></p><p><b>Introduction:</b>
Are you eager to harness the power of Kubernetes for local development? Look no further! In this comprehensive guide, we'll walk you through the process of installing Kubernetes in your local environment using Kind (Kubernetes in Docker). By the end of this tutorial, you'll have a fully functional Kubernetes cluster running smoothly on your machine.</p><h3>Why Kind?</h3><p>Kind simplifies the setup of Kubernetes clusters by leveraging Docker containers, making it an ideal choice for local development environments. It provides a lightweight and efficient way to emulate a Kubernetes cluster, ensuring a hassle-free experience for developers. <br /><br /></p><p> <a href="https://amzn.to/3SwRnxo" target="_blank"> <font color="red"> Download 10+ DevOps Books That You Must Read </font> </a><br /></p><h3>Prerequisites:</h3><p>Before diving into the installation process, make sure you have the following prerequisites in place:</p><ol><li>Linux OS<br /></li><li>Docker installed on your machine.</li><li>A terminal or command prompt for executing commands.</li></ol><h3>Step 1: Install Docker</h3><p>If you haven't installed Docker yet follow this instruction to install</p><div style="text-align: left;"><span></span><span style="font-family: courier;"><br /></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> sudo apt-get update</span></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo apt-get install docker.io</span></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo systemctl enable docker </span></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo groupadd docker</span></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sudo usermod -aG docker $USER</span></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">newgrp docker </span></span></div><div style="text-align: left;"><span style="font-family: courier; font-size: small;"><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="background-color: transparent; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker --version </span></span></div><p></p><h3>Step 2: Install Kind</h3><p>Now, let's install Kind using a package manager or by downloading the binary directly. Open your terminal and execute the following commands:</p><p>For Linux:</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><span style="font-size: medium;"><code class="!whitespace-pre hljs language-bash">curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
<span class="hljs-built_in">chmod</span> +x ./kind
sudo <span class="hljs-built_in">mv</span> ./kind /usr/local/bin/kind</code></span></div><div class="p-4 overflow-y-auto"><span style="font-size: medium;"><code class="!whitespace-pre hljs language-bash">sudo snap install kubectl --classic</code></span></div><div class="p-4 overflow-y-auto"><span style="font-size: medium;"><code class="!whitespace-pre hljs language-bash"><br /></code></span></div></div></pre><h3>Step 3: Create a Kind Cluster</h3><p>With Kind installed, creating a Kubernetes cluster is a breeze. Execute the following command:</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span style="font-size: medium;">kind create cluster --name my-local-cluster</span>
</code></div></div></pre><p>This command will download the necessary Docker images and set up a Kubernetes cluster named "my-local-cluster."</p><h3>Step 4: Verify Your Cluster</h3><p>Ensure your cluster is up and running:</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span style="font-size: medium;">kubectl get po --all-namespaces</span></code></div></div></pre><p>If you can see pod list and status then Congratulations! You've successfully installed Kubernetes locally using Kind. Now, you're ready to deploy, test, and experiment with your applications in a Kubernetes environment right on your machine.</p><p> </p><p> <a href="https://amzn.to/3SwRnxo" target="_blank"><font color="red">10+ DevOps Books That You Must Read </font> </a></p><p><br /></p><h3>Step 5: Watch Full Video</h3><h3> </h3><h3><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/HLdjdSmRj1M" width="520" youtube-src-id="HLdjdSmRj1M"></iframe></div><br /></h3><h3><br /></h3><h3>Conclusion:</h3><p>In this tutorial, we covered the seamless process of installing Kubernetes locally using Kind. This setup empowers developers to iterate and test their applications in a Kubernetes environment without the complexity of managing a full-scale cluster. Embrace the power of Kubernetes for local development and supercharge your workflow with Kind!</p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-20035718964390937802023-12-28T15:08:00.000-08:002023-12-28T19:17:31.590-08:00How to Setup a MySQL DB Cluster in Docker ( Docker DB Cluster)<p> </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkmCfXEeMA1CdIKzLzH4KBCY6s_TMW_2WkpvoWUJ1Xb_GIu2dR3oILL0E1_6WoPF1KG4lpJDtfL7NYyFkkyg_CL6t-dGPuSOmEseIoWCrhx89z4ZBIhBXY4km7peXZl8CZIcCLxsYSk71GN2akFh-Of0pDOFXeSNLirluvhGWcwKPB8bv8qXbBqXTglQ-T/s1280/Docker%20DB%20Cluster.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkmCfXEeMA1CdIKzLzH4KBCY6s_TMW_2WkpvoWUJ1Xb_GIu2dR3oILL0E1_6WoPF1KG4lpJDtfL7NYyFkkyg_CL6t-dGPuSOmEseIoWCrhx89z4ZBIhBXY4km7peXZl8CZIcCLxsYSk71GN2akFh-Of0pDOFXeSNLirluvhGWcwKPB8bv8qXbBqXTglQ-T/w640-h360/Docker%20DB%20Cluster.jpg" width="640" /></a></div><p><br /></p><p><b>Video Tutorial</b></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="366" src="https://www.youtube.com/embed/_td1yu-0iPU" width="520" youtube-src-id="_td1yu-0iPU"></iframe></div><br /><p><br /></p><p><b>Blog Tutorial</b></p><p><br /></p><p>1. At first clone the repo</p><p><b> git clone<a href=" http://github.com/shawon100/docker-mysql-db-cluster" target="_blank"> http://github.com/shawon100/docker-mysql-db-cluster</a></b></p><p>2. Then open the repo or switch to the repo folder and apply the docker compose yml</p><p><b> docker-compose up -d</b></p><p>3. Then exec into the docker container</p><p><b> docker exec -it docker-mysql-db-cluster-mysql-dev1-1 bash</b></p><p>4. Login to mysql shell<b> </b>cli</p><p><b> mysqlsh -u clusteradmin -p</b></p><p>5. Next, Check Configuration</p><p><b>dba.checkInstanceConfiguration("clusteradmin@docker-mysql-db-cluster-mysql-dev1-1:3306") </b></p><p>6. Configure the instance<b></b></p><p><b><br />dba.configureInstance("clusteradmin@docker-mysql-db-cluster-mysql-dev1-1:3306")<br />dba.configureInstance("clusteradmin@docker-mysql-db-cluster-mysql-dev2-1:3306")</b></p><p>7. Create the Cluster</p><p> <b>var cluster = dba.createCluster("dbcluster")</b></p><p>8. Check Status</p><p> <b> cluster.status()</b></p><p>9. Add the second DB Instance</p><p> <b>cluster.addInstance("clusteradmin@docker-mysql-db-cluster-mysql-dev2-1:3306") <br /></b></p><p>10. Create Database and Insert some data in the Primary Container</p><p>Exit and exec again. Then Login using mysql db cli</p><p><b>mysql -u clusteradmin -p </b></p><p>Then Create a Database <br /></p><p><b>CREATE DATABASE developer;</b></p><p><b>use developer; <br /></b></p><p>Create a Table<b></b></p><p><b><br />CREATE TABLE dev(name VARCHAR(20) NOT NULL, SLNO INT NOT NULL,<br />PRIMARY KEY(SLNO));</b></p><p><b></b></p><p><b></b></p><p><b><br />DESCRIBE dev;<br /></b></p><p>Insert Data</p><p><b><br />INSERT INTO dev VALUE("dev1",1);</b></p><p><b> </b></p><p>11. Exec into secondary container & check the data. </p><p><b>SELECT * from developer.dev</b></p><p>You can see the data that you inserted from primary container as the data will be replicated automatically. <b>That means, You have successfully created the DB Cluster in Docker!!!!</b></p><p><span> </span></p><p><b><span>Why Do You Need a DB Cluster in Docker <br /></span></b></p><div class="flex flex-grow flex-col max-w-full"><div class="min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&]:mt-5 overflow-x-auto" data-message-author-role="assistant" data-message-id="616e67d5-3471-4751-a09a-095a5fd2d7c6"><div class="markdown prose w-full break-words dark:prose-invert light"><p>Using a MySQL database cluster in a Docker environment can provide several benefits, particularly in terms of scalability, flexibility, and ease of management. Here are some of the key advantages:</p><ol><li><p><b>Scalability:</b></p><ul><li><b>Horizontal Scaling:</b> Docker makes it easy to deploy multiple instances of MySQL databases, allowing for horizontal scaling. This is crucial for handling increased workloads as your application grows.</li><li><b>Container Orchestration:</b> Container orchestration tools like Kubernetes can be used to manage and scale MySQL containers dynamically based on demand.</li></ul></li><li><p><b>Flexibility:</b></p><ul><li><b>Consistent Environment:</b> Docker containers encapsulate the application, dependencies, and configuration, ensuring a consistent environment across different stages of development, testing, and production.</li><li><b>Isolation:</b> Each MySQL instance runs in its own container, providing isolation. This isolation makes it easier to manage dependencies and avoids conflicts between different versions of MySQL or other software.</li></ul></li><li><p><b>Efficient Resource Utilization:</b></p><ul><li><b>Resource Isolation:</b> Docker containers share the host OS kernel, making them lightweight compared to virtual machines. This results in more efficient use of resources and allows running multiple MySQL instances on the same host without significant overhead.</li></ul></li><li><p><b>Easy Deployment and Rollback:</b></p><ul><li><b>Containerization:</b> Packaging MySQL as a container allows for easy deployment across various environments, reducing the likelihood of "it works on my machine" issues.</li><li><b>Rollback Capabilities:</b> Docker allows for versioning of container images, enabling straightforward rollback to a previous version if issues arise during an update.</li></ul></li><li><p><b>Rapid Development and Testing:</b></p><ul><li><b>DevOps Practices:</b> Docker facilitates DevOps practices by streamlining the development and testing process. Developers can work in a containerized environment that mirrors production, reducing the chances of discrepancies between environments.</li></ul></li><li><p><b>Isolation and Security:</b></p><ul><li><b>Isolation of Processes:</b> Containers provide process isolation, ensuring that each MySQL instance runs independently.</li><li><b>Security Updates:</b> Docker allows you to update individual containers without affecting the entire system, making it easier to apply security patches.</li></ul></li><li><p><b>High Availability and Fault Tolerance:</b></p><ul><li><b>Replication and Clustering:</b> MySQL clusters can be set up using Docker Compose or Kubernetes, providing high availability and fault tolerance.</li><li><b>Automated Failover:</b> Tools like Orchestrator or ProxySQL, when combined with Docker and container orchestration, can automate failover processes in the event of a node failure.</li></ul></li><li><p><b>Infrastructure as Code (IaC):</b></p><ul><li><b>Declarative Configuration:</b> Docker Compose or Kubernetes configurations can be used to declare the desired state of the MySQL cluster. This aligns with Infrastructure as Code principles, making infrastructure configurations version-controlled and reproducible.</li></ul></li><li><p><b>Reduced Development Time:</b></p><ul><li><b>Quick Setup for Developers:</b> Developers can quickly set up a MySQL cluster locally using Docker containers, reducing the time needed for environment configuration.</li></ul></li><li><p><b>Cost-Effective:</b></p><ul><li><b>Resource Efficiency:</b> Docker's efficient resource utilization allows for running multiple containers on the same host, potentially reducing infrastructure costs.</li></ul></li></ol><p>While using MySQL clusters in Docker brings numerous benefits, it's essential to carefully plan the deployment, consider data persistence, and implement appropriate backup and recovery strategies to ensure the reliability and availability of your database systems.</p></div></div></div><p><span> </span><br /></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkmCfXEeMA1CdIKzLzH4KBCY6s_TMW_2WkpvoWUJ1Xb_GIu2dR3oILL0E1_6WoPF1KG4lpJDtfL7NYyFkkyg_CL6t-dGPuSOmEseIoWCrhx89z4ZBIhBXY4km7peXZl8CZIcCLxsYSk71GN2akFh-Of0pDOFXeSNLirluvhGWcwKPB8bv8qXbBqXTglQ-T/s1280/Docker%20DB%20Cluster.jpg" style="margin-left: 1em; margin-right: 1em;"><br /></a></div><br />Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-46707666213890904662023-11-17T08:50:00.000-08:002024-01-03T08:46:10.301-08:00Covergo Senior Cloud Engineer Interview Test Solution<p> </p><p> </p><p style="text-align: left;"><b> Covergo Senior Cloud Engineer Interview Test Solution<br /></b></p><p style="text-align: left;"><br />Notes:<br />Please use Kind to create a local Kubernetes cluster<br />https://kind.sigs.k8s.io/<br />Add Makefile with commands (can be extended if required):<br />make up - creates Kubernetes cluster;<br />make deploy - deploy all required manifests, uploads images and etc;<br />make down - destroy Kubernetes cluster and all resources.<br />Expected Output:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwOeP5nuCEj5WK3Og6K3nDaipl2vBKRIuSptEHH74aAUoTAfkl7P4UbKdkT_tjn-Am9zZvuURiZWQPBUAYkVgSu0bJtlf0kayoTkJFm9HZ6hE1m97rz1OpDM3aNtIc6LLYlGD45e14O550VCS9KzQUwpEjjMq8pQIv_m4Z0YbGRdwe4Qrhes2QAp9Vxsy4/s810/covergo.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="455" data-original-width="810" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwOeP5nuCEj5WK3Og6K3nDaipl2vBKRIuSptEHH74aAUoTAfkl7P4UbKdkT_tjn-Am9zZvuURiZWQPBUAYkVgSu0bJtlf0kayoTkJFm9HZ6hE1m97rz1OpDM3aNtIc6LLYlGD45e14O550VCS9KzQUwpEjjMq8pQIv_m4Z0YbGRdwe4Qrhes2QAp9Vxsy4/w640-h360/covergo.png" width="640" /></a></div><p></p><p><br /><b>Scenario 1: Create a multi-node Kubernetes cluster with Terraform.</b></p><p><br />Create TF scripts for deploying a multi-node Kind cluster<br />Name: new<br />Kind provider: https://github.com/tehcyx/terraform-provider-kind<br />Nodes: 1 control plane and 2 worker node<br />Deploy the Kind cluster with Terraform.</p><p><br /><b>Scenario 2: Create custom helm charts and deploy them to the Kubernetes cluster.</b></p><p><br />Task 1:<br />Create an HTTP application that shows the current time<br />name: app1<br />listen: 0.0.0.0:8282<br />Inject environment variable with configmap:<br />variable: APP_NAME = CoverGo<br />variable: APP_VERSION = 1.0.1<br />Bundle application to the Docker image.<br />Upload the image to the Kubernetes cluster with the kind load command.<br />Create a custom helm chart that deploys 2 replicas of the application app1.<br />Schedule replica deployment on different worker nodes.</p><p><br />Task 2:<br />Create another HTTP application based on the Nginx image.<br />name: nginx1<br />listen: 0.0.0.0:8282<br />Attach persistent volume:<br />size: 1Mb<br />mount path: /data<br />Create a custom helm chart that deploys 1 replica of the application nginx1.</p><p><br /><b>Scenario 3: Test the network isolation and policy enforcement features of Kind.</b><br /><br /></p><ul style="text-align: left;"><li>Define network policies in a Kubernetes manifest to restrict network traffic between app1 and nginx1:</li><li>Deploy the manifest to the Kind cluster and ensure that it is possible to reach app1 from nginx1, but the opposite (from app1 to ng</li><li>inx1).</li><li>Verify that pods can communicate only with themselves based on the defined network policies.</li><li>from nginx1: curl http://app1:8282 <= works</li><li>from app1: curl http://nginx1:8282 <= forbidden</li></ul><p><b>Scenario 4: Design a multi-stage deployment pipeline</b></p><p><br />Propose a solution for the app1 multi-stage release pipeline with assumptions:<br />Cloud provider: AWS, CGP, Azure (select one)<br />Environments: Dev => Prod<br />Repository: Github<br />Distribution: helm chart<br />Draw a principal diagram and add the required description. </p><p><br /></p><p><b>Solution: </b></p><p>Solution Link: <a href="https://shawon10.gumroad.com/l/covergo-solution" target="_blank">https://shawon10.gumroad.com/l/covergo-solution</a><br /></p><p><b style="color: #38761d;">Book 1:1 Mentorship session to get the solution with some trainings<br /></b></p><p><b><span style="color: #38761d;">Solution Mentorship Link: </span></b><a href="https://topmate.io/ashadullah_shawon/431597 " target="_blank">https://topmate.io/ashadullah_shawon/431597 </a></p><p><b> </b><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-54524010295032975202023-11-17T08:42:00.000-08:002024-01-03T08:51:09.256-08:00Brainstation23 DevOps Interview Task Solution<p> </p><p><b> Brainstation23 DevOps Engineering Project Challenge</b></p><p><b> </b><br /><b>Task 1</b><br />Create a full project with code, deployment yaml and jenkinsfile in a github/gitlab/bitbucket<br />repository.</p><p>Source should be php laravel latest code. You will take that code and make 2 dockerfile to<br />create 2 docker image that displays following static html pages,</p><p>App 1 browser output: Hello I am App 1<br />App 2 browser output: Hello I am App 2</p><p>Host these docker images in your dockerhub account publicly. Create separate kubernetes<br />deployment, configmap, service yaml files. Service should be nodeport.<br />Include a nginx deployment that will serve app1 or app2 based on api address. Use nginx<br />official image and mount configmap to change configuration.<br />http://nodeip:nodeport/app1 displays app1<br />http://nodeip:nodeport/app2 displays app2<br />Deploy these applications in a lightweight kubernetes distribution of your choice. Kind, minikube,<br />k3s, k0s. Cluster should be 1 master and 2 nodes. Force app1 in node1 and app2 in node2 with<br />node labels or taints/tolerations, nginx can stay anywhere. Use configmaps for any environment<br />variables.</p><p>Create a docker compose file that runs a jenkins container. Create 2 jenkinsfile that builds and<br />deploys these 2 applications into your choice of lightweight cluster in your local machine.<br />Your solution should include step by step instruction to setup lightweight kubernetes distribution,<br />Your solution should include how to setup 2 jenkins pipelines that use jenkinsfile from your<br />public repository.</p><p>Your solution should include how to customize kubernetes deployment files to use docker<br />images built by the jenkins pipeline<br />Prepare readme in such way that anyone can start jenkins container using docker compose,<br />create 2 pipelines with your instructions, download your code using jenkinsfile from your public<br />repo, build code and push to their dockerhub account (show the way to input credentials to push<br />to dockerhub but DO NOT provide any of your credentials anywhere) and use those docker<br />images with kubernetes yaml files to deploy app1 and app2 into the lightweight cluster. You can<br />provide separate instructions to deploy nginx and update its config to point to app1 and app2.<br />Please keep in mind common anti-patterns, security concerns and suggest how your solution<br />can be scaled up in future. BONUS point for anyone that can successfully integrate any service<br />mesh to handle api traffic routing from kubernetes end.</p><p>Your folder structure should look like the following, src for source codes, build for dockerfile and<br />related settings, deploy for kubernetes yaml files.<br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0w4QXC7RBovG1sVXrXwfEMv8Si26sIHs3LERlhMS05PcU1ibQycH9RJUruw7VJlXoZBfboJ9nEERsPB5dCIflRdDWplY-6NkDkT8cpc_jHnQVrpFjsRzhi9RsVUNrLLVwxQeLDodouQoksQ7DyEoIVjP822n_ey4lb5O8P2tMoZuJszliOKUHDq29MCGU/s665/bs23-interview.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="521" data-original-width="665" height="502" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0w4QXC7RBovG1sVXrXwfEMv8Si26sIHs3LERlhMS05PcU1ibQycH9RJUruw7VJlXoZBfboJ9nEERsPB5dCIflRdDWplY-6NkDkT8cpc_jHnQVrpFjsRzhi9RsVUNrLLVwxQeLDodouQoksQ7DyEoIVjP822n_ey4lb5O8P2tMoZuJszliOKUHDq29MCGU/w640-h502/bs23-interview.png" width="640" /></a></div><p><b>Solution: </b></p><p>This is a devops task that contains laravel app with jenkins CI/CD,
Kubernetes Deployments with Nginx,Jenkins Docker container setup with
docker compose amd Lightweight cluster setup</p><p> </p><p>Solution Link: <a href="https://shawon10.gumroad.com/l/bs23-solution" target="_blank">https://shawon10.gumroad.com/l/bs23-solution</a> <br /></p><p><b style="color: #38761d;">Book 1:1 Mentorship session to get the solution with some trainings</b></p><p><b><span style="color: #38761d;">Solution Mentorship Link</span></b><b><span style="color: #38761d;">: </span></b><a href="https://topmate.io/ashadullah_shawon/431597 " target="_blank">https://topmate.io/ashadullah_shawon/431597 </a></p><p> </p><p> <br /></p><p> </p><p> <br /></p><p> </p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-61636350727562137442023-08-18T09:58:00.004-07:002023-08-18T09:58:21.924-07:00 DocX to HTML Convert & Auto Data Analysis Using ChatGPT Code Interpreter <p><br /></p><p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2w2eEpBbA69Lm4kfOYeGOsvqQA_qMuM4Bnv27SRznD9KkbWy_pIe4ZIhVl9zplUeaKnR22V1wzeTkLewtPHBYI51diQLCX-rSZ4Xw0ElF0t22x-ViQV_qo3kgLFGpZmuyciVhcBSW2W2oHY9vL-Xg8er6iWH4FAFA-8OfgrZknOa32vS3dFYSDD5yT6k_/s1280/power-of-chatgpt.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2w2eEpBbA69Lm4kfOYeGOsvqQA_qMuM4Bnv27SRznD9KkbWy_pIe4ZIhVl9zplUeaKnR22V1wzeTkLewtPHBYI51diQLCX-rSZ4Xw0ElF0t22x-ViQV_qo3kgLFGpZmuyciVhcBSW2W2oHY9vL-Xg8er6iWH4FAFA-8OfgrZknOa32vS3dFYSDD5yT6k_/w640-h360/power-of-chatgpt.jpg" width="640" /></a></div><br /><p></p><p> </p><p> <b>Watch This Video</b><br /></p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/mQ_-HmakkdQ" width="520" youtube-src-id="mQ_-HmakkdQ"></iframe></div><p></p><p><br /></p><p><br /></p><h1>Unleashing the Power of ChatGPT: Data Analysis and Document Conversion</h1><h2>Introduction</h2><p>In today’s data-driven world, efficient data analysis and seamless document conversion are more important than ever. In this blog, we will explore how ChatGPT can be a game-changer in these domains. We will delve into two exciting use cases: performing data analysis using a code interpreter and converting DOCX files to HTML format using ChatGPT.</p><h2>Part 1: Data Analysis with a Code Interpreter</h2><h3>The Basics</h3><p>Imagine having the power of a full-fledged data analysis environment, like a Jupyter Notebook, integrated into a conversational agent. That’s what ChatGPT with a code interpreter brings to the table. You can run Python code, create visualizations, analyze data, and more - all while having a natural conversation with the model.</p><h3>How It Works</h3><ol><li><p><strong>Ask a Question or Define a Task</strong>: Start by asking ChatGPT what you want to analyze. It could be as simple as "Can you plot the sales data for the last year?" or "Please analyze the trends in this dataset."</p></li><li><p><strong>Send Your Data</strong>: If your data is in a file (like a CSV or Excel), you can upload it directly to the conversation. ChatGPT will take it from there.</p></li><li><p><strong>Run the Code</strong>: ChatGPT will write and execute Python code in real-time, showing you the outputs, visualizations, and insights directly within the chat.</p></li><li><p><strong>Iterate</strong>: Need to dive deeper? Just ask follow-up questions or request further analysis based on the results. It’s a dynamic, interactive process.</p></li></ol><h3>Example Use Case</h3><p>Let's say you have sales data and want to forecast future sales. You can upload your data file, and ChatGPT can perform time-series analysis, plot the past sales data, build a forecast model, and visualize the predictions, all while explaining each step of the process to you.</p><h2>Part 2: DOCX to HTML Conversion with ChatGPT</h2><h3>The Need for Conversion</h3><p>DOCX is a popular format for word processing documents, but sometimes we need our content in a more web-friendly format, like HTML. This is where ChatGPT comes into play.</p><h3>How It Works</h3><ol><li><p><strong>Upload Your DOCX File</strong>: Start by uploading your DOCX file to ChatGPT.</p></li><li><p><strong>Request Conversion</strong>: Simply ask ChatGPT to convert the file to HTML. For example: "Can you convert this DOCX file to HTML?"</p></li><li><p><strong>Receive Your HTML File</strong>: ChatGPT will process the file, convert it to HTML, and provide a link for you to download the converted file.</p></li><li><p><strong>Customize If Needed</strong>: Need specific styling or additional elements like buttons or forms in the HTML? Just ask, and ChatGPT can further customize the HTML for you.</p></li></ol><h3>Example Use Case</h3><p>Imagine you’ve written a report in Word, and now you need to publish it as a blog post on your website. Instead of manually copying and pasting the content and reformatting it, you can use ChatGPT to convert the DOCX file into a clean, ready-to-use HTML file.</p><h2>Conclusion</h2><p>ChatGPT is not just a text generation model; it’s a versatile tool that can handle a variety of tasks. From data analysis in a conversational manner to seamless document conversion, ChatGPT is showcasing the future of AI-powered productivity.</p><p></p><p><br /></p><p><br /></p><p></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-84411493906816959762023-08-01T19:57:00.004-07:002023-08-02T05:39:31.680-07:00How to Develop CI/CD pipelines & Deploy Application as a Docker Container to AWS EC2 ECR<p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja9cOU3zvd_xmhbjFqAuW6hOYnsyVF2IpI8jtxZ0dW0hrakev1dsCx47QMOwAPGVJ-fbw3rfPkGuVPy8PE5L6wzs5u9KVxht0HX3PNZOgrPYtEqbqGZtyuSHt7xzSSSNUif7OAEPv97_yDQWKGT7rfvGVgDPbQUPpbCVbRp_gjPdafHdr9gYLvFRSL32t9/s1280/docker+aws+cicdl.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja9cOU3zvd_xmhbjFqAuW6hOYnsyVF2IpI8jtxZ0dW0hrakev1dsCx47QMOwAPGVJ-fbw3rfPkGuVPy8PE5L6wzs5u9KVxht0HX3PNZOgrPYtEqbqGZtyuSHt7xzSSSNUif7OAEPv97_yDQWKGT7rfvGVgDPbQUPpbCVbRp_gjPdafHdr9gYLvFRSL32t9/w640-h360/docker+aws+cicdl.jpg" width="640" /></a></div><p><br /></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="366" src="https://www.youtube.com/embed/MQPRpDBXRyA" width="520" youtube-src-id="MQPRpDBXRyA"></iframe></div><p> </p><p>Repository: <a href="https://github.com/shawon100/aws-ec2-docker-python-ci-cd" target="_blank">https://github.com/shawon100/aws-ec2-docker-python-ci-cd</a><br /></p><p>Install docker and docker compose on your ec2 machine<br /></p><div style="background-color: #1f1f1f; color: #cccccc; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #cccccc;">For Ubuntu:</span></div><br /><div><span style="color: #cccccc;">sudo apt-get update</span></div><div><span style="color: #cccccc;">sudo apt-get install docker.io</span></div><div><span style="color: #cccccc;">sudo systemctl enable docker </span></div><div><span style="color: #cccccc;">sudo groupadd docker</span></div><div><span style="color: #cccccc;">sudo usermod -aG docker $USER</span></div><div><span style="color: #cccccc;">newgrp docker </span></div></div><p><br />Docker Compose:<br />sudo
curl -L
https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname
-s)-$(uname -m) -o /usr/local/bin/docker-compose<br /><br />sudo chmod +x /usr/local/bin/docker-compose<br /><br />docker-compose version<br /><br />Configure ecr access on ec2 machine<br /><br />aws
ecr get-login-password --region us-east-2 | docker login --username AWS
--password-stdin your-ecr-registry-url<br /></p><p>If you have still access problem, attach ecr iam role with your ec2 [ Showed in the Video]<br /></p><p></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-85699050603610018582023-07-28T19:24:00.003-07:002023-07-28T19:24:58.488-07:00[Interview] Kubernetes Quiz Solution of Turing <p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoUsX38O4ohi2VpF-pMIIG-AXRQrqsOl9QFLPyAQ4ZLsLkIShxdxzfV8qJ3FuhGil1c0-aR_RSBxthvvl1Y8uRVXRNk36B51vRspSwFA9GZcjHFbm_LLVAwjcNW09d546aZi4ismBIraGLs94Z3fV41BGjgAVPYSNO8fOKAVtg3PQkaWdeGM7zQEgeUBcn/s560/Kubernetes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="496" data-original-width="560" height="566" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoUsX38O4ohi2VpF-pMIIG-AXRQrqsOl9QFLPyAQ4ZLsLkIShxdxzfV8qJ3FuhGil1c0-aR_RSBxthvvl1Y8uRVXRNk36B51vRspSwFA9GZcjHFbm_LLVAwjcNW09d546aZi4ismBIraGLs94Z3fV41BGjgAVPYSNO8fOKAVtg3PQkaWdeGM7zQEgeUBcn/w640-h566/Kubernetes.png" width="640" /></a></div><p></p><p><br /></p><p><b>Solution of Turing Kubernetes Quiz </b><br /></p><p>You are a DevOps at Turing. You want to open up a proxy port on localhost for Kubernetes cluster. Which of the following is correct command to do it?<br /><br />1. Kubect! localhost<br />2. Kubect! proxy<br />3. Kubect! proxy create<br />4. Kubect! create<br /><br />The correct command to set up a proxy to the Kubernetes API server on your local machine is kubectl proxy. So, the correct answer is option 2: Kubect! proxy<br /><br /><br />You are a DevOps at Turing. You want to look at an object's details. Which of the following subcommands of ‘kubect!' do you need to use in this case?<br /><br />1. Details<br />2. Describe<br />3. Check<br />4. Info<br /><br />The correct command to get detailed information about a specific object in Kubernetes using kubectl is kubectl describe. So, the correct answer is option 2: Describe<br /><br />You are a DevOps at Turing. You take care a microservice system on AWS. You need to config Service Discovery in the system. How can you do it?<br /><br />1. None of the above<br />2. Via environment variables for the socket of the service.<br />3. All of the above<br />4. Via kube-proxy<br />5. Via DNS.<br /><br />Kubernetes provides two primary modes of service discovery, environment variables and DNS. The kube-proxy component also plays a part in service discovery by load balancing across different pods of a service. So, the correct answer is option 3: All of the above.<br /><br /><br />You are a DevOps at Turing. You need to logically group a set of Pods. Which Services supports this case?<br /><br />1. Pod names<br />2. Labels and Selectors<br />3. IP Address attached to Pods<br />4. Current state<br /><br />The correct answer is option 2: Labels and Selectors. Labels are key/value pairs that are attached to objects, such as pods, and Selectors are how you specify which Labels to match when grouping objects.<br /><br />You are a DevOps at Turing. You need to config customer to work with a cloud provider. What does the Service Type work only in this case?<br /><br />1. NodePort<br />2. ClusterIP<br />3. LoadBalancer<br />4. ExternalName<br /><br />In the context of working with a cloud provider in Kubernetes, the Service Type that is specifically designed to work with cloud providers is LoadBalancer. This service type provisions a load balancer for your application in supported cloud providers (like AWS, GCP, Azure, etc.). So, the correct answer is option 3: LoadBalancer.<br /><br /><br />You are a DevOps at Turing. Which of the following statement is correct about the target of this command<br /><br />“kubect1 explain pod.metadata --recursive”<br /><br />1. Explains what metadata is for a pod<br />2. Give a brief overview of a pod<br />3. Explains how to uses a pod in detail, with examples<br />4. Lists all options available in a podas metadata<br /><br />The kubectl explain command is used to get documentation about different Kubernetes resources and their fields. When you use kubectl explain pod.metadata --recursive, it will recursively explain all the fields under pod.metadata.<br /><br />So, the correct answer is option 4: Lists all options available in a pod's metadata<br /><br /><br />You are a DevOps at Turing. You need to manage the assigning nodes to pods depending on resource availability. Which component do you use in this case?<br /><br />1. Flanneld<br />2. ETCD<br />3. Scheduler<br />4. Kubect!<br /><br />The correct answer is option 3: Scheduler. The Kubernetes Scheduler is responsible for scheduling pods onto nodes. It selects a suitable node for each pod based on resource availability, among other factors<br /><br />You are a DevOps at Turing. You are using The Ingress controller to create a Load Balancer. Which is the layer that it's based on?<br /><br />1. Layer 4<br />2. Layer 3<br />3. None of the above<br />4. Layer 7<br /><br />The Ingress controller in Kubernetes is used for handling HTTP and HTTPS routing to services within the cluster. This corresponds to Layer 7 (the application layer) in the OSI model. So, the correct answer is option 4: Layer 7.<br /><br /><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-58915549229404398002023-07-27T09:50:00.008-07:002023-07-27T12:13:16.947-07:00Docker Crash Course: Zero to Hero [50% off]<p><br /></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGWk7rSKkbOdl9heXe7SvBRnTjCbSwa1RYDFYKov9s7-9UByjaaLujhMtX86vhAGy8AP5Myui8D-8wFEMTpnGo-gz95I9edcUPsSLsuNQKtTI3snsL67_czqS6pAdfarB_4zR8XiH5zf0uQ-BeZHSgB6RSvyz2Tpmv4v2WlIWX0ScnU8QyBdqmX-G_y1Yy/s1280/stripe-docker-course.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGWk7rSKkbOdl9heXe7SvBRnTjCbSwa1RYDFYKov9s7-9UByjaaLujhMtX86vhAGy8AP5Myui8D-8wFEMTpnGo-gz95I9edcUPsSLsuNQKtTI3snsL67_czqS6pAdfarB_4zR8XiH5zf0uQ-BeZHSgB6RSvyz2Tpmv4v2WlIWX0ScnU8QyBdqmX-G_y1Yy/w640-h360/stripe-docker-course.jpg" width="640" /></a></div><p></p><div class="flex flex-grow flex-col gap-3"><div class="min-h-[20px] flex items-start overflow-x-auto whitespace-pre-wrap break-words flex-col gap-4"><div class="markdown prose w-full break-words dark:prose-invert light"><p>🔥🔥 <b>SUMMER COURSE OFFER! </b>🔥🔥</p><p>Dive into the world of containerization with our "Docker Crash Course: Zero to Hero" and grab the phenomenal 50% DISCOUNT while you can!</p><p>🚀 In no time, you'll master Docker, the groundbreaking tool that has revolutionized software development and deployment.</p><p>Imagine this... you start with ZERO knowledge, you're deploying applications with ease, getting live support from mentor, getting a taste of the efficiency and flexibility that Docker provides. Sounds like a superpower, right? It can be yours!</p><p>👉<b> What you'll get from this course:</b></p><p>1️⃣ Step-by-step guide on Docker basics: from installation to creating your first container.</p><p>2️⃣ Deep-dive into Dockerfile: Create your custom images and kickstart your projects.</p><p>3️⃣ Master Docker Compose: Effortlessly orchestrate multi-container applications.</p><p>4️⃣ Best practices for Docker deployment: Take your apps from your local machine to production with CI/CD Pipelines<br /></p><p>5️⃣ Real-world examples: See Docker in action, enhancing your learning experience.</p><p>💼 Get the skills that top tech companies are scouting for and open a universe of opportunities!</p><p>💥 Don't forget, this offer won't last forever. Grab your seat, take a leap towards a brighter tech future, and SAVE 50%!</p><p>📢 <b>ENROLL NOW! : <a href="http://bit.ly/docker-course-enroll" target="_blank">http://bit.ly/docker-course-enroll</a></b> </p><p>
</p>
<center>
<script async="" src="https://js.stripe.com/v3/buy-button.js">
</script>
<stripe-buy-button buy-button-id="buy_btn_1NYJYkExfOGRVtNaO0I17UB4" publishable-key="pk_live_51MzGEkExfOGRVtNaz0RkXY7Qf6nGvzMj2CCQxFRw1kHbgy3TBHQbyXqfXe2FIDnswFbHsx2fRkKzqdsaGQR9vPZ100R1TPZHa0">
</stripe-buy-button>
</center>
<b>Course Duration</b> : 1Month (Weekly 2 hours)<p></p><p>Let's embark on this journey, from Zero to Docker Hero!</p><p>Let your Docker journey be our mission! See you in class! 🎓</p></div></div></div><p> </p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-20955030301419281672023-07-26T19:48:00.001-07:002023-07-26T19:48:43.020-07:00Docker Best Practices & Recommendations <p><br /></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsFP4Gg_bsjjWKW8WW3M4I3ZkZmdh-bLAnidUbavsTJ-LV4AHlsGrizEvOmsECkmkyy2S07Q3IGsOhofN0bk5JWKtmOQxfhVj36W9srEBAvuej8yF3c2veKO84SP0bMTgw3Miad5FCcwJNwKwMhgPdv4gMN1_nzVuCDuW4ufY5f3yI0AsnOL2ZVbJjVtpD/s1186/best-practices-docker.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="665" data-original-width="1186" height="358" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsFP4Gg_bsjjWKW8WW3M4I3ZkZmdh-bLAnidUbavsTJ-LV4AHlsGrizEvOmsECkmkyy2S07Q3IGsOhofN0bk5JWKtmOQxfhVj36W9srEBAvuej8yF3c2veKO84SP0bMTgw3Miad5FCcwJNwKwMhgPdv4gMN1_nzVuCDuW4ufY5f3yI0AsnOL2ZVbJjVtpD/w640-h358/best-practices-docker.jpg" width="640" /></a></div><br /><p></p><p><br /></p><p><span class="x193iq5w xeuugli x13faqbe x1vvkbs x10flsy6 x1lliihq x1s928wv xhkezso x1gmr53x x1cpjm7i x1fgarty x1943h6x x4zkp8e x41vudc x6prxxf xvq8zen xo1l8bm xzsf02u x1yc453h" dir="auto"></span></p><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;">When working with Docker and writing Dockerfiles, there are several best practices you can follow to ensure efficient, maintainable, and secure containerization. Here are some recommendations:</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Use <span></span>a minimal base image:</b> Start your Dockerfile with a minimal base image such as Alpine Linux or Debian Slim. This reduces the attack surface and keeps the image size small.</div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;">Leverage layer caching: Docker uses layer caching to speed up the build process. Place frequently changing instructions at the end of your Dockerfile to maximize the utilization of cache for earlier build stages.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Reduce the number of layers:</b> Each instruction in a Dockerfile creates a new layer. Minimize the number of layers by combining related instructions using multi-line syntax. This reduces the final image size and improves build time.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Specify the version for base images:</b> Pin the version of the base image to ensure consistency and avoid unexpected changes. For example, instead of using "ubuntu," specify the version, like "ubuntu:20.04."</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Use .dockerignore: </b>Create a .dockerignore file to exclude unnecessary files and directories from being copied into the Docker context. This reduces build time and avoids adding unnecessary content to the image.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Copy only necessary files: </b>Be specific when copying files into the container. Use wildcards or explicitly list required files instead of copying entire directories. This helps reduce the image size and prevents unnecessary content from being included.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Run only one process per container:</b> Containers are designed to run a single process or service. Avoid running multiple processes in a single container as it can lead to complexity and makes it harder to manage and scale.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Remove unnecessary dependencies and files: </b>Clean up unnecessary packages, dependencies, and temporary files within the Dockerfile. This helps reduce the image size and minimizes potential security vulnerabilities.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Use environment variables for configuration:</b> Utilize environment variables instead of hardcoding configuration values in your Dockerfile. This allows for greater flexibility and easier configuration management when deploying containers.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;"><b>Avoid running containers as root: </b>Set a non-root user to run your application inside the container. Running containers as root can increase the attack surface and potential impact of security vulnerabilities.</div><div dir="auto" style="text-align: start;"> </div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto" style="text-align: start;">These best practices help ensure your Dockerfiles and Docker usage adhere to industry standards, improve build performance, enhance security, and facilitate easier maintenance and troubleshooting.</div><div dir="auto" style="text-align: start;"> </div><div dir="auto" style="text-align: start;">#docker</div><div dir="auto" style="text-align: start;">#best-practices <br /></div></div> <br /><p></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-50482169491417955002023-07-06T00:15:00.003-07:002023-07-06T00:15:18.976-07:00 Ansible Lineinfile Module Kodekloud<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCeIhrQKmOz4KRB9nVM9AP8KH90XrB7KENt0yj9WPf-Grx60qxSnPBUgE_IS50SRcQmUShxlS11Uxlst2K9AoPyQlIraJnRIIB1bIXSFXbHrt1Z50HUMeFfaoJmweELKlhpmnaVVmtg1GQsFOPQd8BnYA0tV2mFZ_rjpJx4VD8_eiykZlrulDEvHklHb9Z/s1280/kodekloud-solution.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCeIhrQKmOz4KRB9nVM9AP8KH90XrB7KENt0yj9WPf-Grx60qxSnPBUgE_IS50SRcQmUShxlS11Uxlst2K9AoPyQlIraJnRIIB1bIXSFXbHrt1Z50HUMeFfaoJmweELKlhpmnaVVmtg1GQsFOPQd8BnYA0tV2mFZ_rjpJx4VD8_eiykZlrulDEvHklHb9Z/w640-h360/kodekloud-solution.jpg" width="640" /></a></div><p></p><p><br /></p><p><b>Question: </b></p><p>The Nautilus DevOps team want to install and set up a simple httpd web server on all app servers in Stratos DC. They also want to deploy a sample web page using Ansible. Therefore, write the required playbook to complete this task as per details mentioned below.<br /><br />We already have an inventory file under /home/thor/ansible directory on jump host. Write a playbook playbook.yml under /home/thor/ansible directory on jump host itself. Using the playbook perform below given tasks:<br /><br /> Install httpd web server on all app servers, and make sure its service is up and running.<br /><br /> Create a file /var/www/html/index.html with content:<br /><br />This is a Nautilus sample file, created using Ansible!<br /><br /> Using lineinfile Ansible module add some more content in /var/www/html/index.html file. Below is the content:<br /><br />Welcome to xFusionCorp Industries!<br /><br />Also make sure this new line is added at the top of the file.<br /><br /> The /var/www/html/index.html file's user and group owner should be apache on all app servers.<br /><br /> The /var/www/html/index.html file's permissions should be 0655 on all app servers.<br /><br />Note: Validation will try to run the playbook using command ansible-playbook -i inventory playbook.yml so please make sure the playbook works this way without passing any extra arguments.</p><p><br /></p><p><b>Solution:</b></p><p>Go to the right folder</p><p><b>cd /home/thor/ansible</b></p><p>Create a playbook</p><p><b>vi playbook.yml</b></p><div style="background-color: #1f1f1f; color: #cccccc; font-family: 'Droid Sans Mono', 'monospace', monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #cccccc;">- </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Install httpd and setup index.html</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">hosts</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">stapp01, stapp02, stapp03</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">become</span><span style="color: #cccccc;">: </span><span style="color: #569cd6;">yes</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">tasks</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Install httpd</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">package</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">httpd</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">state</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">present</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Start service httpd, if not started</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">service</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">httpd</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">state</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">started</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Add content in index.html. Create file if it does not exist and set file attributes</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">copy</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">dest</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">/var/www/html/index.html</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">content</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">This is a Nautilus sample file, created using Ansible!</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">mode</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">"0655"</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">owner</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">apache</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">group</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">apache</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Update content in index.html</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">lineinfile</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">path</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">/var/www/html/index.html</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">insertbefore</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">BOF</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">line</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Welcome to xFusionCorp Industries!</span></div><br /></div><p><b> </b>Run the playbook</p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;"><b style="background: 0px 0px; border: 0px none; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-size: medium;"><span style="font-size: medium;"><b>ansible-playbook -i inventory playbook.yml</b></span></span></b></span></span></span></p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;"><b style="background: 0px 0px; border: 0px none; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-size: medium;"><span style="font-size: medium;"></span></span></b>Finally, check all the appservers</span></span></span></p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;">http://stapp01</span></span></span></p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;">http://stapp02</span></span></span></p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;">http://stapp03</span></span></span></p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;"><br /></span></span></span></p><p><span style="font-family: arial;"><span style="background: 0px 0px; border: 0px; font-family: arial; outline: 0px; padding: 0px; vertical-align: baseline;"><span face="Arial, Tahoma, Helvetica, FreeSans, sans-serif" style="background: transparent 0px 0px; border: 0px none; outline: 0px; padding: 0px; text-align: justify; vertical-align: baseline;"><br /></span></span></span></p><p><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-84173275591312442182023-06-30T16:20:00.006-07:002023-06-30T19:58:11.614-07:00Build & Run Java Spring Boot App with Tomcat Server in Docker<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPoBcHKhIgsKEZFAynUoVbxylNaaCZ-WDiY3IDfjOqyqPV89xHVRgH50erv3il6JejESTooWhX3eztDPt6VZJXtum9klflNfZgpp0xeQUd5rj_edrzDyPvnVtKh2_Agc0ritM6QHaFbt7K3612Bw0QRy67Z1JlUrUKrP_WlHigxfeb8Nkl4g_iUMvw2wkh/s1280/docker%20+%20java%20spring%20boot.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPoBcHKhIgsKEZFAynUoVbxylNaaCZ-WDiY3IDfjOqyqPV89xHVRgH50erv3il6JejESTooWhX3eztDPt6VZJXtum9klflNfZgpp0xeQUd5rj_edrzDyPvnVtKh2_Agc0ritM6QHaFbt7K3612Bw0QRy67Z1JlUrUKrP_WlHigxfeb8Nkl4g_iUMvw2wkh/w640-h360/docker%20+%20java%20spring%20boot.jpg" width="640" /></a></div><p></p><p><br /></p><p>1. At first clone this repo </p><p> git clone <a href="https://github.com/shawon100/Spring-Boot-Maven-Tomcat-Docker">https://github.com/shawon100/Spring-Boot-Maven-Tomcat-Docker</a></p><p>2. Go to the repository folder and Run this command</p><p> docker build -t springimage .</p><p>3. Finally Run this application</p><p> docker run -d -p 8080:8080 --name springapp springimage</p><p>4. Access in your browser: http://localhost:8080/sample/index?name=Shawon<br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-56541773900113653242023-06-29T08:54:00.001-07:002023-06-29T09:58:44.709-07:0010 Kubernetes Best Practices to Follow for your DevOps Architecture<p> </p><p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeO2nnr0MWzWxQWJP_SE_6d0v_rId2XxVV17ld6mXIN_g18qVyn57uz6Rj3Em3yTiCWoOFmnZcWej3GAOEwdn4ImmFaH89-2aRqKSa1GgodR7_m0D0FcO_gARf2HD_hfEBlNBdytCutXIokVm1cFE79MOMtwqKIEfHYhYNNY2h-odgtVjUQcREmrwl5_7W/s1188/kubernetes-best-practice.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="667" data-original-width="1188" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeO2nnr0MWzWxQWJP_SE_6d0v_rId2XxVV17ld6mXIN_g18qVyn57uz6Rj3Em3yTiCWoOFmnZcWej3GAOEwdn4ImmFaH89-2aRqKSa1GgodR7_m0D0FcO_gARf2HD_hfEBlNBdytCutXIokVm1cFE79MOMtwqKIEfHYhYNNY2h-odgtVjUQcREmrwl5_7W/w640-h360/kubernetes-best-practice.png" width="640" /></a></div><br /><p></p><p><span class="break-words"><span dir="ltr">10 best practices to follow when working with Kubernetes:<br /><br /><b>Use
Namespace</b>: Utilize Kubernetes namespaces to logically partition your
cluster resources. This allows for better organization, access control,
and resource management.<br /><br /><b>Deployments for Application Management</b>:
Use Deployments instead of directly managing individual Pods.
Deployments provide features like rolling updates, scaling, and
rollback, making application management easier and more robust.<br /><br /><b>Resource
Limits and Requests</b>: Set resource limits and requests for your Pods to
ensure efficient resource allocation and prevent resource contention
within the cluster. This helps optimize performance and maintain
stability.<br /><br /><b>Health Probes</b>: Implement readiness and liveness probes
to monitor the health of your applications. Probes ensure that only
healthy Pods receive traffic and help Kubernetes manage container
lifecycle effectively.</span></span></p><p><span class="break-words"><span dir="ltr"><br /><b>Horizontal Pod Autoscaling (HPA)</b>: Configure
Horizontal Pod Autoscaling to automatically scale the number of Pods
based on CPU or custom metrics. This dynamic scaling ensures that your
application can handle varying loads efficiently.<br /><br /><b>Secrets
Management</b>: Use Kubernetes Secrets to store sensitive information such
as passwords, API keys, and certificates. This ensures secure access to
confidential data and helps prevent accidental exposure.<br /><b><br />ConfigMaps
for Configuration</b>: Store application configurations in ConfigMaps,
enabling easy management and modification without redeploying the entire
application. This decouples configuration from the application code,
improving flexibility and maintainability.<br /><br /><b>RBAC for Access
Control</b>: Implement Role-Based Access Control (RBAC) to define
fine-grained access control policies within your cluster. RBAC enables
secure management of cluster resources and ensures that only authorized
users have appropriate permissions.<br /><br /><b>Monitoring and Logging</b>: Set
up robust monitoring and logging solutions to gain insights into the
health, performance, and behavior of your Kubernetes cluster and
applications. Tools like Prometheus, Grafana, and Elasticsearch help you
proactively identify issues and troubleshoot effectively.<br /><b><br />Regular
Updates and Maintenance</b>: Keep your Kubernetes cluster and its
components up to date with the latest versions and security patches.
Regularly perform cluster maintenance tasks such as cleaning up unused
resources, updating configurations, and reviewing resource allocation.<br /><br />Remember,
these best practices serve as general guidelines, and it's important to
adapt them to your specific use case and requirements. Always stay
updated with the latest Kubernetes documentation and seek expert advice
when needed to ensure optimal usage of Kubernetes in your environment.</span></span> <br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-51493356398511027772023-06-26T19:17:00.002-07:002023-06-26T19:17:12.167-07:00Kubernetes Time Check Pod Kodekloud<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidWN7pxczfdG9ZkG4Lq8lvmQYQ_Nf0-uGdT-wnnrLgDsiAGGWWSOX5U2Tw6b_TDZNSIXue4HsUTx3pRicGi3WHWAvRq5XUyMkoAUN0qUYgMyIY374Pkx-62Wb-wXdMhw_fBqiLPKKduAEb-hDSp2z7sqypbUZbabLXq8LH_i7nmQZN-VOPRwK0KkoxcF5G/s1280/kodekloud-solution.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidWN7pxczfdG9ZkG4Lq8lvmQYQ_Nf0-uGdT-wnnrLgDsiAGGWWSOX5U2Tw6b_TDZNSIXue4HsUTx3pRicGi3WHWAvRq5XUyMkoAUN0qUYgMyIY374Pkx-62Wb-wXdMhw_fBqiLPKKduAEb-hDSp2z7sqypbUZbabLXq8LH_i7nmQZN-VOPRwK0KkoxcF5G/w640-h360/kodekloud-solution.jpg" width="640" /></a></div><p><br /></p><p><b>Question:</b></p><p>The Nautilus DevOps team want to create a time check pod in a particular Kubernetes namespace and record the logs. This might be initially used only for testing purposes, but later can be implemented in an existing cluster. Please find more details below about the task and perform it.<br /><br /> Create a pod called time-check in the devops namespace. This pod should run a container called time-check, container should use the busybox image with latest tag only and remember to mention tag i.e busybox:latest.<br /><br /> Create a config map called time-config with the data TIME_FREQ=7 in the same namespace.<br /><br /> The time-check container should run the command: while true; do date; sleep $TIME_FREQ;done and should write the result to the location /opt/data/time/time-check.log. Remember you will also need to add an environmental variable TIME_FREQ in the container, which should pick value from the config map TIME_FREQ key.<br /><br /> Create a volume log-volume and mount the same on /opt/data/time within the container.<br /><br />Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.<br /><br /><br /><b>Solution:</b></p><p>At first create the namespace</p><p><b>kubectl create ns devops</b></p><p>Then create a yml file</p><p><b>vi time-check-pod.yml</b> and paste this. Check the mount path time frequence according to question<br /></p><div style="background-color: #1f1f1f; color: #cccccc; font-family: 'Droid Sans Mono', 'monospace', monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #569cd6;">apiVersion</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">v1</span></div><div><span style="color: #569cd6;">kind</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">ConfigMap</span></div><div><span style="color: #569cd6;">metadata</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">time-config</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">namespace</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">devops</span></div><div><span style="color: #569cd6;">data</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">TIME_FREQ</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">"7"</span></div><div><span style="color: #cccccc;">---</span></div><div><span style="color: #569cd6;">apiVersion</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">v1</span></div><div><span style="color: #569cd6;">kind</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">Pod</span></div><div><span style="color: #569cd6;">metadata</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">time-check</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">namespace</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">devops</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">labels</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">app</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">time-check</span></div><div><span style="color: #569cd6;">spec</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">volumes</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">log-volume</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">emptyDir</span><span style="color: #cccccc;">: {}</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">containers</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">time-check</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">image</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">busybox:latest</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">volumeMounts</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">mountPath</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">/opt/data/time</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">log-volume</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">envFrom</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> - </span><span style="color: #569cd6;">configMapRef</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">name</span><span style="color: #cccccc;">: </span><span style="color: #ce9178;">time-config</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">command</span><span style="color: #cccccc;">: [</span><span style="color: #ce9178;">"/bin/sh"</span><span style="color: #cccccc;">, </span><span style="color: #ce9178;">"-c"</span><span style="color: #cccccc;">]</span></div><div><span style="color: #cccccc;"> </span><span style="color: #569cd6;">args</span><span style="color: #cccccc;">:</span></div><div><span style="color: #cccccc;"> [</span></div><div><span style="color: #cccccc;"> </span><span style="color: #ce9178;">"while true; do date; sleep $TIME_FREQ;done > /opt/data/time/time-check.log"</span><span style="color: #cccccc;">,</span></div><div><span style="color: #cccccc;"> ]</span></div><br /></div><p></p><p><br /></p><p>Finally apply the yml</p><p><b>kubectl apply -f time-check-pod.yml</b></p><p>Check the pod</p><p><b>kubectl get po -n devops<br /></b></p><p><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com1tag:blogger.com,1999:blog-3532188705097941107.post-45962325939969109242023-06-24T22:50:00.012-07:002023-08-06T18:35:52.921-07:00Build and Run PHP+MySQL Application in Docker<p style="text-align: left;"> </p><p style="text-align: left;"> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpr_VWmVi_9BTwpSEySM4Dgjc1nAmhgBM_mZriAXMUEXsWisegtSStRiRPA9iULKaIh9OufOuBSFJrhdwj4MCL_TFGrSs9sZCvVgFik48qldTmC0puXt1g3Tie75Qu7RHIBxyRg1OYNyO7DRmrQTNPEux0zxwLciim2tpsJOxAiXglQxAlKtF4Jxu1N96O/s1280/docker-php-mysql.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpr_VWmVi_9BTwpSEySM4Dgjc1nAmhgBM_mZriAXMUEXsWisegtSStRiRPA9iULKaIh9OufOuBSFJrhdwj4MCL_TFGrSs9sZCvVgFik48qldTmC0puXt1g3Tie75Qu7RHIBxyRg1OYNyO7DRmrQTNPEux0zxwLciim2tpsJOxAiXglQxAlKtF4Jxu1N96O/w640-h360/docker-php-mysql.jpg" width="640" /></a></div><p></p><p><br /></p><p><b> Method 1 (For Better Understanding):</b><br /></p><p></p><p style="text-align: left;"><b> Create a Common Network for PHP & MySQL container</b></p><ol style="text-align: left;"><li><b> </b><span style="font-size: small; white-space: pre;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker network create chatbot</span></span></li></ol><p style="text-align: left;"><b> PHP Container</b><br /></p><ol style="text-align: left;"><li> <span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">At first clone this repo </span><a href="https://github.com/shawon100/RUET-ChatBot" style="text-decoration: none;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #009668; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">https://github.com/shawon100/RUET-ChatBot</span></a></span></li><li role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Then go to the folder. Change the host name from localhost to <b>db</b> and add password <b>1test2</b> in <b>config.php</b></span></span></li><li><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Build the image</span><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></li><li><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> docker build -t chatbotimage </span></span></li><li><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Finally Run the Image</span></span></li><li><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker run -d -p 5400:80 --name chatbotapp --network chatbot chatbotimage</span></span></li></ol><p style="text-align: left;"><b> MySQL Container</b></p><p style="text-align: left;"> Pull mysql image and then Run<br /></p><ol id="docs-internal-guid-92a81ca0-7fff-d8cd-81ea-9f37495e765d" style="margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px; text-align: left;"><li aria-level="1" style="background-color: transparent; color: #695d46; font-family: "Open Sans", sans-serif; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;"><p role="presentation" style="line-height: 1.38; margin-bottom: 12pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker pull mysql:latest</span></span></p></li><li aria-level="1" style="background-color: transparent; color: #695d46; font-family: "Open Sans", sans-serif; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;"><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker run -d -p 3306:3306 --name db --network chatbot -e MYSQL_ROOT_PASSWORD=1test2 -e MYSQL_DATABASE=chat mysql</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Exec into mysql container</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><b><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">docker exec -it db bash</span></b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Login to mysql and database</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><b><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">mysql -u root -p</span></b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><b>use chat;</b></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"> </span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;">Run the chat.sql from the database folder to Insert the data</span><br /></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Go to http://localhost:5400 </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">If you want to become a master in Docker for handling production grade workloads you can enroll in this course. </span></span></p>
<center>
<script async="" src="https://js.stripe.com/v3/buy-button.js">
</script>
<stripe-buy-button buy-button-id="buy_btn_1NYJYkExfOGRVtNaO0I17UB4" publishable-key="pk_live_51MzGEkExfOGRVtNaz0RkXY7Qf6nGvzMj2CCQxFRw1kHbgy3TBHQbyXqfXe2FIDnswFbHsx2fRkKzqdsaGQR9vPZ100R1TPZHa0">
</stripe-buy-button>
</center><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><a href="https://www.amazon.ca/Docker-Shipping-Reliable-Containers-Production/dp/1098131827?crid=1VRMX9NXSZFPK&keywords=Docker&qid=1687672111&s=books&sprefix=docker%2Cstripbooks%2C105&sr=1-3&linkCode=li3&tag=shawonruet-20&linkId=9912811f59e96af17327574d91cf36e9&language=en_CA&ref_=as_li_ss_il" target="_blank"></a><br /><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><b><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Method 2 (Using Docker Compose): </span></span></b></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><ol><li> <span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">At first clone this repo </span><a href="https://github.com/shawon100/RUET-ChatBot" style="text-decoration: none;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #009668; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">https://github.com/shawon100/RUET-ChatBot</span></a></span></li><li role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Then go to the folder. Change the host name from localhost to <b>db</b> and add password <b>1test2</b> in <b>config.php</b></span></span></li><li role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Then run the docker<b>-</b>compose.yml using this command<b>: </b></span></span></li><li role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>docker-compose up -d </b></span></span></li></ol><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p></li><li aria-level="1" style="background-color: transparent; color: #695d46; font-family: "Open Sans", sans-serif; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline; white-space: pre;"><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> Video Tutorial</span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span></span></p><p role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/yznbWBEeuqI" width="520" youtube-src-id="yznbWBEeuqI"></iframe></span></span></div><span style="font-size: small;"><span face=""Open Sans", sans-serif" style="background-color: transparent; color: #695d46; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /> </span></span><p></p></li></ol>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com2tag:blogger.com,1999:blog-3532188705097941107.post-87938946158959003322023-06-15T16:59:00.000-07:002023-06-15T16:59:03.784-07:00DevOps Architecture: Enable Rate Limiting to restrict unwanted and frequent Incoming requests from Frontend<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghoWQrUe2_SkxGIWQB--L-715RhP6Ov1_fXSb14wQxnJuPf2pACzBT6cnnYQVVT2O3f0o-s6OYmZQwmzEGdfyNlubLpT8cOC2M_PU6NTFIVnCei7-pth-G43L0e9-rUcSDSDGWwwgtp5FxXkp8lokzM3JTewbDn8Zknuz74kO5k0b4nnlKnpD9e3NiQQ/s612/devops.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="344" data-original-width="612" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghoWQrUe2_SkxGIWQB--L-715RhP6Ov1_fXSb14wQxnJuPf2pACzBT6cnnYQVVT2O3f0o-s6OYmZQwmzEGdfyNlubLpT8cOC2M_PU6NTFIVnCei7-pth-G43L0e9-rUcSDSDGWwwgtp5FxXkp8lokzM3JTewbDn8Zknuz74kO5k0b4nnlKnpD9e3NiQQ/w640-h360/devops.jpg" width="640" /></a></div><p></p><p><br /></p><div class="flex flex-grow flex-col gap-3"><div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap break-words"><div class="markdown prose w-full break-words dark:prose-invert light"><p>An API gateway is a server that acts as an intermediary between a client application and a collection of backend services. Its primary function is to manage, secure, and optimize API (Application Programming Interface) calls. The API gateway acts as a single entry point for clients to access various backend services, providing a unified interface and hiding the complexity of the underlying architecture.</p><p>The importance of an API gateway lies in its ability to provide several key benefits:</p><ol><li><p>Aggregation and Composition: An API gateway allows clients to access multiple backend services through a single API call. It can aggregate data from multiple sources and compose responses to fulfill the client's request. This reduces network overhead and improves performance by minimizing the number of requests required.</p></li><li><p>Security and Authentication: API gateways serve as a security layer, protecting the backend services from unauthorized access. They can enforce authentication and authorization mechanisms, such as API keys, OAuth, or JSON Web Tokens (JWT). By centralizing security measures, the API gateway simplifies the implementation of security policies and ensures consistent protection across multiple services.</p></li><li><p>Rate Limiting and Throttling: API gateways play a crucial role in managing the rate of incoming requests. They can apply rate limiting policies to restrict the number of requests a client can make within a specific time period. Rate limiting helps prevent overloading and protects backend services from abusive or excessive usage, ensuring fair resource allocation and maintaining system stability.</p></li><li><p>Request Transformation and Response Formatting: An API gateway can perform request and response transformations, allowing clients to communicate using a standardized API format. It can convert requests from one format to another, such as JSON to XML or vice versa. This enables backend services to remain agnostic of specific client requirements and promotes interoperability.</p></li><li><p>Monitoring and Analytics: API gateways often include logging and monitoring capabilities, providing insights into API usage, performance metrics, and error tracking. By gathering and analyzing data, organizations can identify patterns, detect anomalies, and optimize their APIs for better efficiency and user experience.</p></li></ol><p>Regarding rate limiting, an API gateway can implement various strategies to prevent an unwanted number of requests. It can enforce limits based on the number of requests per minute, hour, or day, or it can set quotas on the number of requests a specific client or API key can make. When a client exceeds the rate limit, the API gateway can respond with an error or apply throttling, temporarily slowing down the client's requests until they fall within the allowed limit.</p><p>Regarding trust issues with the frontend, an API gateway acts as a boundary between the frontend and the backend services. This separation helps protect the backend from potential security vulnerabilities in the frontend application. By enforcing security measures at the gateway, such as authentication, authorization, and input validation, it mitigates the risk of unauthorized access or malicious requests. The API gateway also shields the backend services from direct exposure to the internet, reducing the attack surface and enhancing overall security posture.</p></div></div></div><p></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-89748994075854944582023-06-03T11:44:00.002-07:002023-06-03T11:44:19.698-07:00Avoid 5 things if you are using Kubernetes in Production<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibW56YyCyEJhnx1nnTbj0_JnZ8AYHty00iqgyf_Z7BUaxa3Ejd_c3bBURyYi2FzMzKUtw4Q43X-3lxpCvzptjAF3UGCJf7ENVN2d34cJUk-w2sJdIyVesjUcI3wfm3Dn0sip_a-i3K0tzYuxnXXMOC4pqQ4uW2V4gGgZQupWx5_eRNz5srqsS8qhfmjw/s1200/kubernetes.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="630" data-original-width="1200" height="336" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibW56YyCyEJhnx1nnTbj0_JnZ8AYHty00iqgyf_Z7BUaxa3Ejd_c3bBURyYi2FzMzKUtw4Q43X-3lxpCvzptjAF3UGCJf7ENVN2d34cJUk-w2sJdIyVesjUcI3wfm3Dn0sip_a-i3K0tzYuxnXXMOC4pqQ4uW2V4gGgZQupWx5_eRNz5srqsS8qhfmjw/w640-h336/kubernetes.jpeg" width="640" /></a></div><p></p><p><span class="break-words"><span><span dir="ltr"><br /><br /><b>Failing
to ensure production grade infrastructure & fault tolerance:</b> If
you are creating kubernetes cluster for production then make sure that
you are selecting production grade virtual machine nodes . If you are
using dev/test grade virtual machine nodes in production then you are in
trouble! If you are using nfs server for storing your logs of
microservices then make sure that the nfs server is also production
grade. It will be a best practice to use dynamic premium storage class
based persistent volumes instead of nfs server. Enable minimum and
maximum nodes according to your predicted production loads while
creating the kubernetes cluster. Finally, make sure that your kubernetes
cluster is available in multiple availability zones.<br /><br /><b>Neglecting
Resource Management and AutoScaling:</b> Kubernetes manages resources such
as CPU, memory, and storage for your application containers. Neglecting
resource management can lead to performance problems or even application
failures. Make sure to properly define resource requests and limits for
your containers to ensure efficient resource allocation and prevent
resource contention. It's also recommended to enable Horizontal pod
Autoscaler and Vertical Pod Autoscaler for your microservices. <br /><br /><b>Skipping
Liveness and Readiness Probes: </b>Liveness and readiness probes are
essential for maintaining application health and availability in
Kubernetes. Skipping or misconfiguring these probes can result in
situations where unhealthy or unready containers are still considered
operational, leading to poor user experience and potential service
disruptions. Always define and configure liveness and readiness probes
appropriately for your application.<br /><br /><b>Failing to Monitor and Debug:
</b> Kubernetes provides various monitoring and logging mechanisms that can
help you understand the behavior of your applications and the cluster
itself. Failing to implement proper monitoring and debugging practices
can make it challenging to identify and resolve issues when they occur.
Establish a robust monitoring and logging strategy from the beginning to
aid troubleshooting and performance optimization.<br /><br /><b>Faulty
Configuration in Internal or External Reverse Proxy and Loadbalancer:
</b>Misconfiguration and Failing to implement accurate ingress rules,
backend configuration, listeners, healthprobes, backend pool, settings
etc. can make the situation worse and can take you to the
troubleshooting maze. <br /><br />By avoiding these common mistakes and
following best practices, you can navigate Kubernetes more effectively
and prevent yourself from falling into Kubernetes hell. </span></span></span></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-59571726173658371972023-05-31T01:56:00.002-07:002024-02-01T15:33:30.472-08:00How to Install or Setup Elasticsearch, Filebeat, Logstash, and Kibana (ELK Stack) in Kubernetes Cluster<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMJIwhloRp7FOHDtZOMIJn8jGFEfzfvDQ0Yg0qpaxh51jyKBs0KpGUUgbSn8JnZnYuYyr_uAZAXgGFNO2ULxgLHk7j2XpCbPUfL0QXjprF00N_la6fYMLx2keSKWkpPzoswuGU8weJepCpCjgPxjHdvCc_WYWzxKdCrLtslxDcUGxyEziXkj6v_ppO5Q/s1093/elk.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="625" data-original-width="1093" height="366" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMJIwhloRp7FOHDtZOMIJn8jGFEfzfvDQ0Yg0qpaxh51jyKBs0KpGUUgbSn8JnZnYuYyr_uAZAXgGFNO2ULxgLHk7j2XpCbPUfL0QXjprF00N_la6fYMLx2keSKWkpPzoswuGU8weJepCpCjgPxjHdvCc_WYWzxKdCrLtslxDcUGxyEziXkj6v_ppO5Q/w640-h366/elk.png" width="640" /></a></div><p> </p><h1 dir="auto" tabindex="-1">Installation <br /></h1>
<ol dir="auto"><li>Clone the repository<br /></li></ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code> </code>git clone https://github.com/shawon100/elasticsearch-logstash-kibana-kubernetes <code>
</code></pre></div>
<ol dir="auto" start="2"><li>Then add the helm repo</li></ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code> <b> helm repo add elastic https://helm.elastic.co
</b></code></pre></div>
<ol dir="auto" start="3"><li>Go to elasticsearch folder. Then Create and Apply the persistent volumes for elastic search.</li></ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> kubectl apply –f pv.yaml</b>
</code></pre></div>
<p dir="auto"> Install elasticsearch using helm values<br /></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> helm install elasticsearch elastic/elasticsearch --version="7.17.3" -f values.yaml</b>
</code></pre></div>
<ol dir="auto" start="4"><li>Go to filebeat folder. Create and Apply the persistent volumes for filebeat.</li></ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> kubectl apply –f pv.yaml</b>
</code></pre></div>
<p dir="auto"> Install filebeat using helm values<br /></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> helm install filebeat elastic/filebeat --version="7.17.3" -f values.yaml</b>
</code></pre></div>
<ol dir="auto" start="5"><li>Go to kibana folder, Install kibana using helm.</li></ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> helm install kibana --version="7.17.3" elastic/kibana</b>
</code></pre></div>
<p dir="auto"> Then change the host name according to your host name in ingress file and apply ingress</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> kubectl apply –f .</b>
</code></pre></div>
<ol dir="auto" start="6"><li>Go to logstash folder and apply the yamls</li></ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto"><pre class="notranslate"><code><b> kubectl apply –f .</b>
</code></pre></div>
<ol dir="auto" start="7"><li>Check the pods and If all pods are in the Running status then go to your kibana host address to access the ELK</li></ol><p> </p><p><span style="font-size: large;"><br /><font color="red"> </font><a href="https://www.amazon.com/b?_encoding=UTF8&tag=cloudageskill-20&linkCode=ur2&linkId=d9a062e038ba9f7621bf0788f0a9f3d9&camp=1789&creative=9325&node=5" target="_blank"><font color="red">Download ELK PLG Stack Installation Books</font></a></span></p><p><span style="font-size: large;"><font color="red"> </font> <br /><b>Video Tutorial </b></span></p><p><span style="font-size: large;"><b> </b></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-size: large;"><b><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/0TZCNv45cuU" width="520" youtube-src-id="0TZCNv45cuU"></iframe></b></span></div><span style="font-size: large;"><b><br /></b></span><p></p><p><span style="font-size: large;"><b> </b></span><br /></p><p> </p><p><br /></p><p><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-25701603555189214402023-05-23T09:00:00.000-07:002023-05-23T09:00:06.826-07:00How to Setup Grafana and Prometheus monitoring tool in Kubernetes<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6tICGkYc-2NB2JvP5hNYxnHExMWSZ6tfXzNMzCMUbEBbOJyU3MuxQjorgMKh_Gm-SH6fOEc-Ii6mmDPFSEqvI1Q1Z68ucl0MfuVjfOzK-c0kh3QXtCFPr5F1gIzU9NLds9noY3CO2sOdd2EgbBG4vRzwV-FbeGXStPOg-AypkieP8fGXIpiYakPWNng/s1757/grafana-prometheus.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="834" data-original-width="1757" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6tICGkYc-2NB2JvP5hNYxnHExMWSZ6tfXzNMzCMUbEBbOJyU3MuxQjorgMKh_Gm-SH6fOEc-Ii6mmDPFSEqvI1Q1Z68ucl0MfuVjfOzK-c0kh3QXtCFPr5F1gIzU9NLds9noY3CO2sOdd2EgbBG4vRzwV-FbeGXStPOg-AypkieP8fGXIpiYakPWNng/w640-h304/grafana-prometheus.jpg" width="640" /></a></div><p></p><p><br /></p><p>1. At first clone this repo: <a href="https://github.com/shawon100/kubernetes-grafana-prometheus" target="_blank">https://github.com/shawon100/kubernetes-grafana-prometheus</a></p><p><b>git clone https://github.com/shawon100/kubernetes-grafana-prometheus</b></p><p>2. Then create a namespace named monitoring</p><p><b>kubectl create ns monitoring</b></p><p>3. Next, create the persistent volumes and claims so that data will not be erased after pod restarting</p><p><b>kubectl apply -f prometheus-pv.yml</b></p><p><b>kubectl apply -f prometheus-pvc.yml</b></p><p><b>kubectl apply -f grafana-pv.yml</b></p><p><b>kubectl apply -f grafana-pvc.yml</b></p><p>4. Finally apply the grafana-prometheus.yaml</p><p><b>kubectl apply -f grafana-prometheus.yaml</b></p><p>5. Setup the ingress to access the grafana</p><p><b>kubectl apply -f grafana-ingress.yml<br /></b></p><p><br /></p><p><br /></p><p><br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-32020794144289512672023-05-01T21:03:00.007-07:002023-05-01T21:04:42.346-07:00Simple Example of Java program about Lock Contention and Solution to Fix <p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7kZs79zZS2d0hY6euQ5bmb970BzCGtCycPEVc0V0FBHqKS86g1oESg6joNRTQLpr0RGsEzsa8eZ9-7PL0hTP2u2IVEUSrq5Pp8BmVnDvv1XEvEENU7N71Cca17HkwEQyRp74Stxxjy_TF8mLuHbX32-bm7MUqlU5lJkRwiR8ewSFirJW3CAFEVaKYVw/s300/Java.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="300" data-original-width="300" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7kZs79zZS2d0hY6euQ5bmb970BzCGtCycPEVc0V0FBHqKS86g1oESg6joNRTQLpr0RGsEzsa8eZ9-7PL0hTP2u2IVEUSrq5Pp8BmVnDvv1XEvEENU7N71Cca17HkwEQyRp74Stxxjy_TF8mLuHbX32-bm7MUqlU5lJkRwiR8ewSFirJW3CAFEVaKYVw/s1600/Java.jpg" width="300" /></a></div><p></p><p><br /></p><p>Lock Contention Program</p><p><span style="color: #990000;">class Table {<br /> <br /> void printTable(int n)<br /> {<br /> for (int i=0; i<10; i++)<br /> {<br /> System.out.println(n*i);<br /> <br /> try <br /> {<br /> Thread.sleep(2000);<br /> }<br /> catch(Exception e)<br /> {<br /> System.out.println(e);<br /> }<br /> }<br /> }<br />}<br /><br />class MyThread1 extends Thread {<br /> Table table;<br /> public MyThread1(Table table)<br /> {<br /> this.table = table;<br /> }<br /> <br /> @Override<br /> public void run()<br /> {<br /> table.printTable(5);<br /> }<br /> <br />}<br /><br />class MyThread2 extends Thread {<br /> Table table;<br /> public MyThread2(Table table)<br /> {<br /> this.table = table;<br /> }<br /> <br /> @Override<br /> public void run()<br /> {<br /> table.printTable(10);<br /> }<br /> <br />}<br /><br />public class Test {<br /> public static void main(String[] args) {<br /> <br /> Table obj = new Table();<br /> MyThread1 t1 = new MyThread1(obj);<br /> MyThread2 t2 = new MyThread2(obj);<br /> t1.start();<br /> t2.start();<br /> }<br /> }</span></p><p>The problem with this code is that both threads are accessing the shared <code>Table</code> object at the same time, and thus may be interfering with each other's output. One possible solution is to use synchronization to ensure that only one thread can access the <code>printTable</code> method at a time. Here's an example of how to modify the code to use synchronization</p><p><span style="color: #38761d;">class Table {<br /> <br /> synchronized void printTable(int n)<br /> {<br /> for (int i=0; i<10; i++)<br /> {<br /> System.out.println(n*i);<br /> <br /> try <br /> {<br /> Thread.sleep(2000);<br /> }<br /> catch(Exception e)<br /> {<br /> System.out.println(e);<br /> }<br /> }<br /> }<br />}<br /><br />class MyThread1 extends Thread {<br /> Table table;<br /> public MyThread1(Table table)<br /> {<br /> this.table = table;<br /> }<br /> <br /> @Override<br /> public void run()<br /> {<br /> table.printTable(5);<br /> }<br /> <br />}<br /><br />class MyThread2 extends Thread {<br /> Table table;<br /> public MyThread2(Table table)<br /> {<br /> this.table = table;<br /> }<br /> <br /> @Override<br /> public void run()<br /> {<br /> table.printTable(10);<br /> }<br /> <br />}<br /><br />public class Test {<br /> public static void main(String[] args) {<br /> <br /> Table obj = new Table();<br /> MyThread1 t1 = new MyThread1(obj);<br /> MyThread2 t2 = new MyThread2(obj);<br /> t1.start();<br /> t2.start();<br /> }<br />}</span><br /> </p><p>In this modified code, the <code>printTable</code> method is declared with the <code>synchronized</code>
keyword, which means that only one thread can execute it at a time.
This ensures that the output of the multiplication tables will not be
interleaved or otherwise interfered with. <br /></p><p><span style="color: #990000;"> </span><br /> <br /> <br /></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com0tag:blogger.com,1999:blog-3532188705097941107.post-71308426546248065282023-03-31T22:12:00.003-07:002023-03-31T22:22:26.770-07:00How to Install and Use K8sGPT tool to analyze Kubernetes POD and Service Error<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIqGRAzxw0jinB0StUL0ZNPFzSjJ54IYTlmQ7OArr7rGUA1ZVqQEMjCvFkZ1uIaQQTjICW-EBfX_CFTqLlz_2G5pXqmQARmMxMAZ5N4j6A8_Dz0gaoaSTngiqVT031S8nFpZTm-_nNPbalsOGZaUJ4aMVZsjow690MqP7xDjgz8TlJLZGGjG6zg0tPmA/s1200/kubernetes.jpeg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="630" data-original-width="1200" height="336" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIqGRAzxw0jinB0StUL0ZNPFzSjJ54IYTlmQ7OArr7rGUA1ZVqQEMjCvFkZ1uIaQQTjICW-EBfX_CFTqLlz_2G5pXqmQARmMxMAZ5N4j6A8_Dz0gaoaSTngiqVT031S8nFpZTm-_nNPbalsOGZaUJ4aMVZsjow690MqP7xDjgz8TlJLZGGjG6zg0tPmA/w640-h336/kubernetes.jpeg" width="640" /></a></div><p></p><p dir="auto">K8sGPT is a tool for scanning your kubernetes clusters, diagnosing and triaging issues in simple english.</p>
<p dir="auto">It has SRE experience codified into it's analyzers and helps to pull out the most relevent information to enrich it with AI.</p><p dir="auto"> <b>Installation</b></p><p dir="auto">At first get the binaries<b> <br /></b></p><p dir="auto"><b> </b><b>wget https://github.com/k8sgpt-ai/k8sgpt/releases/download/v0.1.6/k8sgpt_Linux_x86_64.tar.gz</b></p><p dir="auto">Then create and copy api key from your openai account <b><br /></b></p><p dir="auto"><b> ./k8sgpt generate </b></p><p dir="auto"><b>./k8sgpt auth</b></p><p dir="auto">Paste the api key</p><h2 dir="auto" tabindex="-1">Analyzers</h2>
<p dir="auto">K8sGPT uses analyzers to triage and diagnose issues in your cluster. It has a set of analyzers that are built in, but
you will be able to write your own analyzers.</p><h3 dir="auto" tabindex="-1">Built in analyzers</h3>
<ul class="contains-task-list"><li class="task-list-item"><input checked="checked" class="task-list-item-checkbox" disabled="disabled" id="" type="checkbox" /> podAnalyzer</li><li class="task-list-item"><input checked="checked" class="task-list-item-checkbox" disabled="disabled" id="" type="checkbox" /> pvcAnalyzer</li><li class="task-list-item"><input checked="checked" class="task-list-item-checkbox" disabled="disabled" id="" type="checkbox" /> rsAnalyzer</li><li class="task-list-item"><input checked="checked" class="task-list-item-checkbox" disabled="disabled" id="" type="checkbox" /> serviceAnalyzer</li><li class="task-list-item"><input checked="checked" class="task-list-item-checkbox" disabled="disabled" id="" type="checkbox" /> eventAnalyzer</li><li class="task-list-item"><input checked="checked" class="task-list-item-checkbox" disabled="disabled" id="" type="checkbox" /> ingressAnalyzer</li></ul><p dir="auto"> <b>Example</b></p><p dir="auto"><b>./k8sgpt analyze --explain --filter=Pod </b></p><p dir="auto">If you want to show it using json output</p><p dir="auto"><b>./k8sgpt analyze -o json --explain --filter=Pod | jq .</b></p><p dir="auto"><b> </b></p><div class="separator" style="clear: both; text-align: center;"><b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI6xLf_6RSwTfe3Ui4dNfZeqw_qozgTD62Dk9V-_XGXjjObG-Xzs5_SD6J_iwPohL0DbldCrMEX2ilAn4AJAOOfc8fyZrrkm9iiXD0gnswviUvcPe9v0KBUXTM-pWU9pbsTtsNktJCYHKD2hXWcuEADZhpBDZHXc5I4x4krlJUWmMyIMFZNyj_Jx2aIg/s1020/k8sgpt.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="627" data-original-width="1020" height="394" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI6xLf_6RSwTfe3Ui4dNfZeqw_qozgTD62Dk9V-_XGXjjObG-Xzs5_SD6J_iwPohL0DbldCrMEX2ilAn4AJAOOfc8fyZrrkm9iiXD0gnswviUvcPe9v0KBUXTM-pWU9pbsTtsNktJCYHKD2hXWcuEADZhpBDZHXc5I4x4krlJUWmMyIMFZNyj_Jx2aIg/w640-h394/k8sgpt.gif" width="640" /></a></b></div><b><br /></b><p></p><p dir="auto"><b> </b><br /></p><p dir="auto"></p><p dir="auto"><br /></p><p></p>Ashadullah Shawonhttp://www.blogger.com/profile/06735213332908381404noreply@blogger.com1