<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bahman Nikkhahan</title>
    <description>The latest articles on DEV Community by Bahman Nikkhahan (@bahmannik).</description>
    <link>https://dev.to/bahmannik</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F342172%2Fc323efc3-92f3-468e-b092-2a0fd50aecd7.jpg</url>
      <title>DEV Community: Bahman Nikkhahan</title>
      <link>https://dev.to/bahmannik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bahmannik"/>
    <language>en</language>
    <item>
      <title>Code review, an important process within a development team</title>
      <dc:creator>Bahman Nikkhahan</dc:creator>
      <pubDate>Tue, 29 Jun 2021 11:37:51 +0000</pubDate>
      <link>https://dev.to/bahmannik/code-review-an-important-process-within-a-development-team-c9l</link>
      <guid>https://dev.to/bahmannik/code-review-an-important-process-within-a-development-team-c9l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: Whatever you read here is just based on my experience and is my personal opinion! You may have a different idea!&lt;/p&gt;

&lt;h1&gt;
  
  
  Why do we need code review
&lt;/h1&gt;

&lt;p&gt;There are many reasons to review code, and I am sure you can do your own research to figure it out, but here are some reasons that came to my mind at the time of writing this article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Share knowledge&lt;/li&gt;
&lt;li&gt;Catch accidental errors&lt;/li&gt;
&lt;li&gt;Check test coverage&lt;/li&gt;
&lt;li&gt;Check consistency&lt;/li&gt;
&lt;li&gt;Quality control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are a developer and finished your task, it is your responsibility to find someone to review your code. Your task doesn't finish after you create a pull request. Obviously, this depends on your team and you may have a different approach.&lt;/p&gt;

&lt;h1&gt;
  
  
  Two extreme scenarios
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Team 1: Very strict&lt;/strong&gt;&lt;br&gt;
I have worked in teams that people were very strict in code reviews and spent a lot of time going through all changes and understand them. They were checking everything, like naming conversion, indentation, and even extra spaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Team 2: Very easygoing&lt;/strong&gt;&lt;br&gt;
I also worked in teams that people were very easygoing and used to approve most of the pull requests quickly.&lt;/p&gt;

&lt;p&gt;As a developer, my preference is the first team (I had a different opinion a couple of years ago!). At the end of the day, the quality of the code is very important. Having said that I was curious to know why people in the second team did not take quality time for code reviews.&lt;/p&gt;

&lt;h1&gt;
  
  
  The people side of the things
&lt;/h1&gt;

&lt;p&gt;Throughout my career as a software developer, I have seen different cultures in teams when it comes to code review. Firstly I think code review culture, is very much dependent on the company's culture. If there is not a good team binding, code review can become a place to argue and blame. People want to prove they are right not others. However, a good culture can lead to a more constructive review process and eventually a better quality of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  You are a reviewer, how do you put comments on code?
&lt;/h2&gt;

&lt;p&gt;First of all, as a reviewer, you should not sacrifice the quality of the code. Don't stop providing feedback to other developers. However, you should think about the comments that you put. Sometimes a pull request comment can go wrong and makes developers frustrated. Here are some tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you are not sure about something, don't make the pull request author do the research for you! You better do your research first and then push your idea forward. Alternatively, you can just suggest an optional change, if the developer is keen to investigate it.
&lt;/li&gt;
&lt;li&gt;People can interpret a single comment differently. It is very much important to know the person who wrote the code. Some people are eager to accept feedback but some people may not be and can take it personally. I think if you are not sure how a developer might react to your comment, go and talk to him/her instead. &lt;/li&gt;
&lt;li&gt;If you cannot reason about your proposed change, don't put a comment. People have different coding styles and unless there is a reason, like performance, code standard, clarity, etc. you better not ask people to change their code.
&lt;/li&gt;
&lt;li&gt;You should not only comment on things that you think are wrong. If you see a positive point, mention it, please. For example things like "I did not know you can use this function here" or "I think this class has a good test coverage, well done!".&lt;/li&gt;
&lt;li&gt;Choose your words wisely. For example instead of saying "Why did you use this function? Didn't you know it is slow?", you can say "Last time I used this function it was slow, was there a performance improvement in it recently?"&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What else can impact code reviews?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Sometimes external factors can impact code reviews, things like deadlines, or stakeholder pressure. A reviewer who is under delivery pressure may spend less time on code reviews. Also, he may skip asking for changes while reviewing others' code in order to not block the delivery. &lt;/li&gt;
&lt;li&gt;Lack of visibility for the whole team. If there is a large pull request and some people need to spend a considerable amount of time to review it, you better have some visibility in the team for that. For example, you can add a task to the backlog item only for the code review. In this way, the reviewer can spend a good time reviewing and everyone else can see it.&lt;/li&gt;
&lt;li&gt;I also noticed some people want to be nice to their colleagues, so they avoid putting comments on pull requests as much as they can. &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  How long should a code review take?
&lt;/h1&gt;

&lt;p&gt;I think it is important to make it clear to your team that code review is part of the development and they should take whatever time they need to. But make it visible, create a task for large pull requests so that everyone in the team can see the effort.&lt;/p&gt;

</description>
      <category>codereview</category>
    </item>
    <item>
      <title>Moving a legacy application to containers</title>
      <dc:creator>Bahman Nikkhahan</dc:creator>
      <pubDate>Mon, 11 Jan 2021 11:31:19 +0000</pubDate>
      <link>https://dev.to/bahmannik/porting-a-legacy-application-to-containers-1hl6</link>
      <guid>https://dev.to/bahmannik/porting-a-legacy-application-to-containers-1hl6</guid>
      <description>&lt;p&gt;In this post, I am going to talk about the areas that you need to be focused on when containerizing a legacy ASP.NET application. What are the gotchas? This post is based on my recent experience to containerize a legacy app. Hopefully, it can help you to not go through the pain that I went :) &lt;/p&gt;

&lt;p&gt;By legacy app I mean an app that you cannot easily convert it to .Net core or .Net 5. You need to use Windows Containers to run the app. &lt;/p&gt;

&lt;h2&gt;
  
  
  Configurations
&lt;/h2&gt;

&lt;p&gt;I talked about configuration builders in &lt;a href="https://dev.to/bahmannik/asp-net-application-in-window-containers-21dg"&gt;section 2&lt;/a&gt; of these series. It is important to know how can you inject configuration values to containers. &lt;/p&gt;

&lt;h2&gt;
  
  
  Local logs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Application logs
&lt;/h3&gt;

&lt;p&gt;If your application is logging on the local file system, you probably need to change this. The reason is whatever you save in the containers will be gone after you re-create your container or restart it. You can utilize cloud services like Azure Application Insight for this purpose. If cloud services are not your preferred option, then you may need to look for another way to save your logs persistently. &lt;/p&gt;

&lt;h3&gt;
  
  
  IIS logs
&lt;/h3&gt;

&lt;p&gt;As an ASP.Net developer, it is very common to check IIS logs every now or then for debugging purposes. You may still be able to do that in Windows containers, but as I mentioned above, there wouldn't be persistence storage in containers and you need to find a way to save or stream the logs somewhere else. Even if you don't want to have persistence storage for IIS logs, you still may want to access them somehow. &lt;/p&gt;

&lt;p&gt;You can log in into each container to view logs. However, a better way can be using Microsoft Log Monitor. &lt;a href="https://github.com/microsoft/windows-container-tools/tree/master/LogMonitor"&gt;Microsoft Log Monitor&lt;/a&gt; is a good tool to write IIS logs to container output. Then if you are using a container orchestration framework like Kubernetes, or you are using Azure Kubernetes Services, you should be able to view the logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local files
&lt;/h2&gt;

&lt;p&gt;If your application saves any file locally, it can even be a temporary file, then you may need to change this. Again the important reason here is lack of persistency. However, there could be other reasons like when your application is not ready to work behind a load balancer. &lt;/p&gt;

&lt;p&gt;Suppose you are using Kubernetes to manage your containers. Then Most probably, you will end up having multiple containers running your application. But your application can be unprepared for it. For example, it saves a temporary file on a container file system and saves the file name in the database. Then when the time comes to process the file, it is possible that it cannot find the file. Because the request could have been redirected to a different container which doesn't have the file locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Caching
&lt;/h2&gt;

&lt;p&gt;Depending on the type of caching mechanism which you use, you may need to revisit it. In our case, we had in-memory caching which we had to change. The reason to change it, however, wasn't just containerizing the app. We changed it because it wasn't easy to get it working in a load-balanced environment. Instead, we used Azure Redis Cache which was easy to work with (unless you find yourself stuck in &lt;a href="https://nickcraver.com/blog/2020/02/11/binding-redirects/"&gt;assembly redirects&lt;/a&gt;!). &lt;/p&gt;

&lt;h2&gt;
  
  
  ASP.Net Sessions (Web Forms)
&lt;/h2&gt;

&lt;p&gt;Similar to caching, you may need to check ASP.NET sessions if you are using ASP.NET Web forms. We have some legacy web form applications in our conatiners and had to make sure ASP.NET sessions work fine when more than one instance of the application (containers) exist. Again we used Azure Redis Cache for this purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Third-party integrations
&lt;/h2&gt;

&lt;p&gt;Most of the times legacy applications have legacy integrations too. If your application is only talking to other applications using APIs, you are in luck. Otherwise, you need to check them out. &lt;/p&gt;

&lt;p&gt;For example in our case, our application is integrated with multiple systems using different mechanisms. For example, we were using a third party C# library which needs a license file to exist on the server. This license file should be generated on the server when we set it up.  This could work very well in a non-containerized environment. However, it is not a container friendly approach. Because containers have a short life span and we didn't want to generate licenses for each container that we spin up. Luckily, we were able to remove this dependency.&lt;/p&gt;

&lt;p&gt;Another example was the case of using a certificate to communicate with a third party application. Our support team had to install this certificate on our web servers. Again this doesn't work very well with the containers, instead, we put the certificate in Azure Key Vault and used it from there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use of other windows components other than IIS
&lt;/h2&gt;

&lt;p&gt;If you are only using IIS on your servers, you should be able to get it to work easily in a Windows container. You can inject the application's configuration values using configuration builders as I mentioned above. However, if you are using different windows components you need to think about alternatives.&lt;/p&gt;

&lt;p&gt;We were using two particular Windows components which caused some issues for us. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MSMQ&lt;/strong&gt;: MSMQ is a queuing service in Windows which can be used to create and manage tasks in queues. This particular Windows component exists in the base Windows container image which we were using. The problem was however, it didn't make sense to have queues in each container when we could have a couple of them running the same version of the app. After some investigation, we realized this is no longer needed and we could achieve the same thing by maintaining a single table in the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows Task Scheduler&lt;/strong&gt;: We were using Windows Task Scheduler to run an application periodically. If you want to use the same thing in a container, there is a bit of issue to inject your configuration values into the app using config builders (check &lt;a href="https://github.com/aspnet/MicrosoftConfigurationBuilders/issues/25"&gt;this&lt;/a&gt;). Instead, we created a separate container for this particular application and used Kubernetes &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/"&gt;Cron Jobs&lt;/a&gt; to run the container periodically. &lt;/p&gt;

&lt;h2&gt;
  
  
  Moving to cloud?
&lt;/h2&gt;

&lt;p&gt;If you are containerizing your application, it is likely that you are going to host your application in the cloud. We used Azure Kubernetes Service (AKS) to host our cluster. &lt;/p&gt;

&lt;p&gt;When you move from on-premise systems to cloud, you can face some extra challenges. For example, we had some challenges around timezones. Our application used to work on servers which were using local timezone. On the cloud, however, everything was on UTC. So we ended up with some broken areas which we had to fix. One example in our c# code was when we were using DateTime.Now() method. It returns date and time in server timezone. This means we used to get local timezone and now we are getting UTC. Therefore we had to make sure this doesn't break anything and if it does, fix it.    &lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In summary, containerising a legacy application could be challenging if your tech stack is old and there are many unknowns. I suggest doing a proper analysis of the items which I mentioned here, before going with containers. For example, ask yourself about the logging requirements of your app or the way that you integrate with other systems, what sort of cashing mechanism do you require, etc. These questions can help you identify and manage any possible risk on your way.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>windowscontainer</category>
      <category>aspnet</category>
      <category>legacy</category>
    </item>
    <item>
      <title>ASP.NET application in Window Containers</title>
      <dc:creator>Bahman Nikkhahan</dc:creator>
      <pubDate>Thu, 03 Dec 2020 11:49:10 +0000</pubDate>
      <link>https://dev.to/bahmannik/asp-net-application-in-window-containers-21dg</link>
      <guid>https://dev.to/bahmannik/asp-net-application-in-window-containers-21dg</guid>
      <description>&lt;p&gt;Suppose you have a legacy app that you want to containerize, or for some reason, you are using .Net Framework and not .net core (or .net 5). Then you need to use Windows containers. In this article, I am going to start from scratch and show you the steps. Let's begin!&lt;/p&gt;

&lt;p&gt;The source code for this article is available &lt;a href="https://github.com/bahman616/WinContainers"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to run this application check the README file in the above repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build your first Windows container
&lt;/h2&gt;

&lt;p&gt;Let's start with the dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# escape=`&lt;/span&gt;

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS build&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;nuget restore&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;msbuild /p:Configuration&lt;span class="o"&gt;=&lt;/span&gt;Debug

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /inetpub/wwwroot&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --from=build /app/SampleWebsite/. ./&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a simple dockerfile which is building our super simple app! It starts with the windows server base image. When it comes to choosing your base image, you have multiple options:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Windows Server Core&lt;/strong&gt;: This is the one which you may need to build your ASP.NET Framework application. It just has what you need not more than that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Nano Server&lt;/strong&gt;: This base image can be used for .Net Core application and it is smaller than Windows Server Core image in size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Windows&lt;/strong&gt;: Entire Windows!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Windows IoT Core&lt;/strong&gt;: Suitable for IoT devices.&lt;/p&gt;

&lt;p&gt;If you want to know more about these base images, you can read &lt;a href="https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have selected .Net Framework 4.8 sdk which is based on Windows Server Core 2019 Long-Term Servicing Channel (ltsc). Then I labelled this step as "build".&lt;/p&gt;

&lt;p&gt;The next step in the docker file is moving to a folder called 'app'. Then we copy everything there.&lt;/p&gt;

&lt;p&gt;Restoring nuget packages and building the application are the next steps.&lt;/p&gt;

&lt;p&gt;In the final section of the dockerfile, we use ASP.NET base image in order to host our website using IIS. Note that behind the scenes we are using the same base Windows images in this step and the first line of the dockerfile which is &lt;a href="https://hub.docker.com/_/microsoft-dotnet-framework-runtime/"&gt;.Net framework runtime&lt;/a&gt;. You can check the source code of .Net base images from &lt;a href="https://github.com/microsoft/dotnet-framework-docker/tree/master/src"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration Builders
&lt;/h2&gt;

&lt;p&gt;A typical .Net Framework website has a web.config file that includes all the configuration values. When you deploy your website, you transform/update the configuration values for your environment. This is not going to work for containers. Because when you build your container image, you bake configuration values in it. You should be able to inject environment variables in containers when you run them. Then your application should be able to access those environment variables in order to get its configuration values. This is why you need configuration builders.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/aspnet/config-builder"&gt;Configuration Builders&lt;/a&gt; are some nuget packages that you can install on your .Net app (&amp;gt;= 4.7.1) and help your app to get its required configuration values from environment variables, Azure Key Vault, etc. &lt;/p&gt;

&lt;p&gt;When you install a configuration builder nuget package, it changes some settings in your web.config. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;configSections&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"configBuilders"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"&lt;/span&gt; &lt;span class="na"&gt;restartOnExternalChanges=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt; &lt;span class="na"&gt;requirePermission=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/configSections&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;configBuilders&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;builders&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Environment"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&amp;lt;/builders&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/configBuilders&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;appSettings&lt;/span&gt; &lt;span class="na"&gt;configBuilders=&lt;/span&gt;&lt;span class="s"&gt;"Environment"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"webpages:Version"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"3.0.0.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"webpages:Enabled"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"ClientValidationEnabled"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"UnobtrusiveJavaScriptEnabled"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;add&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;"Message"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"The app is not running in a container"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/appSettings&amp;gt;&lt;/span&gt;
...
&lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the above code, there is a new "configBuilders" section on the web.config. We only have one entry in this section and that is "Microsoft.Configuration.ConfigurationBuilders.Environment". Because we want to pass configuration values as environment variables to our containers, we only need this one entry in  section.&lt;/p&gt;

&lt;p&gt;Then all we need to do is specifying the name of the configBuilders on appSettings. Note that config builders have some modes and the default mode can only be used on appSettings and connectionStrings section because they can have key-value pairs. If you need to change a different area on web.config, then you need to use a different mode for config builders.&lt;/p&gt;

&lt;p&gt;In windows container, there is a limitation which is important to note. This is from &lt;a href="https://docs.microsoft.com/en-us/aspnet/config-builder"&gt;Microsoft docs&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In a Windows container environment, variables set at run time are only injected into the EntryPoint process environment. Apps that run as a service or a non-EntryPoint process do not pick up these variables unless they are otherwise injected through a mechanism in the container. For IIS/ASP.NET-based containers, the current version of ServiceMonitor.exe handles this in the DefaultAppPool only. Other Windows-based container variants may need to develop their own injection mechanism for non-EntryPoint processes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Running your container
&lt;/h2&gt;

&lt;p&gt;I created a script in the Github repo which you can use to run the container. The instructions about how to use the script, are in the &lt;a href="https://github.com/bahman616/WinContainers"&gt;README file&lt;/a&gt; of the repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging
&lt;/h2&gt;

&lt;p&gt;In order to debug your windows container in Visual Studio, make sure you have updated your visual studio to the latest version as there have been many improvements around windows containers at the time of writing this post.&lt;/p&gt;

&lt;p&gt;The easiest way to debug your container is using the container window in Visual Studio which is available from View menu =&amp;gt; Other windows.&lt;/p&gt;

&lt;p&gt;You should be able to see all running containers on your machine and check the environment variables, logs, ports, and even files on a container:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vv4x6BLJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xaudc5bx80hbc3mz0zcc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vv4x6BLJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xaudc5bx80hbc3mz0zcc.png" alt="windows containers debug"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also run commands against the running container or attach your debugger to it using the same containers windows. You can get more information about containers window in Visual Studio from &lt;a href="https://docs.microsoft.com/en-us/visualstudio/containers/view-and-diagnose-containers?view=vs-2019"&gt;Here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What should I know about windows container?</title>
      <dc:creator>Bahman Nikkhahan</dc:creator>
      <pubDate>Thu, 03 Dec 2020 11:48:52 +0000</pubDate>
      <link>https://dev.to/bahmannik/what-should-i-know-about-windows-container-g9n</link>
      <guid>https://dev.to/bahmannik/what-should-i-know-about-windows-container-g9n</guid>
      <description>&lt;p&gt;In this post, I assume you have a basic understanding of containers.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why windows containers
&lt;/h1&gt;

&lt;p&gt;I think the first question that you need to ask yourself is why do you want to use Windows containers? Containers are a better fit for Linux compared to Windows and not every feature that you expect to use in Linux containers exist in Windows containers (at the time of writing this post). However, there could be instances that you have an application that needs Windows to run and you still want to benefit from containerisation. &lt;/p&gt;

&lt;p&gt;If you made up your mind to use Windows containers, here are the things which you need to know:&lt;/p&gt;

&lt;h1&gt;
  
  
  Isolation Modes
&lt;/h1&gt;

&lt;p&gt;If this is the first time that you are going to work with Windows containers, you need to know about their isolation modes. Windows containers have 2 isolation modes, "Process" and "Hyper-V". You can read more about them &lt;a href="https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container"&gt;here&lt;/a&gt;. But in short, process isolation mode is useful when your containers are going to share the same host OS. However, Hyper-V isolation mode is useful when you want your containers to have their own virtual machine and their own OS. Hyper-V isolation mode can give you a more secure option and also more flexibility when it comes to choosing the host OS version, but it &lt;a href="https://cevo.com.au/post/windows-containers-on-ecs/"&gt;could affect the performance&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One other thing to consider is that not all cloud providers support Hyper-V isolation modes. For example, Azure and AWS don't support it yet (at the time of writing this post).&lt;/p&gt;

&lt;h1&gt;
  
  
  Base Images
&lt;/h1&gt;

&lt;p&gt;There are &lt;a href="https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images"&gt;multiple windows images&lt;/a&gt; that you can use to build your windows container. If you have a .Net framework application which you want to containerise, you probably want to choose &lt;a href="https://hub.docker.com/_/microsoft-windows-servercore"&gt;Windows Server Core base image&lt;/a&gt;. &lt;br&gt;
If you want to use a different build of Windows base image for your host machine and containers, you should first check &lt;a href="https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-20H2%2Cwindows-10-20H2"&gt;this&lt;/a&gt; page out. If you are going to choose process isolation mode, you have limited flexibility when it comes to Windows builds.&lt;/p&gt;

&lt;h1&gt;
  
  
  Windows containers limitation
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Windows containers are introduced with Windows Server 2016. So it is not available for older versions of Windows.&lt;/li&gt;
&lt;li&gt;Version compatibility is another limitation which I mentioned above.&lt;/li&gt;
&lt;li&gt;At the time of writing this post, cloud providers are catching up on Windows containers and their offerings are not as mature as their Linux containers&lt;/li&gt;
&lt;li&gt;There is better community support on Linux containers compared to Windows containers.&lt;/li&gt;
&lt;li&gt;If you use container orchestration tools like Kubernetes, you'll need to have Linux vms in your setup as well, so you'll end up with a hybrid approach.&lt;/li&gt;
&lt;li&gt;Windows base images are bigger in size compared to the Linux ones.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>DbUp and Helm chart hooks</title>
      <dc:creator>Bahman Nikkhahan</dc:creator>
      <pubDate>Sat, 11 Jul 2020 12:26:04 +0000</pubDate>
      <link>https://dev.to/bahmannik/dbup-and-helm-chart-hooks-4gbn</link>
      <guid>https://dev.to/bahmannik/dbup-and-helm-chart-hooks-4gbn</guid>
      <description>&lt;p&gt;I was recently working on a solution to run DbUp scripts in a Kubernetes cluster. &lt;/p&gt;

&lt;p&gt;A little bit of background information: We have an ASP.Net framework application which uses a SQL Server database. To upgrade the database with the latest changes, we use DbUp. We have a console app which uses DbUp to upgrade the database before each release.&lt;/p&gt;

&lt;p&gt;Our ASP.Net application is in Azure Kubernetes Services (AKS) in a hybrid cluster. We have Linux and Windows nodes in the cluster. The application itself is in Windows nodes but we need Linux nodes to run Helm, Nginx ingress controller and any other Linux based tools which we may require.&lt;/p&gt;

&lt;p&gt;To manage our application releases, we use helm charts. If you are not familiar with helm chart, you probably need to read about it first and continue reading this article :), but in short, it is essentially a simple way to manage Kubernetes packages. &lt;a href="https://helm.sh/"&gt;Here is the link to get more information&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Now get back to the problem which we wanted to solve. We want to run the DbUp console app just before we release our application using helm charts. One way could be adding a separate step in our release pipeline to run DbUp just before releasing the ASP.Net app. However, we wanted to have everything in helm if we could, therefore a better way is using helm chart hooks. &lt;/p&gt;

&lt;p&gt;As mentioned &lt;a href="https://helm.sh/docs/topics/charts_hooks/"&gt;here&lt;/a&gt;:&lt;br&gt;
"Helm provides a hook mechanism to allow chart developers to intervene at certain points in a release's life cycle." What it means is you can ask Helm to let you jump in and run something at a certain point. For example before a release or after a release. That gave me the idea that helm chart hooks could be great for our use case. So all I needed was adding a Kubernetes job and hook it up to helm pre-install and pre-upgrade hooks. In this way, I could make sure that our DbUp code gets run before any release. If for any reason this step fails, the release doesn't even start.&lt;/p&gt;

&lt;p&gt;Here is what the job template which I used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{- if .Values.dbup.upgradeDatabase }}
apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ .Release.Name }}-dbup"
  labels:
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: "{{ .Release.Name }}-dbup"
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  annotations:
    "helm.sh/hook": pre-install, pre-upgrade
    "helm.sh/hook-weight": "-5"
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
spec:
  template:
    metadata:
      name: "{{ .Release.Name }}-dbup"
      labels:
        app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
        app.kubernetes.io/instance: "{{ .Release.Name }}-dbup"
        helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    spec:
      restartPolicy: Never
      containers:
      - name: dbup
        image: "{{ .Values.imageName }}"
        env:
        - name: "ConnectionString"
          valueFrom:
            secretKeyRef:
              key:  ConnectionString
              name: "{{ .Release.Name }}-dbup"
      nodeSelector:
        "beta.kubernetes.io/os": windows 
{{- end }}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see from the above code I need to create a secret to keeps my connectionstring. Here it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{- if .Values.dbup.upgradeDatabase }}
apiVersion: v1
kind: Secret
metadata:
  name: "{{ .Release.Name }}-dbup"
  annotations:
    "helm.sh/hook": pre-install, pre-upgrade
    "helm.sh/hook-weight": "-10"    
     "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
data:
  ConnectionString: {{ .Values.connectionString | b64enc }}
  {{- end }}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I use "dbup.upgradeDatabase" flag in helm values files as a way to trigger the database upgrade.&lt;/p&gt;

&lt;p&gt;Note that you can specify a weight for helm chart hooks. In this way you let Helm know which resource to create first. The weights will be ordered ascending. That's why I set -10 for the secret and -5 for the job. Because I want to make sure Helm will create the secret before the job.&lt;/p&gt;

&lt;p&gt;These resources will be created before any release (by specifying helm.sh/hook) and they will be destroyed after release succeeds or fails (by specifying helm.sh/hook-delete-policy). &lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to be successful in Certified Kubernetes Application Developer (CKAD) exam </title>
      <dc:creator>Bahman Nikkhahan</dc:creator>
      <pubDate>Mon, 02 Mar 2020 11:15:12 +0000</pubDate>
      <link>https://dev.to/bahmannik/how-to-be-successful-in-certified-kubernetes-application-developer-ckad-exam-519i</link>
      <guid>https://dev.to/bahmannik/how-to-be-successful-in-certified-kubernetes-application-developer-ckad-exam-519i</guid>
      <description>&lt;p&gt;Do you wish to challenge yourself to learn Kubernetes in a structured way? Or do you want to be known as a Kubernetes developer? Or you just want to add a Kubernetes certificate to your achievements? If your answer to any of these question is yes, please keep reading :) &lt;/p&gt;

&lt;h1&gt;
  
  
  What is CKAD?
&lt;/h1&gt;

&lt;p&gt;CKAD Developed by the Cloud Native Computing Foundation (CNCF), in collaboration with The Linux Foundation. The Cloud Native Computing Foundation (CNCF) is a Linux Foundation project that was founded in 2015 to help advance container technology and align the tech industry around its evolution. It was announced alongside Kubernetes 1.0 &lt;a href="https://en.wikipedia.org/wiki/Cloud_Native_Computing_Foundation"&gt;[1]&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;This is the official CKAD exam explanation on Cloud Native Computing Foundation website &lt;a href="https://www.cncf.io/certification/ckad/"&gt;[2]&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;“The Certified Kubernetes Application Developer exam certifies that users can design, build, configure, and expose cloud-native applications for Kubernetes. A Certified Kubernetes Application Developer can define application resources and use core primitives to build, monitor, and troubleshoot scalable applications and tools in Kubernetes”.&lt;/p&gt;

&lt;p&gt;According to CNCF website, CKAD's curriculum is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;13% – Core Concepts&lt;/li&gt;
&lt;li&gt;18% – Configuration&lt;/li&gt;
&lt;li&gt;10% – Multi-Container Pods&lt;/li&gt;
&lt;li&gt;18% – Observability&lt;/li&gt;
&lt;li&gt;20% – Pod Design&lt;/li&gt;
&lt;li&gt;13% – Services &amp;amp; Networking&lt;/li&gt;
&lt;li&gt;8% – State Persistence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The exam costs 300 USD at the moment which is not cheap but you may consider it as a very good investment for your future career progression. Apart from this, many companies are happy to reimburse the cost for their employees. &lt;/p&gt;

&lt;h1&gt;
  
  
  Booking the exam
&lt;/h1&gt;

&lt;p&gt;After you've made your decision to book this exam and you paid for it, you need to schedule a day and time. A couple of hints when booking the exam:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;b&gt;Book it for the most productive time of your day.&lt;/b&gt; The exam takes 2 hours and you need to be very focused and efficient when taking it. Don't book the exam for a time that you won't be your best &lt;/li&gt;
&lt;li&gt; &lt;b&gt;Don’t book your exam on a day that you have a busy schedule.&lt;/b&gt; Ideally, you don't want to book the exam for a day that you are supposed to do many different tasks and will be tired before the exam. &lt;/li&gt;
&lt;li&gt; &lt;b&gt;Allow extra time for technical challenges&lt;/b&gt; I learnt this in a hard way! The first time that I took the exam I had to go out for another matter around 45 minutes after the exam. I thought I had enough time buffer reserved after the exam. However, when the proctor released the exam for me, it didn't work properly on my browser and we tried many things to fix it. Eventually, the exam loaded for me after an hour and 20 minutes on a different browser. So I was not able to attend the whole 2 hours and I failed the exam. You need to make sure your computer meets the exam requirements. After doing that, the exam website may work for you. I checked the system requirements beforehand but still faced different issues on the day. You also don't want to use a corporate laptop on a network that may be restricted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Exam Format
&lt;/h1&gt;

&lt;p&gt;The exam includes 19 questions with different weight out of 100%. You see the question weight on top of each question. The questions are not multiple choice and you actually need to Work on a Linux terminal to meet the questions objectives.&lt;/p&gt;

&lt;p&gt;Each question has multiple objective and you need to meet the objectives as much as you can. I am not certain if you get points for questions which you have done partially, but I think this is the case. Otherwise, my grade would have been lower than what I actually received :D .&lt;/p&gt;

&lt;h1&gt;
  
  
  Exam day
&lt;/h1&gt;

&lt;p&gt;Because the exam is online, a proctor is going to monitor you all the time. You will be asked to have only two tabs open in Google Chrome, one for the exam and another one for Kubernetes docs. You are not allowed to open any other website or application. You also need to share all of your screens with the proctor.&lt;/p&gt;

&lt;p&gt;You need to sit in a quiet room, all doors should be closed, and no one should enter the room. You need to show a 360 degrees view of the room to the proctor.&lt;br&gt;
You can’t eat during the exam, you are only allowed to drink from a clear water bottle.&lt;/p&gt;

&lt;p&gt;You should have a clean desk with no extra electronic devices or papers on. I was asked to remove the papers from the printer. I was also asked to take out my smartwatch.&lt;/p&gt;

&lt;p&gt;Make sure you stand up and stretch your body before the exam because you need to sit down for 2 hours. During the exam, you can ask for breaks but the timer won't stop.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources:
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Study the exam handbook first
&lt;/h2&gt;

&lt;p&gt;You'll get whatever you need to know about the exam by studying the handbook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read others’ story about how to prepare yourself
&lt;/h2&gt;

&lt;p&gt;There are some blogs about how to be successful in CKAD exam (apart from this!). I found them very useful to get some tips for the exam. Here some of them:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@ameenalam202/tips-for-successful-certified-kubernetes-application-developer-ckad-exam-preparation-efaed88500fe"&gt;Tips for Successful Certified Kubernetes Application Developer (CKAD) Exam Preparation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/@nassim.kebbani/how-to-beat-kubernetes-ckad-certification-c84bff8d61b1"&gt;How to beat Kubernetes CKAD certification&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/scriptautomate/tips-for-the-certified-kubernetes-exams-cka-and-ckad-49mn"&gt;Tips for The Certified Kubernetes Exams: CKA and CKAD in 2020&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Read Kubernetes docs
&lt;/h2&gt;

&lt;p&gt;Obviously the best place to read about Kubernetes is its own official website. However, it could be a little bit overwhelming if you don't have that much experience working with Kubernetes. Maybe going through a course would be a better start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Online courses
&lt;/h2&gt;

&lt;p&gt;There are so many courses online about Kubernetes. I personally found Linux Academy very useful. The main reason is their labs. In each section of the course, there are labs that everything has been set up for you to be able to practice. I found their questions very similar to the actual exam (even a little bit harder). &lt;/p&gt;

&lt;h2&gt;
  
  
  Books
&lt;/h2&gt;

&lt;p&gt;There are books available for Kubernetes if you want to learn it in deep. I am sure you can find a few by a simple search over the web. &lt;/p&gt;

&lt;h2&gt;
  
  
  Practice
&lt;/h2&gt;

&lt;p&gt;In order to be successful in CKAD exam, you need to practice. You can find sample questions that you can use:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dgkanatsios/CKAD-exercises"&gt;CKAD Exercises&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codeburst.io/kubernetes-ckad-weekly-challenges-overview-and-tips-7282b36a2681"&gt;Kubernetes CKAD Example Questions Practical Challenge Series&lt;/a&gt;&lt;br&gt;
&lt;a href="https://matthewpalmer.net/kubernetes-app-developer/articles/ckad-practice-exam.html"&gt;Practice Exam for Certified Kubernetes Application Developer (CKAD) Certification&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Exam tips:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Time is critical, you need to be fast, efficient and get yourself familiar with the shortcuts.&lt;/li&gt;
&lt;li&gt;Don’t spend a huge amount of time for a question that has only 2% points.&lt;/li&gt;
&lt;li&gt;If you think you are stuck on a question and you feel you spent more time than you should, skip it.&lt;/li&gt;
&lt;li&gt;Use note to take note of questions which you skipped 
&lt;/li&gt;
&lt;li&gt;Try to meet questions objectives. Even if you haven't answered the entire question.&lt;/li&gt;
&lt;li&gt;The first hour is critical. I went through 70% of the questions in the first hour. Your efficiency may drop in the second hour.&lt;/li&gt;
&lt;li&gt;You have one free retake, so it is okay if you fail in the first run, just try to reflect on your mistakes and practice on some areas that you can avoid.&lt;/li&gt;
&lt;li&gt;Typing speed can be helpful, but if you are like me and not so fast in typing, you can rely on kubectl auto complete. Using autocomplete also helps you to validate your commands. &lt;/li&gt;
&lt;li&gt;Make sure you practice against the version of Kubernetes that you are going to use on the exam day.&lt;/li&gt;
&lt;li&gt;Make sure you are on the right cluster and namespace.&lt;/li&gt;
&lt;li&gt;Don't bother testing everything if you are confident about your solution and the object was created successfully and is running (unless you have extra time).&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Use Kubernetes docs
&lt;/h1&gt;

&lt;p&gt;You are allowed to open Kubernetes documents during the exam. This can be very useful, but you need to make sure you are using the docs efficiently. &lt;br&gt;
Try to make yourself familiar with different pages and how the search functionality works. For example, if you want to search how to use a configMap withing a pod, you may want to search for 'configMap' keyword, but you are probably going to look for a page in the search results which talks about volumes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/"&gt;Kubectl Cheat Sheet page&lt;/a&gt; is your friend. There are many useful tips about using kubectl. Try to go through that page and read it through. I would suggest to open this page at the very start of your exam and copy and paste the commands to activate auto complete in kubectl (if you don't remember the commands). &lt;/p&gt;

&lt;p&gt;Try to use your browser history to navigate between the pages which you have already visited. Some people suggest bookmarking the important pages before the exam, but I was not sure if that'll be cheating or not. I didn't do it myself.&lt;/p&gt;

&lt;p&gt;Having all said about Kubernetes docs, I should say you try to avoid opening any documentation and probably want to spend your time on the actual exam. Therefore you may want to restrict yourself to kubectl commands and helps.&lt;/p&gt;

&lt;h1&gt;
  
  
  More important tips:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
Make yourself familiar with basic Linux terminal commands, things like how to log in as root, view, edit, and copy files. Don't forget to push the right key combinations to copy-paste in Linux :)
&lt;/li&gt;
&lt;li&gt;
Make yourself familiar with basic commands in vim, how to open, edit, save, highlight, undo, etc. 
&lt;/li&gt;
&lt;li&gt;
You can keep some useful command to create some key objects in the notepad. For example, the command to create a pod.
&lt;/li&gt;
&lt;li&gt;
In order to save typing time you can use &lt;b&gt;'alias k=kubectl'&lt;/b&gt; and use 'k' instead of 'kubectl' afterwards. If you want autocomplete works with 'k' you need to run this: &lt;b&gt;'complete -F __start_kubectl k'&lt;/b&gt;
&lt;/li&gt;
&lt;li&gt;
You can use &lt;b&gt;'kubectl create'&lt;/b&gt; to create many Kubernetes primitives like configMap, secret, service, etc. You can tick some questions off easily by using &lt;b&gt;'kubectl create'&lt;/b&gt;. For example, if you are asked to create a secret with key1=value1 you can easily do it by running this command:
&lt;b&gt;'kubectl create secret generic my-secret --from-literal=key1=value1'
&lt;/b&gt;
You don't need to spend a lot of time to write the object description using YAML format. Even if there is something that you cannot do with the command line, you can still generate a basic YAML file and edit and run it. In order to do that, you can add &lt;b&gt;'--dry-run o yaml &amp;gt; myfile.yaml'&lt;/b&gt; to the above command. This won't create the object and will write the object description in a YAML file. Then you can edit the file and run it using &lt;b&gt;'kubectl apply -f myfile.yaml'&lt;/b&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;'kubectl run'&lt;/b&gt; is another useful command. You can use it to create pods, deployments, jobs, cronjobs, etc. The good thing about this command is you can easily set container image, arguments, commands, environment variables and etc. If you run &lt;b&gt;'kubectl run'&lt;/b&gt; you get some samples about how to use it. For example, in order to create a pod, you need to set --restart=Never flag, otherwise it'll create a deployment for you. Note that there would be some changes in this command in the near future and these options may not be available then. Again similar to &lt;b&gt;'kubectl create'&lt;/b&gt; you can add &lt;b&gt;'--dry-run'&lt;/b&gt; and &lt;b&gt;'-o yaml &amp;gt; pod.yaml'&lt;/b&gt; to output the object definition in a YAML file, edit it and run it using &lt;b&gt;'kubectl apply -f pod.yaml'&lt;/b&gt;
&lt;/li&gt;
&lt;li&gt;
If you need to edit a YAML definition of an object but not sure about the syntax, you can use &lt;b&gt;'kubectl explain'&lt;/b&gt;. For example, suppose you don't remember the structure for readinessProbe in pod but you remember it is under spec.container. In that case you can use &lt;b&gt;'kubectl explain pod.spec.containers'&lt;/b&gt; to get more information about options which are available under 'containers'. You can also use '--recursive' to get a better view. Try &lt;b&gt;'kubectl explain pod.spec.containers.readinessProbe --recursive'&lt;/b&gt; yourself to see what is available for readinessProbe.
&lt;/li&gt;
&lt;li&gt;One last thing is about taking backup before wiping out an object. Because everything is prepared for you to work on, if you delete an object and need it, later on, you can't restore it. Make sure you save the specifications of the object before deleting it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this article can help you with your CKAD exam. If you have any question/feedback, please feel free to put a comment here or contact me directly.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>ckad</category>
    </item>
  </channel>
</rss>
