<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cloudify DevOps]]></title><description><![CDATA[Cloudify DevOps]]></description><link>https://cloudifydevops.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1675360416682/XBxM4RE2s.png</url><title>Cloudify DevOps</title><link>https://cloudifydevops.com</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 02 Mar 2024 06:52:09 GMT</lastBuildDate><atom:link href="https://cloudifydevops.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><atom:link rel="next" href="https://cloudifydevops.com/rss.xml?page=1"/><item><title><![CDATA[GitHub Authentication Failed Error from Command Line]]></title><description><![CDATA[<p>After setting up my local and remote Git repositories, I couldn't able to push to my remote GitHub repository from the command line. I was getting the following error:</p><pre><code class="lang-bash">$ git push origin mainUsername <span class="hljs-keyword">for</span> <span class="hljs-string">'https://github.com'</span>: usernamePassword <span class="hljs-keyword">for</span> <span class="hljs-string">'https://username@github.com'</span>: passwordfatal: Authentication failed <span class="hljs-keyword">for</span> <span class="hljs-string">'https://github.com/username/my-repository.git/'</span></code></pre><p>Finally, I solved this issue but I wanted to share this with others so it might be helpful.</p><h3 id="heading-authenticate-on-github">Authenticate on Github</h3><p>To solve this issue, we need to set up a personal access token (PAT) for authentication. First, we need to go to the GitHub settings, and from there we need to scroll down and click on Developer settings.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680952574797/c09afdc7-031a-4069-9093-6518a0a88a0b.png" alt class="image--center mx-auto" /></p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680952037427/742dfb76-6bd1-4c2d-87db-4b98f5676e09.png" alt class="image--center mx-auto" /></p><p>After that, we need to click on Personal access tokens and from the drop-down, select Tokens (classic).</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680951998296/f5ddf0f7-fe87-498a-a68c-22e8ccd77530.png" alt class="image--center mx-auto" /></p><p>Now, we need to click on Generate new token, and from the drop-down, choose to Generate new token (classic).</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680952313629/c132e056-f7c0-4766-bfe9-9e96a790e926.png" alt class="image--center mx-auto" /></p><p>Now, you will get a personal access token and paste it into the <code>Password for 'https://username@github.com'</code> field when you authenticate via the command line.</p><pre><code class="lang-bash">$ git push origin mainUsername <span class="hljs-keyword">for</span> <span class="hljs-string">'https://github.com'</span>: usernamePassword <span class="hljs-keyword">for</span> <span class="hljs-string">'https://username@github.com'</span>: PersonalAccessToken</code></pre><p>Hopefully, this article will help you if you have faced a similar issue. If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/github-authentication-failed-error-from-command-line</link><guid isPermaLink="true">https://cloudifydevops.com/github-authentication-failed-error-from-command-line</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Sat, 08 Apr 2023 11:25:39 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1681295213170/242ab60b-ac3d-415c-b89f-0300d1c34bb4.png</cover_image></item><item><title><![CDATA[Mastering Git: 18 Essential Commands for Becoming a Version Control Pro]]></title><description><![CDATA[<p>Git is a popular version control tool that makes it easier for developers to collaborate effectively on a project. It enables multiple developers to collaborate on the same codebase without eliminating one another's changes. To properly take advantage of Git's potential, one needs to grasp a few key commands that can turn them into version control experts.</p><p>We'll go through some important Git commands in this article to help you become an expert in version control.</p><h3 id="heading-1-git-config">1. git config</h3><p>To configure Git in your local machine, the <code>git config</code> command is used. It enables you to set up your name and email, define aliases for frequently used commands, and set various preferences.</p><pre><code class="lang-yaml"><span class="hljs-comment">#To display the current configuration</span><span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">--list</span><span class="hljs-comment">#To set up your name and email address</span><span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">--global</span> <span class="hljs-string">user.name</span> <span class="hljs-string">"Your Name"</span><span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">--global</span> <span class="hljs-string">user.email</span> <span class="hljs-string">"youremail@example.com"</span><span class="hljs-comment">#To define an alias for frequently used commands</span><span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">--global</span> <span class="hljs-string">alias.co</span> <span class="hljs-string">checkout</span></code></pre><p>This <code>git config --global alias.co checkout</code> will create an alias "co" for the "checkout" command. So, now you can type "git co" instead of typing "git checkout".</p><h3 id="heading-2-git-init">2. git init</h3><p>A new Git repository is set up using the git init command. In the current directory, it generates a new .git subdirectory that contains all the files required to manage the repository. To create a Git repository, this command must be used once at the beginning of a project.</p><p>Imagine you wish to use Git for version control when starting a new software project. The first thing you would do is to initialize a new Git repository using the <code>git init</code> command in the directory (Let's say ~/Desktop/my-project) where you want to keep that project. So, you need to go to that directory and run the following command to initialize the Git which will only create a local git repository.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">init</span></code></pre><h3 id="heading-3-git-remote">3. git remote</h3><p>If you want to push your commits to a remote repository like GitHub, GitLab, or others, the first thing you need to do is to create a remote repository there and then configure the local repository you have just created to push to that remote repository. To do this, you need to run the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">remote</span> <span class="hljs-string">add</span> <span class="hljs-string">origin</span> <span class="hljs-string">https://github.com/&lt;your-username&gt;/my-project.git</span></code></pre><p>This command will add a remote called "origin" to the local repository, which directs to the URL of your remote repository on GitHub. After executing this, you can push your local changes to the remote repository by running <code>git push</code>.</p><p>If you want to remove the local Git repository from a remote origin repository, you can use the following commands:</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">remote</span> <span class="hljs-string">remove</span> <span class="hljs-string">origin</span></code></pre><p>To check if there are any remote repositories associated with your local Git repository, you can use the following command which will list all the remote repositories associated with your local Git repository.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">remote</span> <span class="hljs-string">-v</span></code></pre><h3 id="heading-4-git-add">4. git add</h3><p>To add files to the staging area, use the <code>git add</code> command. Changes are temporarily held in the staging area before being committed. Every time a file needs to be committed after being modified, this command needs to be run.</p><p>Let's say you have a project that contains the file named main.txt. You wish to commit the file's modifications to your Git repository because you made some changes to it. But, you must first add the file to the staging area using the <code>git add</code> command before you can commit the modifications.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">add</span> <span class="hljs-string">main.txt</span></code></pre><p>In case you have modified multiple files in your local repository and want to commit all those files to your Git repository, you can run the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">add</span> <span class="hljs-string">.</span></code></pre><h3 id="heading-5-git-commit">5. git commit</h3><p>The local repository is updated using the <code>git commit</code> command. It is used to create a snapshot of the staged modifications along a timeline of a Git project's history. Each commit includes a message that details the modifications made.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">commit</span> <span class="hljs-string">-m</span> <span class="hljs-string">"Added new content to main.txt"</span></code></pre><p>The -m option allows you to add a commit message that details the changes made in the commit. It is recommended that the commit message should be descriptive and summarize the changes you made.</p><h3 id="heading-6-git-push">6. git push</h3><p>To submit local repository changes to a remote repository, the <code>git push</code> command is used. After a commit, this command must be executed to make the changes available to other developers.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">origin</span> <span class="hljs-string">master</span></code></pre><h3 id="heading-7-git-pull">7. git pull</h3><p>The <code>git pull</code> command is used to update the changes from the remote repository to the local repository. Before making any changes to the local repository, this command must be executed to make sure it is up-to-date.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">pull</span> <span class="hljs-string">origin</span></code></pre><h3 id="heading-8-git-status">8. git status</h3><p>The <code>git status</code> command displays the local Git repository's current status. It displays information about any deleted or untracked files as well as changes made to the local working directory, staging area, and repository.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">status</span></code></pre><h3 id="heading-9-git-clone">9. git clone</h3><p>A copy of a remote repository can be made on a local machine using the <code>git clone</code> command. When creating a new development environment or working on a project with multiple developers, this command is helpful.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">clone</span> <span class="hljs-string">&lt;URL</span> <span class="hljs-string">of</span> <span class="hljs-string">the</span> <span class="hljs-string">repository&gt;</span></code></pre><h3 id="heading-10-git-branch">10. git branch</h3><p>You can create, list, or delete branches with the <code>git branch</code> command. It allows the developer to work on different features or versions of the project without affecting the main branch. To start a new branch or change branches, this command must be used.</p><p>To list all the branches we can use the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">branch</span> <span class="hljs-string">-a</span> <span class="hljs-string">-v</span></code></pre><p>To delete a local branch, you need to run the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">branch</span> <span class="hljs-string">-d</span> <span class="hljs-string">new-branch</span><span class="hljs-comment">#To delete a local branch forcefully</span><span class="hljs-string">git</span> <span class="hljs-string">branch</span> <span class="hljs-string">-D</span> <span class="hljs-string">new-branch</span></code></pre><p>Git will not allow you to delete the local branch if there are unmerged changes in that branch. In that case, you need to use -D flag that will forcefully delete that branch.</p><p>To delete a remote branch, the following command needs to be executed but if the remote branch needs to be deleted forcefully then the --force/--f flag should be used.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">origin</span> <span class="hljs-string">--delete</span> <span class="hljs-string">new-branch</span><span class="hljs-comment">#To delete the remote branch forcefully</span><span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">origin</span> <span class="hljs-string">--delete</span> <span class="hljs-string">--f</span> <span class="hljs-string">new-branch</span></code></pre><h3 id="heading-11-git-diff">11. git diff</h3><p>The <code>git diff</code> command displays the modifications made to a file or set of files between two versions.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">diff</span></code></pre><h3 id="heading-12-git-log">12. git log</h3><p>A list of commits made to the repository is displayed by the <code>git log</code> command. It shows the information about the commit, including the author, date, and commit message.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">log</span></code></pre><h3 id="heading-13-git-merge">13. git merge</h3><p>The <code>git merge</code> command is used to combine changes from one branch into another branch. When working on the same code, developers can utilize this to integrate their changes before putting them up in a branch.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">merge</span></code></pre><h3 id="heading-14-git-show">14. git show</h3><p>The <code>git show</code> command provides information about a particular commit. It display the changes made in the commit and other metadata, such as the commit message, author, and date.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">show</span></code></pre><h3 id="heading-15-git-reset">15. git reset</h3><p>The <code>git reset</code> command resets the repository's state to a particular commit. It can be applied to undo repository modifications or to undo erroneous commits. With the <code>git log</code> command, you can get the commit id.</p><pre><code class="lang-yaml"><span class="hljs-comment">#To reset the reposiotry to a specific commit id</span><span class="hljs-string">git</span> <span class="hljs-string">reset</span> [<span class="hljs-string">commit</span> <span class="hljs-string">id</span>]<span class="hljs-comment">#To reset the repository to the previous commit</span><span class="hljs-string">git</span> <span class="hljs-string">reset</span> <span class="hljs-string">HEAD^</span></code></pre><p>This <code>git reset HEAD^</code> will reset the repository to the previous commit and move the HEAD pointer back to one commit.</p><h3 id="heading-16-git-stash">16. git stash</h3><p>Changes that are not yet ready to be committed are stored temporarily using the <code>git stash</code> command. It can be used to save modifications before merging or to transition between branches without committing changes.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">stash</span></code></pre><h3 id="heading-17-git-checkout">17. git checkout</h3><p>To switch between branches or to create a new branch, <code>git checkout</code> command is used.</p><pre><code class="lang-yaml"><span class="hljs-comment"># Switch between branches:</span><span class="hljs-string">git</span> <span class="hljs-string">checkout</span> <span class="hljs-string">feature-branch</span><span class="hljs-comment">#Create and switch to a new branch</span><span class="hljs-string">git</span> <span class="hljs-string">checkout</span> <span class="hljs-string">-b</span> <span class="hljs-string">another-new-branch</span></code></pre><h3 id="heading-18-git-rm">18. git rm</h3><p>To remove a file (main.txt) from both the working directory and the Git repository, the <code>git rm</code> command is used.</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">rm</span> <span class="hljs-string">main.txt</span></code></pre><p>If you want to keep it in the working directory but remove from Git repository, you can use the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">git</span> <span class="hljs-string">rm</span> <span class="hljs-string">--cached</span> <span class="hljs-string">main.txt</span></code></pre><h3 id="heading-conclusion">Conclusion</h3><p>In conclusion, Git is a crucial tool for version control in software development. You can become an expert in version control by learning these key Git commands as well as other Git commands. These commands make it possible to manage the codebase and collaborate effectively with other developers. Git commands not only help you save time but also enable you to track changes, correct issues, and maintain a transparent history of the project. You may work smarter and more productively in software development by correctly using Git commands.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/mastering-git-18-essential-commands-for-becoming-a-version-control-pro</link><guid isPermaLink="true">https://cloudifydevops.com/mastering-git-18-essential-commands-for-becoming-a-version-control-pro</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Sat, 08 Apr 2023 10:26:08 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1680949165750/e7b6c1da-49d8-40d7-b83e-03693d5b37f6.png</cover_image></item><item><title><![CDATA[8 Key Kubernetes Components You Need to Know for Successful Application Deployment]]></title><description><![CDATA[<p>Kubernetes, which is defined as a powerful container orchestration platform, has several important components such as Pods, Services, Ingress, ConfigMaps, Secrets, Deployments, ReplicaSet, StatefulSets, and others. In this article, we will discuss 8 important components in-depth to help you understand how they function and how they tie into the larger Kubernetes ecosystem before deploying your first application in Kubernetes. In the previous article of this Kubernetes series, we learned about essential concepts of Kubernetes before starting your Kubernetes journey.  </p><p><a target="_blank" href="https://cloudifydevops.com/kubernetes-101-essential-concepts-to-master-before-you-begin">Kubernetes 101: Essential Concepts to Master Before You Begin</a></p><p>So, this article is for you whether you're a beginner just getting started with Kubernetes or an experienced user trying to enhance your understanding. Let's explore some of Kubernetes' key components to realize the full potential of container orchestration! Hopefully, by the end of this artile, you'll have a solid understanding of each of these components as well as how to deploy and manage your containerized apps using them.</p><p>Some of Kubernetes' essential components are:</p><ol><li><p>Pods</p></li><li><p>Service</p></li><li><p>Ingress</p></li><li><p>ConfigMap</p></li><li><p>Secrets</p></li><li><p>Deployments</p></li><li><p>ReplicaSet</p></li><li><p>StatefulSets</p></li></ol><h2 id="heading-1-pods">1. Pods</h2><p>A pod is known as the smallest deployable unit in Kubernetes which represents a single instance of a running process. Pods run inside a node which is a physical or virtual machine in a Kubernetes cluster that runs containers. Usually, a pod is meant to run one container inside it but it can contain multiple containers as well. One common use case is a pod is the sidecar pattern where a main application container run alongside one and more sidecar containers for providing different functionality. For example, a single container inside a pod runs an instance of a web server like Nginx or Apache but in case there are two containers, then the main container runs a web server, and the other running sidecar container provides logging or monitoring capabilities.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680304977217/736cb31c-2797-44f1-a570-28c8ae217136.png" alt class="image--center mx-auto" /></p><p>In the diagram, we can see that node contains two pods and each pod has a container running inside it. One pod has a my-app container and another pod has a database container.</p><h2 id="heading-2-service">2. Service</h2><p>In Kubernetes, when pods are created, they are assigned an internal IP address to communicate with each other. If a pod is recreated, it may be assigned a different IP address that's why these IP addresses are not stable. So, if my-app is communicating with the database app using an internal IP address, we need to adjust the IP address every time the database pod recreation.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680305007939/a2bb418e-c9a6-439c-af2f-0207fdb1ed64.png" alt class="image--center mx-auto" /></p><p>To prevent this issue, another component of Kubernetes <strong>Service</strong> is used. A Service provides a stable IP address for pods. Even if pods are recreated, the Service and its IP address will stay. In the above diagram, if my-app pod will be recreated, it will not affect the life cycle of its service. The service and its IP address will be the same, so we don't need to adjust any IP address anymore. Services also act as a load balancer which means that it catches traffic and forwards it to the pod that is the least busy.</p><h2 id="heading-3-ingress">3. Ingress</h2><p>An Ingress is a Kubernetes component that enables you to expose your services to the public internet. An Ingress performs as a reverse proxy, forwarding incoming requests to the appropriate service based on the rules that you define on the ingress resource. <a target="_blank" href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/">Ingress controller</a> is responsible for fulfilling the Ingress, usually with a load balancer.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680305898181/c7aaddc8-1362-4bb7-8e11-b98fcb8c0e2d.png" alt class="image--center mx-auto" /></p><p>In this diagram, we are exposing the my-app application over the public internet. Here, a request from a client first goes to the ingress and then the ingress sends that request to the service of the my-app pod.</p><h2 id="heading-4-configmap">4. ConfigMap</h2><p>A ConfigMap provides a way to store configuration data in key-value pairs for an application separately from your application code. It is an external configuration file for an application. It can be used to store environment variables, database endpoints, or other application settings. It is connected to the pods, so pods can get data that ConfigMap contains.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680307325224/589e34eb-6ea6-4a53-a9d3-e670381d836a.png" alt class="image--center mx-auto" /></p><p>In this example, to communicate with the database pod, my-app will have a database endpoint/URL named "my-db-service". If we put this endpoint in the application as an application properties file or as an external variable, it will be a problem if the URL will change to "db-service". In that case, the application needs to rebuild which creates a complicated process. We can avoid all these hassles if we simply put this database endpoint in the ConfigMap and adjust it in case of any changes.</p><h2 id="heading-5-secrets">5. Secrets</h2><p>A Secret gives an application a method to store sensitive information like usernames, passwords, certificates, or API keys in an encrypted format. This component is similar to ConfigMap. The only difference is ConfigMap is used to store information in a plain text format while Secrets are used to store encrypted data securely. Secret also needs to be attached to the pod, so that pod gets those secure contents from it.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680308992427/e188b1b9-59ec-471f-886f-f31fed0d643b.png" alt class="image--center mx-auto" /></p><p>In this diagram, we can add the database's credentials inside the Secret with proper encryption and connects it to the my-app pods to get those credentials securely.</p><h2 id="heading-6-deployment">6. Deployment</h2><p>A Deployment is a high-level object that manages the deployment and scaling of a set of replicas of a pod. It is known as the blueprint of a pod. It ensures that the desired number of replicas is always healthy and running. It provides a declarative approach to specify your application's desired state, along with the container image, the number of replicas, and any other configuration options. Kubernetes automatically handles the deployment of new replicas and the termination of old replicas when you change the configuration of the Deployment, ensuring that your application is always running and up-to-date.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680382555038/fe3f80be-8365-4fd9-a014-cc964dbd313a.png" alt class="image--center mx-auto" /></p><p>For example, if we specify 2 replicas in the deployment file of the my-app pod, it will create another pod in another node of the Kubernetes cluster which will also connect to the same Service. In the diagram, we can see that if a pod dies, the service will forward the traffic to another pod running in another node in the same cluster as the Service works as a load balancer. In this way, we can ensure that our application is always running and healthy.</p><h2 id="heading-7-replicaset">7. ReplicaSet</h2><p>In Kubernetes, a ReplicaSet makes sure that a certain amount of pod replicas are running at all times. For pods, fault tolerance and scalability are ensured by replica sets. ReplicaSet shouldn't typically be created explicitly. Deployment, on the other hand, is a higher-level object that manages ReplicaSets and gives Pods declarative updates. Instead of using ReplicaSets explicitly, Deployments are recommended.</p><h2 id="heading-8-statefulset"><strong>8. StatefulSet</strong></h2><p>A StatefulSet maintains a set of stateful Pods and ensures a specified number of stateful pods are always running. A StatefulSet is used for applications that require stable and unique network identities or persistent storage, such as databases. If we want to use the replication of the database pod in another node, we can't use the deployment because the database has its state which is its data. In this case, we need to use StatefulSet which ensures that database reads and writes are synchronized. Deploying a database using StatefulSet is a bit complicated compared with Deployment. So it is recommended to host a database outside the Kubernetes cluster.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680385003688/702bc834-b52c-4192-b28e-f62646b63690.png" alt class="image--center mx-auto" /></p><h2 id="heading-conclusion">Conclusion</h2><p>In conclusion, Kubernetes is a powerful platform for container orchestration that provides a wide range of components to support the deployment and scaling of your apps. We looked at 8 key Kubernetes parts in this article: Pods, Services, Ingress, ConfigMaps, Secrets, Deployments, ReplicaSets, and StatefulSets. You can construct reliable, scalable, and resilient applications that take full advantage of Kubernetes by comprehending about these components and how they work.</p><h2 id="heading-references">References</h2><ol><li><a target="_blank" href="https://kubernetes.io/">https://kubernetes.io/</a></li></ol><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/8-key-kubernetes-components-for-successful-application-deployment</link><guid isPermaLink="true">https://cloudifydevops.com/8-key-kubernetes-components-for-successful-application-deployment</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Sat, 01 Apr 2023 22:40:17 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1680388808349/816dc3c0-7e2b-4a93-8af2-c4996b853a10.png</cover_image></item><item><title><![CDATA[Kubernetes 101: Essential Concepts to Master Before You Begin]]></title><description><![CDATA[<p>Kubernetes has emerged as a crucial component of contemporary software development, particularly for businesses that operate on a large scale. It is an open-source container orchestration technology that was initially created by Google and automates the deployment, scaling, and management of containerized applications. With Kubernetes, developers have the freedom to concentrate on creating code rather than worrying about the supporting infrastructure because of the framework it provides for managing distributed systems. For businesses that want to develop and deploy applications rapidly and effectively, with high availability, scalability, and resilience, Kubernetes is essential. This blog will explain what Kubernetes is, how it functions, its architecture and core components, and why modern software development needs it.</p><h2 id="heading-kubernetes-and-how-it-works">Kubernetes and How It Works</h2><p>As technology is rapidly changing, the deployment, scaling, and maintenance of containerized applications are all automated via the open-source container orchestration technology known as Kubernetes.</p><p><strong>Containerization</strong> is a process of packaging software in a way that it can run reliably across different computing environments. It has grown in popularity in recent years because it enables developers to build, package, and deploy applications more rapidly and consistently. Several applications can operate on a single host operating system using this containerization technique without interfering with one another. Each container has its own set of dependencies, libraries, and configuration files and is isolated from the others.</p><p>Let's understand more clearly with an example. Consider running a web application you have for development purposes on your local environment. To function, the application needs particular versions of Node.js, a database, and a few third-party libraries. As you are using your computer for other purposes as well, installing these dependencies globally and running the chance of conflicts with other programs is not something you want to do. Instead, you can package the application and its dependencies separately from the rest of the system by the container and run in any computer that supports containerization technologies, such as Docker. That container can also be deployed to a cloud platform like AWS or Google Cloud and based on demand, it can be quickly scaled up or down, making it simple to handle traffic peaks without over-provisioning resources.</p><p><strong>A Container Orchestrator</strong> is a tool that simplifies the management of containerized applications and helps ensure that they are running properly across a distributed system which automates tasks such as network configuration, scaling, and load balancing. Kubernetes is created based on this principle that provides a powerful set of features for managing containerized applications such as:</p><ol><li><p>Container orchestration: Kubernetes helps to automate the deployment, scaling, and management of containerized applications across a cluster of nodes.</p></li><li><p>Service discovery and load balancing: Kubernetes has an internal DNS system that helps to discover containers and communicate with each other. It also offers load balancing for distributing traffic between containers.</p></li><li><p>Self-healing: The health of containers is being monitored continuously and restarted or replaced automatically by Kubernetes if they fail or become unresponsive.</p></li><li><p>Auto-scaling: Kubernetes can automatically scale the number of containers based on resource utilization and spikes in traffic.</p></li><li><p>Rolling updates and rollbacks: Without downtime, Kubernetes offers a way to perform updates to containers and if there are any critical issues, It allows for easy rollbacks.</p></li><li><p>Config management: Kubernetes offers a way to manage configuration files and environment variables for containers.</p></li><li><p>Storage orchestration: Kubernetes can manage storage for containerized applications, including persistent storage volumes.</p></li><li><p>Security: Kubernetes offers a range of security features, including role-based access control (RBAC), network policies, and container image verification</p></li></ol><h2 id="heading-kubernetes-architecture-and-components">Kubernetes Architecture and Components</h2><p>As a distributed system for managing containerized applications, Kubernetes is composed of a cluster of nodes and those nodes in a Kubernetes cluster are divided into two types:</p><ol><li><p>Master node</p></li><li><p>Worker Node</p></li></ol><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1679862288830/262c132c-925d-46da-b6c3-2ba04aa02931.png" alt class="image--center mx-auto" /></p><p>The Component of Kubernetes cluster (Source: Kubernetes)</p><p><strong>1. Master Node:</strong> The master node runs the Kubernetes <strong>control plane</strong> components which is a collection of Kubernetes components that are responsible for managing the state of the cluster, scheduling applications, and maintaining communication between nodes. Control plane containers the following components:</p><ul><li><p><strong>Kubernetes API server</strong>: This is the central management point for the Kubernetes cluster. It provides an HTTP REST API that allows end users to interact with the Kubernetes cluster, including creating and managing pods, services, and other objects. The other cluster components also communicate with this API server. The API server is responsible for exposing the cluster API endpoints and processing all API requests as well as authentication and authorization. This API server is the only component that communicates with etcd and also coordinates all the processes between the control plane and worker node components.</p></li><li><p><strong>etcd</strong>: This is a distributed key-value store used by Kubernetes to store cluster configuration and state information. We can call it the brain of the cluster. It provides a reliable and consistent way to store data across the cluster. etcd stores all configurations, states, and metadata of Kubernetes objects such as pods, secrets, deployment, daemonset, configmaps, etc. As it was mentioned earlier, It only communicates with the API server.</p></li><li><p><strong>Kubernetes Scheduler</strong>: This component is responsible for scheduling pods onto worker nodes based on available resources and other constraints.</p><p>  To deploy a pod, we specify the pod requirements that include CPU, memory, priority, persistent volumes (PV),  etc and they deploy it in the cluster. Then Kubernetes scheduler identifies the pod creation request and chooses the best node for a pod that satisfies all the requirements.</p></li><li><p><strong>Kube Controller Manager</strong>: In Kubernetes, controllers are programs that run endless control loops which continuously observe the state of objects in case there is any difference between the actual and desired state of those objects. The controller manager runs the core controllers that monitor and takes necessary action to maintain the desired state.</p></li><li><p><strong>Cloud Controller Manager</strong>: The Cloud Controller Manager (CCM) is a component of the Kubernetes control plane that runs when Kubernetes is deployed in cloud environments. It provides an interface between the Kubernetes control plane and the cloud platform API and enables interaction between Kubernetes and the cloud provider's underlying infrastructure. Load balancers, block storage, network routes, etc are a few of the resources that CCM is responsible for managing.</p></li></ul><p><strong>2. Worker Node:</strong> The worker node(s) are responsible for running containers and serving application traffic. They contain the following core components:</p><ul><li><p><strong>Kubelet</strong>: This is an agent that runs as a daemon on each worker node and communicates with the Kubernetes API server to manage containers and pods from pod specification. It creates containers based on pod specifications. By starting, stopping, and restarting the containers as needed, the Kubelet makes sure they are running and in good condition. Moreover, it monitors how much CPU and memory are being used by the containers and provides this data to the Kubernetes API server.</p></li><li><p><strong>Kube-proxy:</strong> The kube-proxy is a network proxy and load balancer for Kubernetes services. It executes on each worker node as a daemonset and routes traffic to the proper container or pod in accordance with the configuration of the service. Iptables rules, which is a default mode, are used by the kube-proxy to control network traffic and guarantee the service's scalability and high availability. With this mode, kube-proxy choose the backend pod randomly for load balancing. Once the connection is made, requests are sent to the same pod until the connection is broken.</p></li><li><p><strong>Container runtime:</strong> Container runtime is a program that runs containers on worker nodes. It runs on all the nodes in the Kubernetes cluster. It is responsible for starting and stopping containers as well as pulling images from container registries, and allocating containers resources such as CPU and memory. Organizations can select the container runtime that best suits their needs thanks to Kubernetes' support for a variety of them.</p></li></ul><h2 id="heading-conclusion"><strong>Conclusion</strong></h2><p>In this article, we have discussed the fundamentals of Kubernetes, such as containerization, container orchestrators, and the main elements of the Kubernetes architecture. We've seen how Kubernetes offers attributes like fault tolerance, scalability, and high availability, all of which are essential for operating mission-critical applications.</p><p>The fundamental building blocks of Kubernetes, known as Kubernetes objects, will be covered in more detail in the forthcoming article. We will explore the different types of objects, their properties, and how a Kubernetes cluster can use them to manage its resources and applications.</p><p>Stay tuned for more information about the interesting Kubernetes world!</p><h2 id="heading-references">References:</h2><ol><li><a target="_blank" href="https://kubernetes.io/">https://kubernetes.io/</a></li></ol><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/kubernetes-101-essential-concepts-to-master-before-you-begin</link><guid isPermaLink="true">https://cloudifydevops.com/kubernetes-101-essential-concepts-to-master-before-you-begin</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Sun, 26 Mar 2023 21:10:33 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1679864384602/91ba8fba-6324-49b1-adbd-e0819b92b688.png</cover_image></item><item><title><![CDATA[How I Fixed the direnv allow Error: Troubleshooting .envrc and direnv Issues for Effective Environment Variable Management]]></title><description><![CDATA[<p>In software development, <code>.envrc</code> and <code>direnv</code> are tools used to manage environment variables. While working on a project, I faced a problem while getting environment variables from the .envrc file, though I executed <code>direnv allow</code> command successfully.</p><p>In this article, I am going to discuss how I have solved this issue and additionally, before that, I will discuss <code>.envrc</code> and <code>direnv</code></p><h2 id="heading-envrc">.envrc</h2><p>Environment variables and their values can be defined in configuration files called <code>.envrc</code> files which stand for "Environment RC" files. Sensitive data that shouldn't be committed to version control, such as API keys, credentials, and other configuration data, is typically stored in this file. The file, which contains a list of key-value pairs that can be exported as environment variables, is usually stored in the project's root directory.</p><p>Similar to <code>.envrc</code>, <code>.env</code> is also a configuration file that sets environment variables but the main difference is that <code>.envrc</code> is specific to <code>direnv</code>, whereas <code>.env</code> is a general-purpose file that may be used by any tool or framework.</p><p>Consider that you are working on a project that calls for an API key from a third-party service. In the root directory of your project, run this command in the terminal:</p><pre><code class="lang-yaml"><span class="hljs-string">vim</span> <span class="hljs-string">.envrc</span></code></pre><p>Then insert this line in the .envrc file:</p><pre><code class="lang-yaml"><span class="hljs-string">export</span> <span class="hljs-string">API_KEY=YOUR_API_KEY</span></code></pre><h2 id="heading-direnv">direnv</h2><p>Environment variables can be managed using the tool known as <code>direnv</code>, which stands for "directory environment," in a flexible and secure way compared to conventional methods. It allows you to define environment variables for specific directories and automatically exports them when any change has been made into those directories. This can be helpful for projects that need various environment variables for various settings, such as production, staging, and development, or for various stages of development.</p><h2 id="heading-steps-to-fix-the-direnv-allow-error">Steps to Fix the direnv allow Error</h2><h3 id="heading-basic-installation"><strong>Basic Installation</strong></h3><p>To install <code>direnv</code> in MacOS, run this command in the terminal:</p><pre><code class="lang-yaml"><span class="hljs-string">brew</span> <span class="hljs-string">install</span> <span class="hljs-string">direnv</span></code></pre><h3 id="heading-hook-direnv-into-the-shell">Hook direnv into the Shell</h3><p><code>direnv</code> must be linked to the shell in order to function properly. Each shell has a unique extension system. Now add the following line at the end of the <code>~/.zshrc</code> file:</p><pre><code class="lang-yaml"><span class="hljs-string">eval</span> <span class="hljs-string">"$(direnv hook zsh)"</span></code></pre><p>If you are using Bash then add the following line at the end of the <code>~/.bashrc</code> file:</p><pre><code class="lang-yaml"><span class="hljs-string">eval</span> <span class="hljs-string">"$(direnv hook bash)"</span></code></pre><p>In these examples:</p><ul><li><p><code>eval</code> function evaluates the string that is passed to it as a shell command.</p></li><li><p>To use <code>direnv</code> in the shell, the <code>direnv hook zsh</code> command generates a string of Zsh shell commands to configure.</p></li><li><p>For Bash, it's doing the same mechanism.</p></li></ul><p>Configuring the hook of <code>direnv</code>, restart your shell to work properly.</p><p>After that, the following command needs to be executed in the terminal to make <code>direnv</code> work.</p><pre><code class="lang-yaml"><span class="hljs-string">direnv</span> <span class="hljs-string">allow</span></code></pre><p><strong>N.B: If you update the .envrc file, you need to execute the</strong> <code>direnv allow</code> <strong>command again.</strong></p><h3 id="heading-retrieve-environment-variable">Retrieve Environment Variable</h3><p>Once the <code>direnv allow</code> command will be executed, you can load the environment variables. You can use the <code>API_KEY</code> variable in your code like this:</p><pre><code class="lang-yaml"><span class="hljs-string">import</span> <span class="hljs-string">os</span><span class="hljs-string">api_key</span> <span class="hljs-string">=</span> <span class="hljs-string">os.getenv("API_KEY")</span></code></pre><p>In this example:</p><ul><li><p>We need to import os which is a Python built-in module that offers a means to communicate with the underlying operating system. Sometimes, Python interpreter might include this os module by default.</p></li><li><p>In the Python os module, there is a function called <code>os.getenv</code> that returns the value of an environment variable.</p></li></ul><h2 id="heading-conclusion">Conclusion</h2><p>In conclusion, <code>.envrc</code> and <code>direnv</code> are essential tools for managing your environment variables and making sure that your development environment is configured correctly. The methods described in this article can help you identify and fix any problems, including the <code>direnv allow</code> error. You may optimize your development process and improve your efficiency by following these best practices.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/how-i-fix-the-direnv-allow-error</link><guid isPermaLink="true">https://cloudifydevops.com/how-i-fix-the-direnv-allow-error</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Thu, 09 Feb 2023 15:43:21 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1675958032532/715099e1-cbd1-4623-a97b-569fb5f86caf.png</cover_image></item><item><title><![CDATA[12 Kubectl Commands to Master Kubernetes Deployments]]></title><description><![CDATA[<p>The kubectl command-line tool is the main interface for interacting with Kubernetes, a robust platform for managing containerized applications. You may create, update, and manage resources, such as pods, services, and deployments, in a Kubernetes cluster using kubectl.</p><p>In this article, we'll look at the 12 kubectl commands that any Kubernetes administrator needs to be familiar with. These commands will help you master Kubernetes, from managing and debugging apps to creating and updating resources. This article will provide you a thorough overview of the most important kubectl commands, whether you're an experienced Kubernetes user or you're just getting started.</p><h2 id="heading-1-kubectl-cluster-info"><strong>1. kubectl cluster-info</strong></h2><p>This command provides information about the current state of your Kubernetes cluster, including the API server address, the cluster state, and the versions of the components that make up your cluster.</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">cluster-info</span></code></pre><h2 id="heading-2-kubectl-version">2. kubectl version</h2><p>This command displays the version of <code>kubectl</code> that is currently installed on your system, as well as the version of the Kubernetes cluster that it is connected to.</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">version</span></code></pre><h2 id="heading-3-kubectl-get">3. kubectl get</h2><p>This command will provide a list of resources available in your Kubernetes cluster. There are several types of resources:</p><ul><li><p>Namespace</p></li><li><p>Deployment</p></li><li><p>Pod</p></li><li><p>Node</p></li><li><p>Service</p></li><li><p>ReplicaSets.</p></li></ul><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">all</span></code></pre><p>This command will give the list of all of those available resources in your cluster. To pull a list of a specific resource, you need to use the following command in your terminal.</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">deployment</span></code></pre><p>For a specific namespace:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">deployment</span> <span class="hljs-string">-n</span> <span class="hljs-string">namespace</span></code></pre><p>Here, -n is the short form of the flag -namespace. If you don't use any specific namespace, then <code>kubectl get deployment</code> command will return the deployment list from the "default"/current namespace. A namespace is a Kubernetes object that separates a single physical Kubernetes cluster into numerous virtual clusters.</p><p>Similarly, If you need to fetch the list of all the pods in a namespace, you can use this command:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">pods</span> <span class="hljs-string">-o</span> <span class="hljs-string">wide</span></code></pre><p>here, "-o wide" flag is providing more details about the pod.</p><p>So, with this kubectl get command, we can also fetch the list of Node, Namespace, ReplicaSets and Service</p><h2 id="heading-4-kubectl-create">4. kubectl Create</h2><p>The Kubernetes command <code>kubectl create</code> is used to add new resources to a cluster. Users can build resources like pods, services, and deployments using this commands. Here's an illustration of how to build a new deployment using kubectl create:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">create</span> <span class="hljs-string">deployment</span> <span class="hljs-string">my-nginx</span> <span class="hljs-string">--image=nginx</span></code></pre><p>With this command, a new deployment named will <code>my-nginx</code> will be created using the <code>nginx</code> image.</p><p>Here is another example of how to create a new cronjob with this command:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">create</span> <span class="hljs-string">job</span> <span class="hljs-string">my-cronjob</span> <span class="hljs-string">--schedule="*/5</span> <span class="hljs-string">*</span> <span class="hljs-string">*</span> <span class="hljs-string">*</span> <span class="hljs-string">*"</span> <span class="hljs-string">--image=busybox</span> <span class="hljs-string">--</span> <span class="hljs-string">command</span> <span class="hljs-string">--</span> <span class="hljs-string">args="echo</span> <span class="hljs-string">This</span> <span class="hljs-string">is</span> <span class="hljs-string">a</span> <span class="hljs-string">cron</span> <span class="hljs-string">job!"</span></code></pre><p>With this command:</p><ul><li><p>A new CornJob will be created named my-cornjob which will be running in busybox container</p></li><li><p>An echo command will be repeated every 5 minutes</p></li><li><p><code>--schedule</code> flag specifies the schedule for the job in cron syntax</p></li><li><p>"*/5 <em>"</em> means to run the job every 5 minutes</p></li><li><p><code>--image</code> flag specifies which container it should run</p></li><li><p><code>--command</code> flag is used to specify which command it should run inside the container.</p></li></ul><p>With Kubernetes' CronJobs functionality, you can automate recurring processes like database backups, log rotations, and more.</p><h2 id="heading-5-kubectl-edit">5. kubectl edit</h2><p>With this <code>kubectl edit</code> command, you can edit an existing resource in a cluster. You can modify a resource's configuration in a text editor using <code>kubectl edit</code>, which eliminates the need for you to manually generate a new YAML file.</p><p>Here's an illustration of how to change a deployment using kubectl edit:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">edit</span> <span class="hljs-string">deployment</span> <span class="hljs-string">my-nginx</span></code></pre><p>This command starts a text editor and opens the my-nginx deployment. When you make changes to the deployment's configuration and save the file, the cluster's deployment will be updated.</p><h2 id="heading-6-kubectl-delete">6. kubectl delete</h2><p><code>kubectl delete</code> command will help you to delete any resources such as pod, deployment, service, cornjob in your Kubernetes cluster. So, never just remove anything without knowing everything you need to know about it. Think carefully before executing this command since once the resource is deleted, it cannot be recovered; you must reconstruct it.</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">delete</span> <span class="hljs-string">deployment</span> <span class="hljs-string">my-nginx</span></code></pre><h2 id="heading-7-kubectl-apply">7. kubectl apply</h2><p>The Kubernetes command <code>kubectl apply</code> enables you to create or modify resources in a cluster. Kubectl apply creates or modifies the resource in the cluster to match the configuration by reading the resource's configuration from a file or from standard input.</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">apply</span> <span class="hljs-string">-f</span> <span class="hljs-string">deployment.yaml</span></code></pre><p>Here, <code>kubectl apply</code> command reads a deployment configuration from a file named <code>deployment.yaml</code> and creates a new deployment in the cluster depending on that configuration file. In case, if there will be a file existed on that name, then this command will update that configuration file.</p><h2 id="heading-8-kubectl-config">8. kubectl config</h2><p>In Kubernetes, the command <code>kubectl config</code> allows you to manage the configuration for a kubectl client. The config command can be used to view, edit, or switch between multiple cluster configurations, as well as to manage user credentials and context settings.</p><h3 id="heading-set-a-current-namespace">Set a Current Namespace</h3><p>If you are working on a specific namespace, then every time typing a namespace in each command is a hassle. To overcome this, you can set that namespace as a current namespace.</p><p>Here is an example of how to set up a current namespace:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">config</span> <span class="hljs-string">set-context</span> <span class="hljs-string">--current</span> <span class="hljs-string">--namespace=NAMESPACE</span></code></pre><p><code>kubectl config set-context</code> is a command in Kubernetes that allows you to modify the context of a kubectl configuration. The context defines the cluster, user, and namespace that kubectl commands operate. In this example, this command will set the current namespace as "NAMESPACE".</p><h3 id="heading-set-current-context">Set Current Context</h3><p>A context is defined as a named group of clusters and user credentials in the Kubernetes cluster. To set a context, you need to execute the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">config</span> <span class="hljs-string">use-context</span> <span class="hljs-string">docker-desktop</span></code></pre><p>In this example, this command is used to switch the current context in the <code>kubectl</code> configuration to the <code>docker-desktop</code> context. So, kubectl commands can interact with the cluster running on docker-desktop. You can also use minikube instead of docker-desktop if you want to interact with the cluster running on minikube.</p><p>You can check the current context by running this command:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">config</span> <span class="hljs-string">current-context</span></code></pre><h2 id="heading-9-kubectl-describe">9. kubectl describe</h2><p><code>kubectl describe</code> is a useful tool for monitoring and debugging your Kubernetes cluster. It offers a quick approach to obtaining comprehensive information about a resource, making it simpler to understand the resource's current state and spot any problems. It shows details about a resource's status, events, and metadata.</p><p>Here is an example:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">describe</span> <span class="hljs-string">deployment</span> <span class="hljs-string">my-nginx</span></code></pre><p>With this command, you can get details information on my-nginx deployment which includes the status of the deployment, the events that have occurred, and the metadata associated with the deployment.</p><h2 id="heading-10-kubectl-logs">10. kubectl logs</h2><p>You may get the logs of a container in a pod using the Kubernetes command <code>kubectl logs</code>. The logs can be used to track down problems with a container or to troubleshoot problems with it.</p><p>Here's an example of how you can use <code>kubectl logs</code></p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">logs</span> <span class="hljs-string">my-pod</span></code></pre><p>If there will be multiple containers in a pod, we can get the log of a specific container this way:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">logs</span> <span class="hljs-string">my-pod</span> <span class="hljs-string">-c</span> <span class="hljs-string">my-container</span></code></pre><p>Here, <code>-c</code> is an option that specifies the name of the container from where you want to retrieve the logs.</p><h2 id="heading-11-kubectl-exec">11. kubectl exec</h2><p>You can execute a command in a running container of a pod using the Kubernetes command <code>kubectl exec</code>. It is helpful for debugging, troubleshooting, and monitoring the status of an application.</p><p>Here's an illustration of how kubectl exec might be used:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">exec</span> <span class="hljs-string">-it</span> <span class="hljs-string">pod-name</span> <span class="hljs-string">--</span> <span class="hljs-string">bash</span></code></pre><p>In this example, <code>kubectl exec</code> is used to launch a <code>bash</code> shell in the container of the specified pod. The <code>-it</code> flag is used to attach to the shell and interact with it.</p><p>If you have multiple containers in a pod, you can use the following command:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">exec</span> <span class="hljs-string">-it</span> <span class="hljs-string">pod_name</span> <span class="hljs-string">-c</span> <span class="hljs-string">container_name</span> <span class="hljs-string">bash</span></code></pre><p>In this example, <code>-c</code> is used to specify the container name where the shell command will be executed.</p><h2 id="heading-12-kubectl-cp">12. kubectl cp</h2><p>In Kubernetes, the command <code>kubectl cp</code> allows you to copy files and directories between a local file system and a container in a pod, or between two containers in the same pod. This can be useful for transferring files between the host and containers, or for copying files between containers within a pod.</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">cp</span> <span class="hljs-string">&lt;local-file-path&gt;</span> <span class="hljs-string">&lt;pod-name&gt;:&lt;container-destination-path&gt;</span></code></pre><p>In this example:</p><ul><li><p><code>kubectl cp</code> is used to copy a local file to a container in a pod.</p></li><li><p><code>local-file-path</code> specifies the path to the file on the local file system.</p></li><li><p><code>pod-name</code> and <code>container-destination-path</code> specify the destination of the file within the container.</p></li></ul><h2 id="heading-conclusion">Conclusion</h2><p>With that, we have come to the end of this discussion on the 12 kubectl commands for mastering Kubernetes deployments. Please keep in mind that these are not the only kubectl command and there are many more Kubernetes concepts and kubectl commands to investigate.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/12-kubectl-commands-to-master-kubernetes-deployments</link><guid isPermaLink="true">https://cloudifydevops.com/12-kubectl-commands-to-master-kubernetes-deployments</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Tue, 07 Feb 2023 12:37:15 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1675772949543/519c529b-6bb4-4835-bd78-1e7cb7f0e8d0.png</cover_image></item><item><title><![CDATA[Disaster Recovery: Protecting Your Business from Unexpected Outages]]></title><description><![CDATA[<p>Events that disrupt services could occur at any time. The network will go down anytime, when the most recent application deployment may bring a serious issue, or when there will be a natural disaster. Disasters can happen at any time, and if a business is not ready, the effects could be disastrous.</p><p>In this blog, we will examine the essential elements of an effective disaster recovery plan, including RTO, RPO, and RTA which will help you to keep your business up and running, no matter what life throws your way.</p><h1 id="heading-disaster-recovery">Disaster Recovery</h1><p>Disaster recovery (DR) refers to the process of anticipating and recovering from unexpected events. The possibility of a disaster, whether natural or man-made, is quite real in a society where technology is the backbone of the economy. Disaster recovery, however, may be a lifesaver with the correct strategy and execution, ensuring that your company remains functioning even in the aftermath of a disaster. The essential elements of an effective disaster recovery plan, from RTO to RPO to RTA, all work together to safeguard your crucial systems, data, and activities. Having a strong, focused, and tested disaster recovery plan is a fundamental need for a business when things go wrong.</p><h1 id="heading-recovery-time-objective-rto">Recovery Time Objective (RTO)</h1><p>RTO refers to the maximum amount of time the application can be offline which will be determined by the business and the DR solution should be able to restore functionality based on the business and all other requirements.</p><p><img src="https://lh3.googleusercontent.com/GlqDcyAqqhESsWND-epaCUllq7yXiXh3cLEQVHMPItfZx5Ylp1dDB-EW6xglJ81eNrKRrJ17a3nQpkHWaQ6NrBbVTyJ1MJOsetW4vChtRbQam7deqhZxkvdy_Fpt_eO1zfzGtTyH-PIpL_1tepo3-lvIvQ=s2048" alt /></p><h1 id="heading-recovery-point-object-rpo"><strong>Recovery Point Object (RPO)</strong></h1><p>RPO is the measure of acceptable data loss in case of a disaster and it determines how much of the last known good data will be recovered based on the backup and replication policies.</p><p><img src="https://lh6.googleusercontent.com/Js9oaDCWSaXlZs9eyjACCXSYYSqFwqiCcbXkSFAGo8tQLcqnaRJnrKwC8O1ztt5dcLGyaMq5ZGEIJW8kU32RJgvmMkRNtdmSV7bbl7367XaY_gAit5f4BV1zOKGnMDkDrpSDvtWLijL4TDupmJqNqss2aA=s2048" alt /></p><h1 id="heading-recovery-time-actual-rta"><strong>Recovery Time Actual (RTA)</strong></h1><p>RTA stands for Recovery time actual or achievable. This is a measurement of the actual recovery time that was shown during a test run for disaster recovery. The gap between RTO and RTA is an important metric to track. Testing the DR solution regularly will reveal RTA trends over time.</p><ul><li><p>RTA&lt;RTO then RTO indicates success or lower RTO which is good</p></li><li><p>RTA&gt;RTO then RTO indicates the failure to meet business goals or unachievable RTO</p></li></ul><p><img src="https://lh5.googleusercontent.com/VR2BXdkUrPXfOkCrVlfXWDBHwt_yg4ehyjZloQCeiH3hReI2P_evImLMA-872HE_r5g08_DoKbTPBlIO8v5h7YNdmxJAPdb7YyiaUMVrcEj5-WdckECrZ_IdfHm4x8VNj4eJ_0eheSbhxZ3IV7CVSJjZFg=s2048" alt /></p><h1 id="heading-three-disaster-recovery-strategies">Three Disaster Recovery Strategies</h1><h3 id="heading-hot-site">Hot Site</h3><p>A hot site is a fully functional backup location that offers an organization's whole infrastructure, including hardware, software, and data, to enable business continuity in the case of a disaster. A business might set up a hot site at a different location with the same servers, networking hardware, and data storage devices as its main site, along with all necessary data and programs that are pre-installed and updated. The business may immediately move to the hot site in the case of a tragedy and go on with little interruption.</p><h3 id="heading-cold-site">Cold Site</h3><p>A cold site is a pre-configured facility with minimal power and infrastructure but no hardware or data placed at the time of setup. To store its backup hardware, for instance, a business might rent a sizable data center with enough room, electricity, and cooling, but without any hardware or data already in place. Before using the cold site as a backup location, the organization must first install the needed equipment and software and restore data in the event of a disaster.</p><h3 id="heading-warm-site">Warm Site</h3><p>The middle ground between the two disaster recovery alternatives is a warm site. It is a backup location that has been pre-configured and is only partially operational, but it includes servers and networking equipment that are necessary for a business to continue operating in the event of a disaster but it might not have all the necessary data and programs pre-installed.</p><h1 id="heading-testing-dr-solution">Testing DR Solution</h1><p>The significance of testing and upgrading disaster recovery plans on a regular basis is to maintain preparation for actual disasters. For instance, a business might have a plan in place for disaster recovery that calls for moving activities to a warm site in the case of a catastrophe. The warm site may not be fully functional or its data may be outdated, which might cause delays and disruptions in the company's recovery operations if the plan is not routinely evaluated and updated. Companies should test their disaster recovery plans on a regular basis and update them as needed, whether that means installing new hardware or software, upgrading data backups, or changing the plan itself to reflect changes in the organization's operations.</p><p>As a result, there will be less downtime and business continuity will be maintained in the event of a disaster. This helps to ensure that the disaster recovery plan is prepared to be activated at a moment's notice.</p><h1 id="heading-best-practices">Best Practices</h1><p>To make sure they have all the information they need in the case of a disaster, organizations should regularly backup their data. To respond to a disaster in an efficient and organized manner, it is also essential to have a clear communication plan in place that specifies who to contact and what information to share. Finally, it's critical to train employees on the disaster recovery plan so that they are all aware of what to do in an emergency. Businesses may assure that they are ready to respond to disasters and reduce downtime and data loss by putting these best practices into effect.</p><h1 id="heading-conclusion">Conclusion</h1><p>In conclusion, disaster recovery is an essential component of corporate operations that needs careful planning and preparation. As DR affects business cost and reputation, a proper RTO and RPO should be determined by business decisions. Lower RTO and RPO solutions may be more expensive, but they can give businesses more security and reduce downtime in the event of a disaster. To monitor RTA and ensure readiness, the disaster recovery plan must undergo regular testing. The ability to promptly respond to a disaster and maintain business continuity depends on having a solid disaster recovery solution in place and available.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/disaster-recovery</link><guid isPermaLink="true">https://cloudifydevops.com/disaster-recovery</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Fri, 03 Feb 2023 14:43:29 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1675434897926/788328e3-e713-4243-b7d8-17d3eba29f45.png</cover_image></item><item><title><![CDATA[Minikube for Beginners: A Guide to a Local Kubernetes Cluster on MacOS]]></title><description><![CDATA[<p>Minikube is a tool that lets you test and develops Kubernetes applications on a single node on your local workstation. You need Minikube if you want an easy and convenient approach to test and build applications on a local Kubernetes cluster without disrupting other systems or applications. It supports a number of hypervisors and offers a low-cost, isolated environment for testing and development.</p><p>In this article, let's look at how we can set up Minikube for MacOS</p><h1 id="heading-step-1-install-homebrew">Step 1: Install Homebrew</h1><p>Homebrew, a popular package manager for macOS, can be used to install Minikube. Run the following command in your terminal if Homebrew isn't already installed on your device:</p><pre><code class="lang-yaml"><span class="hljs-string">/bin/bash</span> <span class="hljs-string">-c</span> <span class="hljs-string">"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"</span></code></pre><h1 id="heading-step-2-install-minikube">Step 2: Install Minikube</h1><p>To install Minikube, run the following command in your terminal using Homebrew:</p><pre><code class="lang-yaml"><span class="hljs-string">brew</span> <span class="hljs-string">install</span> <span class="hljs-string">minikube</span></code></pre><h1 id="heading-step-3-start-minikube">Step 3: Start Minikube</h1><p>You can start Minikube by running the following command in your terminal:</p><pre><code class="lang-yaml"><span class="hljs-string">minikube</span> <span class="hljs-string">start</span></code></pre><p>If you have a Docker machine installed in your MacOS, you might get the following error while executing the above command. <strong>To solve this issue</strong>, you need to start the Docker desktop application and rerun the command.</p><pre><code class="lang-yaml"><span class="hljs-string"></span>  <span class="hljs-attr">Exiting due to DRV_DOCKER_NOT_RUNNING:</span> <span class="hljs-string">Found</span> <span class="hljs-string">docker,</span> <span class="hljs-string">but</span> <span class="hljs-string">the</span> <span class="hljs-string">docker</span> <span class="hljs-string">service</span> <span class="hljs-string">isn't</span> <span class="hljs-string">running.</span> <span class="hljs-string">Try</span> <span class="hljs-string">restarting</span> <span class="hljs-string">the</span> <span class="hljs-string">docker</span> <span class="hljs-string">service.</span></code></pre><h1 id="heading-step-4-set-context">Step 4: Set Context</h1><p>Now you need to set the context to minikube so that the kubectl command can interact with it:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">config</span> <span class="hljs-string">use-context</span> <span class="hljs-string">minikube</span></code></pre><h1 id="heading-step-5-verify-minikube-setup">Step 5: Verify Minikube Setup</h1><p>Now you can verify the status of Minikube using the following command in your terminal:</p><pre><code class="lang-yaml"><span class="hljs-string">minikube</span> <span class="hljs-string">status</span></code></pre><h1 id="heading-step-6-interacting-with-cluster">Step 6: Interacting with Cluster</h1><p>To interact with the newly created cluster in your MacOS, you need to run the following command in your terminal if you have <strong>kubectl already installed</strong>:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">po</span> <span class="hljs-string">-A</span></code></pre><p>But, <strong>if you don't have kubectl installed</strong> on your MacOS, then run the following command where minikube can download the appropriate kubectl version:</p><pre><code class="lang-yaml"><span class="hljs-string">minikube</span> <span class="hljs-string">kubectl</span> <span class="hljs-string">--</span> <span class="hljs-string">get</span> <span class="hljs-string">po</span> <span class="hljs-string">-A</span></code></pre><h1 id="heading-step-7-testing-minikube">Step 7: Testing Minikube</h1><p>Now, we can test the minikube by deploying a simple application by following the command in the terminal:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">create</span> <span class="hljs-string">deployment</span> <span class="hljs-string">hello-minikube</span> <span class="hljs-string">--image=kicbase/echo-server:1.0</span><span class="hljs-string">kubectl</span> <span class="hljs-string">expose</span> <span class="hljs-string">deployment</span> <span class="hljs-string">hello-minikube</span> <span class="hljs-string">--type=NodePort</span> <span class="hljs-string">--port=8080</span></code></pre><p>This might take some time but if you run the following command, the deployment will show up:</p><pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">services</span> <span class="hljs-string">hello-minikube</span></code></pre><p>Letting Minikube open a web browser for you is the simplest approach to using this service. To do that run the following command in the terminal:</p><pre><code class="lang-yaml"><span class="hljs-string">minikube</span> <span class="hljs-string">service</span> <span class="hljs-string">hello-minikube</span></code></pre><h1 id="heading-step-8-access-kubernetes-dashboard">Step 8: Access Kubernetes Dashboard</h1><p>To access the dashboard of Kubernetes, you need to run the following command which will open a Kubernetes dashboard on the web browser with a user-friendly interface:</p><pre><code class="lang-yaml"><span class="hljs-string">minikube</span> <span class="hljs-string">dashboard</span></code></pre><h1 id="heading-conclusion">Conclusion:</h1><p>In this article, we have learned about Minikube and how to set it up on MacOS with a step-by-step process.</p><p>I hope this article has helped you to explore Minikube's capabilities for testing and deploying applications on a single node of a Kubernetes cluster.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/minikube-for-beginners-a-guide-to-a-local-kubernetes-cluster-on-macos</link><guid isPermaLink="true">https://cloudifydevops.com/minikube-for-beginners-a-guide-to-a-local-kubernetes-cluster-on-macos</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Thu, 02 Feb 2023 07:59:02 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1675324424590/1621876c-8d37-4184-8db0-05ad5747f912.png</cover_image></item><item><title><![CDATA[I Did it! How I Maximized My Blog's Reach by Cross-Posting. A Step-by-Step Guide]]></title><description><![CDATA[<p>I recently began my adventure as a new blogger on Hashnode with a passion for sharing my technical views and thoughts with the world. But I quickly saw that I needed to look at other platforms as well in order to really increase the visibility of my blog and attract more readers. I later learned the value of cross-posting at that point. I was able to expand the audience for my blog and distribute it over the internet by posting my content on various websites. This article will outline the steps I took to successfully cross-post from Hashnode to Dev.to and explain how it helped me reach my objective of increasing blog readership.</p><p>I will try other platforms as well for the cross-posting and I will review those in a future blog post.</p><h1 id="heading-what-is-devto">What is dev.to</h1><p>The online social media community and platform <a target="_blank" href="https://dev.to/">dev.to</a>, which stands for "Developer Community," was created especially for programmers and other tech-related hobbyists. It provides a variety of tools, including blogging, forums, job postings, and events, all aimed at building a sense of connection and community among developers around the world. The platform promotes the exchange of ideas and best practices by encouraging users to share their expertise, experiences, and insights with others. Additionally, it gives developers a place to showcase their most recent works and get input from their colleagues, which helps them evolve professionally and strengthen their talents.</p><h1 id="heading-what-is-hashnode">What is Hashnode</h1><p>A contemporary blogging platform called <a target="_blank" href="https://hashnode.com/">Hashnode</a> makes it simple for users to produce, publish, and share their material with a large audience. It is intended to simplify, streamline, and customize the blogging process, freeing users to concentrate on the blog's content rather than its technical setup and upkeep. Hashnode is a one-stop shop for bloggers trying to expand their online presence because it also provides a variety of services like analytics, comments, and SEO optimization tools. Users can quickly build a blog with a professional appearance, write and publish posts, and share their material on several channels all from one location using Hashnode. Overall, Hashnode is an easy-to-use, adaptable, and feature-rich platform.</p><h1 id="heading-what-is-cross-posting">What is Cross-Posting</h1><p>The act of uploading the same content on various platforms or websites is known as cross-posting. This can be done to boost visibility and interaction, reach a larger audience, or just save time by avoiding having to write fresh material for every platform.</p><h1 id="heading-setting-up-cross-posting">Setting up Cross-Posting</h1><ol><li><p>We need to create an account first in <a target="_blank" href="https://hashnode.com/"><strong>Hashnode</strong></a></p></li><li><p>Then create an account in <a target="_blank" href="https://dev.to/">dev.to</a></p></li><li><p>Open the settings and select the Extensions tab</p></li><li><p>You'll discover Publishing to DEV Community from RSS under the Extensions tab. Simply paste the RSS feed URL from your Hashnode into the RSS Feed URL field.</p><p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674290708505/3308e14a-8568-496e-8cb9-61a0a40ee75f.png" alt class="image--center mx-auto" /></p></li><li><p>To get your RSS feed URL, go to your Hashnode dashboard and click on RSS.xml</p><p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674290756279/32218454-79f1-405c-a920-e6b9597d2567.png" alt class="image--center mx-auto" /></p></li><li><p>A new tab will be opened and you will find your RSS feed URL from the address bar.</p><p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674290776769/7deb1dad-e958-4096-8d94-34d5d30021c1.png" alt class="image--center mx-auto" /></p></li><li><p>After pasting it into the RSS Feed URL field, click "Save Feed Settings".</p></li><li><p>Then click on "Fetch feed now" and your Hashnode articles will eventually show up as drafts in the dev.to dashboard.</p></li><li><p>You will find the article as a Draft in the dashboard and edit it before publishing it.</p></li><li><p>You might want to add a cover image that will be automatically dragged from Hashnode to dev website. At least, I have faced this issue.</p></li><li><p>So, Upload the image and copy only the part starting from https</p></li><li><p>Add "cover_image" below tags and paste the link.</p></li><li><p>The default value of "published" will be "false" as it is a draft copy. So make it "true"</p></li><li><p>Then click "Save Changes" at the bottom and it will be published instantly.</p></li></ol><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674290867936/50c8db32-54d3-4916-97b1-a5289ac7578c.jpeg" alt class="image--center mx-auto" /></p><h1 id="heading-conclusion">Conclusion</h1><p>In conclusion, cross-posting is an effective strategy for bloggers who want to broaden their audience and boost interaction. Blogging professionals can reach new audiences, increase their exposure, and increase traffic to their blogs by distributing their material across a variety of platforms. Popular platforms like Hashnode and <a target="_blank" href="http://Dev.to">Dev.to</a> provide simple cross-posting tools that make it easy for bloggers to distribute their work on several websites. Bloggers can cross-post with confidence by following the instructions in this tutorial, knowing that they are doing everything possible to increase their audience and develop their online presence.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/cross-posting-a-step-by-step-guide</link><guid isPermaLink="true">https://cloudifydevops.com/cross-posting-a-step-by-step-guide</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Sat, 21 Jan 2023 08:04:45 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1674286983410/afbaccf4-72db-407b-b7d8-f5961dc3cae7.jpeg</cover_image></item><item><title><![CDATA[How I secured sensitive information in GitLab environment variable and made the pipeline secured]]></title><description><![CDATA[<p>While working on my current project, I was facing some issues regarding GitLab CI/CD values which were getting exposed in the pipeline logs. I was looking for a solution and found that it can be achieved with the variable "masked" option. I wanted to mask a server key but it was not possible because that key has multiline values and according to the rules, the "masked" option can only be enabled on single-line variable values. So, finally, I figured out that I can achieve this using Base64. In this article, I will explain how to store sensitive data as an environment variable and secure a GitLab CI/CD pipeline by base64 encoding and decoding.</p><h1 id="heading-what-is-base64">What is Base64?</h1><p>A file (such as an image or video) can be converted into a string of text using Base64 so that it can be transferred over the internet. This is accomplished by taking the file's binary contents and turning it into a set of 64 text-usable characters. In this way, the file can be transmitted as text and still be converted back to its original format once it is retrieved. It's similar to delivering someone a gift wrapped in paper and then having them open the package to retrieve the real gift. In email attachments and when embedding files in HTML, CSS, or JavaScript, Base64 is frequently utilized.</p><h1 id="heading-gitlab-environment-variable">GitLab environment variable</h1><p>GitLab CI/CD environment variables are used to safely store and manage sensitive data that is required by the pipeline, such as API keys, passwords, and other configuration parameters. You may reduce the security risk of hardcoding sensitive information into your pipeline definition by using environment variables.</p><p>While setting up an environment variable, GitLab CI/CD provides a "masked" option that can hide the value of an environment variable from the pipeline logs. This is helpful if we don't want sensitive data, such as passwords and API credentials, to be shown in the pipeline logs. When the "masked" option is on, a variable's value is changed to ***** In the pipeline logs.</p><h1 id="heading-secured-pipeline-with-base64">Secured pipeline with Base64</h1><p>Though the "masked" is really an amazing feature of GitLab CI/CD variables, it can't be enabled on multiline variable values. Here comes Base64 which converts the multiline variable values into encoded single-line variable values and after that, I enabled the "masked" option. In the case of single-line values, we can also use Base64 to make it more secure in the pipeline. To mask a variable, there are some certain rules. The variable's value must:</p><ul><li><p>A single line.</p></li><li><p>Characters from the Base64 alphabet (RFC4648).</p></li><li><p>The <code>@</code>, <code>:</code>, <code>.</code>, or <code>~</code> characters.</p></li></ul><h3 id="heading-how-to-use-base64">How to use Base64</h3><p>The base64 command-line utility is often pre-installed if you are using a popular Linux distribution like Ubuntu, Debian, CentOS, or Red Hat. There shouldn't be any more actions for you to take.</p><p>If you are using Max OS, you can use the HomeBrew command to install base64:</p><pre><code class="lang-bash">brew install base64</code></pre><h3 id="heading-encoding-with-base64">Encoding with base64</h3><p>To encode a variable, you can use this command:</p><pre><code class="lang-bash"><span class="hljs-built_in">echo</span> -n <span class="hljs-string">"insert_your_variable"</span> | base64</code></pre><p>The output of the command is:</p><pre><code class="lang-bash">aW5zZXJ0X3lvdXJfdmFyaWFibGU=</code></pre><ul><li><p>The "echo" command is showing the variable's value in the terminal</p></li><li><p>"-n" is a subcommand for echo which is telling not to append a newline character to the end of the output otherwise it would additionally append a newline character which will also be encoded by base64 and creates additional problems during decoding.</p></li><li><p>| is known as a 'pipe' operator which takes the output of one command and makes the input for another command. In this command, this operator is passing the output of echo -n "insert_your_variable" as the input of the base64 command.</p></li></ul><p>After encoding, add that value as a CI/CD environment variable with the "masked" option enabled.</p><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674192856517/ce43f3e9-4de8-43a3-b8d4-a65a421d759e.png" alt class="image--center mx-auto" /></p><h3 id="heading-decoding-with-base64">Decoding with Base64</h3><p>To decode a variable in the terminal, just use this command with the "-d" or "--decode" after base64:</p><pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"insert_your_variable"</span> | base64 -d</code></pre><p>So, now I am going to show how we can decode the value in the GitLab CI/CD pipeline. We need to use the base64 command to decode our base64-encoded value kept in a variable named <strong>SECRET_KEY</strong> in a GitLab pipeline. I am giving a project-level example below:</p><pre><code class="lang-typescript">stages:  - deploydeploy:  stage: deploy  script:    - echo <span class="hljs-string">"$SECRET_KEY"</span> | base64 -d    - <span class="hljs-keyword">export</span> DECODED_SECRET_KEY=<span class="hljs-string">"$SECRET_KEY"</span></code></pre><p>The pipeline in this illustration has just one stage, named deploy. At the project level, the variable is stored as SECRET_KEY.</p><p>The pipeline initially uses the base64 command to decode the value contained in SECRET_KEY in the script section of the deploy step. After that, the decoded value is then exported and stored in the variable DECODED_SECRET_KEY so that it can be used later in the pipeline.</p><h1 id="heading-conclusion">Conclusion</h1><p>In this article, you have learned how to do base64 encoding for a variable and stored it in GitLab CI/CD environment variable with the "masked" option. Also, how to decode it in the GitLab pipeline without showing the variable's value in the pipeline logs.</p><p>It's crucial to note that using plain text to keep secret keys in your pipeline is not recommended; instead, it's more secure to use GitLab's secret variable feature to store the keys and use them in the pipeline.</p><hr /><p>I appreciate you taking the time to read this. Your support is much appreciated! If you found this article valuable, please consider clicking the 👉 <strong><em>Follow</em></strong> button and giving it a few claps by clicking the  <strong><em>like</em></strong> button to help me create more informative content like this. Thank you for your time! 🖤<br />Also, follow me on <a target="_blank" href="https://medium.com/@nayeem.ridoy"><strong>Medium</strong></a>, <a target="_blank" href="https://twitter.com/ShaMdNayeem"><strong>Twitter</strong></a> &amp; <a target="_blank" href="https://www.linkedin.com/in/shanayeem/"><strong>LinkedIn</strong></a>.</p>]]></description><link>https://cloudifydevops.com/secured-gitlab-pipeline-with-base64</link><guid isPermaLink="true">https://cloudifydevops.com/secured-gitlab-pipeline-with-base64</guid><dc:creator><![CDATA[Sha Md. Nayeem]]></dc:creator><pubDate>Fri, 20 Jan 2023 06:15:57 GMT</pubDate><cover_image>https://cdn.hashnode.com/res/hashnode/image/upload/v1674194087606/b406dd37-a023-44c4-b081-028d736f5f9f.jpeg</cover_image></item></channel></rss>