Windows Archives - TEKSpace Blog https://blog.tekspace.io/tag/windows/ Tech tutorials for Linux, Kubernetes, PowerShell, and Azure Wed, 30 Aug 2023 15:20:21 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://blog.tekspace.io/wp-content/uploads/2023/09/cropped-Tekspace-logo-icon-32x32.png Windows Archives - TEKSpace Blog https://blog.tekspace.io/tag/windows/ 32 32 Top 100 Essential PowerShell Commands: Your Must-Know Cheat Sheet https://blog.tekspace.io/top-100-essential-powershell-commands-your-must-know-cheat-sheet/ https://blog.tekspace.io/top-100-essential-powershell-commands-your-must-know-cheat-sheet/#respond Wed, 30 Aug 2023 01:14:54 +0000 https://blog.tekspace.io/?p=1416 PowerShell, an integral component of Windows operating systems, has revolutionized the way administrators and users interact with their systems by offering a robust command-line environment. At its core, PowerShell empowers users to leverage a comprehensive set of commands, often referred to as cmdlets, to perform a wide array of tasks. From basic PowerShell commands like

The post Top 100 Essential PowerShell Commands: Your Must-Know Cheat Sheet appeared first on TEKSpace Blog.

]]>
PowerShell, an integral component of Windows operating systems, has revolutionized the way administrators and users interact with their systems by offering a robust command-line environment. At its core, PowerShell empowers users to leverage a comprehensive set of commands, often referred to as cmdlets, to perform a wide array of tasks. From basic PowerShell commands like ‘Get-ChildItem’ for navigating files and directories to more complex operations involving system management and automation, this environment has become an indispensable tool for Windows users.

Unlike the traditional command-line interface (CLI) like the Command Prompt, PowerShell’s flexibility comes from its ability to work with objects and data streams. By utilizing cmdlets, users can perform operations on data objects directly, making it easier to manipulate and manage information. Moreover, PowerShell offers the capability to create and execute scripts, enabling users to automate intricate processes and repetitive tasks efficiently.

However, before harnessing the full potential of PowerShell commands and scripts, one must navigate the concept of execution policies. These policies dictate the level of trust PowerShell places in various scripts and configurations. Understanding and managing these policies ensures a secure and controlled environment for executing scripts and commands. Whether it’s for automating routine tasks, managing systems at scale, or extracting insights from data, Windows PowerShell serves as an indispensable platform that empowers users to achieve efficient and streamlined operations within the Windows environment.

Here are the top 100 PowerShell commands to use and everyone should master:

NoCommandDescriptionExample
1Get-HelpDisplays information about PowerShell commands.Get-Help Get-Process
2Get-CommandLists all available commands in PowerShell.Get-Command
3Get-ChildItemRetrieves files and folders in a specified location.Get-ChildItem C:\
4Set-LocationChanges the current working directory.Set-Location D:\
5Get-ContentReads the content of a file.Get-Content file.txt
6Out-FileWrites output to a file.Get-Process | Out-File processes.txt
7Write-OutputSends output to the pipeline.Write-Output “Hello, PowerShell!”
8Select-ObjectSelects specific properties of objects.Get-Process | Select-Object Name, CPU
9Where-ObjectFilters objects based on specified criteria.Get-Service | Where-Object { $_.Status -eq “Running” }
10ForEach-ObjectPerforms an operation on each object in a pipeline.1..5 | ForEach-Object { $_ * 2 }
11Format-TableFormats output as a table.Get-Process | Format-Table -AutoSize
12Sort-ObjectSorts objects by specified properties.Get-Service | Sort-Object Status
13Measure-ObjectCalculates properties of objects (e.g., length).“Hello, PowerShell!” | Measure-Object -Character
14New-ItemCreates a new item (file, folder, etc.).New-Item newfile.txt -ItemType File
15Remove-ItemDeletes an item.Remove-Item file.txt
16Copy-ItemCopies files or folders.Copy-Item file.txt newfolder
17Rename-ItemRenames an item.Rename-Item file.txt newname.txt
18Test-PathChecks if a file or folder exists.Test-Path file.txt
19Get-ServiceRetrieves services.Get-Service
20Start-ServiceStarts a service.Start-Service serviceName
21Stop-ServiceStops a service.Stop-Service serviceName
22Restart-ServiceRestarts a service.Restart-Service serviceName
23Get-ProcessRetrieves processes.Get-Process
24Start-ProcessStarts a process.Start-Process notepad
25Stop-ProcessStops a process.Stop-Process -Name notepad
26Get-WmiObjectRetrieves management information using WMI.Get-WmiObject Win32_ComputerSystem
27Get-EventLogRetrieves event log data.Get-EventLog -LogName Application
28Get-ContentReads the content of a file.Get-Content file.txt
29Set-ContentWrites content to a file.Set-Content file.txt “New content”
30Test-ConnectionTests network connectivity.Test-Connection google.com
31Test-NetConnectionComprehensive network connectivity test.Test-NetConnection google.com
32Invoke-WebRequestPerforms HTTP requests.Invoke-WebRequest https://www.example.com
33ConvertTo-JsonConverts objects to JSON format.Get-Process | ConvertTo-Json
34ConvertFrom-JsonConverts JSON data to objects.‘{“Name”:”John”,”Age”:30}’ | ConvertFrom-Json
35Get-DateRetrieves the current date and time.Get-Date
36New-ObjectCreates a new object.New-Object PSObject
37Get-ContentReads the content of a file.Get-Content file.txt
38Set-ContentWrites content to a file.Set-Content file.txt “New content”
39Invoke-ExpressionInvokes a command or expression as if by typing it.Invoke-Expression ‘Get-Process’
40Write-HostDisplays messages to the console.Write-Host “Hello, PowerShell!”
41Out-GridViewDisplays data in a graphical table.Get-Process | Out-GridView
42Out-PrinterSends output to a printer.Get-Process | Out-Printer
43Get-HostRetrieves host information.Get-Host
44Get-ModuleLists the modules imported into the session.Get-Module
45Import-ModuleImports a module into the session.Import-Module MyModule
46Remove-ModuleRemoves imported modules from the session.Remove-Module MyModule
47Get-CommandLists available commands.Get-Command
48Get-AliasLists aliases.Get-Alias
49Set-AliasCreates or changes aliases.Set-Alias np Notepad
50Clear-HostClears the console screen.Clear-Host
51Clear-ContentClears the content of a file.Clear-Content file.txt
52Clear-ItemRemoves the content of an item.Clear-Item file.txt
53Clear-VariableRemoves variable values.Clear-Variable varName
54Clear-RecycleBinClears the contents of the Recycle Bin.Clear-RecycleBin
55Compare-ObjectCompares two sets of objects.Compare-Object object1 object2
56Complete-TransactionCompletes a transaction.Complete-Transaction
57ConvertFrom-CsvConverts CSV-formatted data to objects.Get-Content data.csv | ConvertFrom-Csv
58ConvertTo-CsvConverts objects to CSV format.Get-Process | ConvertTo-Csv -NoTypeInformation
59Debug-ProcessDebugs a process.Debug-Process -Id processId
60Disable-PSBreakpointDisables breakpoints.Disable-PSBreakpoint -Id breakpointId
61Enable-PSBreakpointEnables breakpoints.Enable-PSBreakpoint -Id breakpointId
62ExitExits the current session.Exit
63Export-AliasExports aliases to a file.Get-Alias | Export-Alias -Path aliases.txt
64Export-ClixmlExports objects to an XML file.Get-Process | Export-Clixml process.xml
65Export-CsvExports objects to a CSV file.Get-Process | Export-Csv process.csv
66ForEach-ObjectIterates through objects in the pipeline.1..5 | ForEach-Object { $_ * 2 }
67Format-CustomFormats output using a customized view.Get-Process | Format-Custom
68Format-HexFormats data as hexadecimal values.Format-Hex 123
69Format-ListFormats output as a list of properties.Get-Process | Format-List
70Format-TableFormats output as a table.Get-Process | Format-Table -AutoSize
71Format-WideFormats output as a table with a single wide column.Get-Process | Format-Wide
72Get-AclRetrieves access control lists (ACLs).Get-Acl file.txt
73Set-AclSets access control lists (ACLs).Set-Acl file.txt -AclObject $aclObj
74Get-AliasGets aliases.Get-Alias
75Get-AuthenticodeSignatureRetrieves digital signatures.Get-AuthenticodeSignature file.exe
76Get-ChildItemRetrieves items in a location.Get-ChildItem C:\
77Get-ClipboardRetrieves the current clipboard contents.Get-Clipboard
78Get-CommandGets commands.Get-Command
79Get-ComputerInfoRetrieves computer information.Get-ComputerInfo
80Get-ContentRetrieves the content of an item.Get-Content file.txt
81Get-CredentialRetrieves stored credentials.Get-Credential
82Get-CultureRetrieves culture information.Get-Culture
83Get-DateRetrieves the current date and time.Get-Date
84Get-EventRetrieves events.Get-Event
85Get-HistoryRetrieves the command history.Get-History
86Get-HostRetrieves host information.Get-Host
87Get-HotFixRetrieves installed hotfixes.Get-HotFix
88Get-ItemRetrieves items.Get-Item
89Get-ItemPropertyRetrieves property values of an item.Get-ItemProperty file.txt -Name Length
90Get-JobRetrieves background jobs.Get-Job
91Get-LocationRetrieves the current location.Get-Location
92Get-MemberRetrieves members of an object.Get-Process | Get-Member
93Get-ModuleLists the modules imported into the session.Get-Module
94Get-OSVersionRetrieves the operating system version.Get-WmiObject Win32_OperatingSystem | Select-Object Caption
95Get-ProcessRetrieves processes.Get-Process
96Get-RandomGenerates random numbers.Get-Random -Minimum 1 -Maximum 100
97Get-ServiceRetrieves services.Get-Service
98Get-TransactionRetrieves transactions.Get-Transaction
99Get-UICultureRetrieves user interface culture information.Get-UICulture
100Get-UniqueRetrieves unique items.Get-ChildItem | Get-Unique

The post Top 100 Essential PowerShell Commands: Your Must-Know Cheat Sheet appeared first on TEKSpace Blog.

]]>
https://blog.tekspace.io/top-100-essential-powershell-commands-your-must-know-cheat-sheet/feed/ 0
Building your first docker image for Windows https://blog.tekspace.io/how-to-create-docker-image-for-windows-containers/ https://blog.tekspace.io/how-to-create-docker-image-for-windows-containers/#respond Sat, 30 Mar 2019 01:37:45 +0000 https://blog.tekspace.io/index.php/2019/03/30/how-to-create-docker-image-for-windows-containers/ In this tutorial, I will demonstrate how to host an ASP.NET Core 2.2 application on Windows Containers by using a Docker image. A Docker image will be packaged with an ASP.NET Core application that will be run when a container is spun up.Before we get started with creating a Docker image. Let’s make sure we

The post Building your first docker image for Windows appeared first on TEKSpace Blog.

]]>
In this tutorial, I will demonstrate how to host an ASP.NET Core 2.2 application on Windows Containers by using a Docker image. A Docker image will be packaged with an ASP.NET Core application that will be run when a container is spun up.
Before we get started with creating a Docker image. Let’s make sure we have prerequisites done.

Prerequisites

Once you have the prerequisites, we will use a publicly available ASP.NET Core base image from Microsoft. Microsoft maintains their Docker images on Docker hub. Docker hub is a container registry to manage your Docker images either by exposing the image publicly or maintaining it privately. Private image responsibilities cost money. Visit Docker Hub website to learn more about image repository management.

Building your first Docker Image

Step 1: Open the PowerShell console as an administrator

Step 2: Let’s get started by pulling ASP.NET Core 2.2 Docker image from Docker hub by executing the below command.

docker pull mcr.microsoft.com/dotnet/core/aspnet:2.2

Your output should look similar to what is shown below:

Step 3: Create a folder with your preference name whatever you prefer. I will use c:\docker\ for demonstration purposes.

mkdir c:\docker

Step 4: Download ASP.NET Core application package from this URL.

Invoke-WebRequest -UseBasicParsing -OutFile c:\docker\WebAppCore2.2.zip https://github.com/rahilmaknojia/WebAppCore2.2/archive/master.zip

What we are doing in the above command is downloading packaged code that is already built to save time on building a package.

Step 5: Extract WebAppCore2.2.zip by using the PowerShell 5.0 native command. If you do not have PowerShell 5.0 and above, you will have to manually extract the package.

Expand-Archive c:\docker\WebAppCore2.2.zip -DestinationPath c:\docker\ -Force 

Step 6: Now let’s create a Docker file in c:\docker folder.

New-Item -Path C:\docker\Dockerfile -ItemType File

Step 7: Go ahead and open C:\docker folder path in Visual Studio Code.

Step 8: Now we will open Dockerfile by double-clicking on the file in Visual Studio Code to start writing the required steps to build an image.

Copy and paste the code below into Dockerfile.

# Pull base image from Docker hub 
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2

# Create working directory
RUN mkdir C:\\app

# Set a working directory
WORKDIR c:\\app

# Copy package from your machine to the image. Also known as staging a package
COPY WebAppCore2.2-master/Package/* c:/app/

# Run the application
ENTRYPOINT ["dotnet", "WebAppCore2.2.dll"]

What we told the Dockerfile is to pull an asp.net core base image from Docker hub. Then we ran a command to create a directory called app in c:\app path. We also told the container to set c:\app as a working directory. That way we can access binary directly when the container is spun up. We also added a step to copy all the binaries from c:\docker\WebAppCore2.2-master\Package\ to destination path in container c:\app. Once we had the package staged in the container, we told it to run the application by executing dotnet WebAppCore2.2.dll so that the app would be accessible from outside the container. To learn more about Dockerfile for Windows, check out this Microsoft documentation.

Now that you have the required steps to build an image, let’s go ahead with the below steps.

Step 9: Navigate to Dockerfile working directory from PowerShell console. If you are already in that path, you can ignore it.

cd c:\docker

Step 10: Execute the below command to build a container image.

docker build -t demo/webappcore:2.2.0

The above command will create a Docker image under demo path. With the image name called as webappcore and version 2.2.0.

Your output should look like below once it is successful:

PS C:\docker> docker build -t demo/webappcore:2.2.0 .
Sending build context to Docker daemon  9.853MB
Step 1/5 : FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
 ---> 36e5a01ef28f
Step 2/5 : RUN mkdir C:\\app
 ---> Using cache
 ---> 8f88e30dcdd0
Step 3/5 : WORKDIR c:\\app
 ---> Using cache
 ---> 829e48e68bda
Step 4/5 : COPY WebAppCore2.2-master/Package/* c:/app/
 ---> Using cache
 ---> 6bfd9ae4b731
Step 5/5 : ENTRYPOINT ["dotnet", "WebAppCore2.2.dll"]
 ---> Running in 4b5488d5ea5f
Removing intermediate container 4b5488d5ea5f
 ---> 9729270fe1ac
Successfully built 9729270fe1ac
Successfully tagged demo/webappcore:2.2.0

Step 11: Once the image has been built, you are now ready to run the container. Execute the below command.

docker run --name webappcore --rm -it -p 8000:80 demo/webappcore:2.2.0

The above command will create a new container called webappcore with parameters.

  • --rm is used to automatically remove the container after it is shutdown.
  • -it will open a session into your container and output all the logs.
  • -p is used for creating an external port and assigning it to the internal port of a container. Port 8000 is exposed to outside containers, and port 80 is used to access the app within the container.
  • demo/webappcore:2.2.0 is the path to the Docker image to run as a container.

Output of a running container

Step 12: Browsing your application from your local machine localhost:8000.

This is it! You ran your first Docker container in your local environment. Thank you for following the tutorial. Please comment below for any issue or feedback you would like to share.

The post Building your first docker image for Windows appeared first on TEKSpace Blog.

]]>
https://blog.tekspace.io/how-to-create-docker-image-for-windows-containers/feed/ 0
Run your first Windows Container on your Windows 10 https://blog.tekspace.io/run-your-first-windows-container-on-your-windows-10/ https://blog.tekspace.io/run-your-first-windows-container-on-your-windows-10/#respond Sun, 24 Mar 2019 15:59:32 +0000 https://blog.tekspace.io/index.php/2019/03/24/run-your-first-windows-container-on-your-windows-10/ Windows 10 now comes with container features available to pro and enterprise versions. To get started with containers on Windows 10, please make sure the below prerequisites are met. Pre-requisites Let’s ensure we have prerequisites installed before we get started with docker cli and container installation. If you already have the below items installed, you

The post Run your first Windows Container on your Windows 10 appeared first on TEKSpace Blog.

]]>
Windows 10 now comes with container features available to pro and enterprise versions. To get started with containers on Windows 10, please make sure the below prerequisites are met.

Pre-requisites

Let’s ensure we have prerequisites installed before we get started with docker cli and container installation. If you already have the below items installed, you can skip them and proceed with the setup.

Windows 10 now comes with container feature available for developers and devops engineers to start using Docker containers in their local environment. To enable containers for Windows 10, execute the below command.

Enable-WindowsOptionalFeature -FeatureName containers -Online -all

NOTE: Upon installation, you will be prompted to reboot your system after the container feature is enabled. It is recommended that you select yes to reboot your system.

Install Docker CLI

Now we will go ahead and download latest docker cli by using the Chocolate package management tool.

Once you have choco installed, go ahead and open PowerShell as an administrator and execute the below command.

choco install docker

You will be asked to say yes or no. Go ahead and continue with the interactive installation process by pressing Y. The output should look like below if the installation was successful.

Now that you have docker cli installed, you are now ready to run your first Docker container.

Installing Docker Enterprise Edition (EE)

To install Docker EE on Windows 10, please make sure above setup is successfully completed. To get started, go ahead and execute the below commands from an elevated PowerShell console.

To go to the Downloads’ folder of your current user.

cd ~\Downloads

Download Docker Enterprise Edition from online

Invoke-WebRequest -UseBasicParsing -OutFile docker-18.09.3.zip https://download.docker.com/components/engine/windows-server/18.09/docker-18.09.3.zip

NOTE: In this tutorial I am using Docker 18.09.3 version. This may change in the future. You can follow the updated document from here.

Unzip the Docker package.

Expand-Archive docker-18.09.3.zip -DestinationPath $Env:ProgramFiles -Force

Execute the below script to set up and start Docker.

# Add Docker to the path for the current session.
$env:path += ";$env:ProgramFiles\docker"

# Optionally, modify PATH to persist across sessions.
$newPath = "$env:ProgramFiles\docker;" +
[Environment]::GetEnvironmentVariable("PATH",
[EnvironmentVariableTarget]::Machine)

[Environment]::SetEnvironmentVariable("PATH", $newPath,
[EnvironmentVariableTarget]::Machine)

# Register the Docker daemon as a service.
dockerd --register-service

# Start the Docker service.
Start-Service docker

Test your Docker setup by executing the below command.

docker container run hello-world:nanoserver

Running your first Docker container

In this example, I will be using nanoserver image from Docker hub to run an IIS application.

Step 1: Let’s first check if we have any Docker images pulled from Docker hub. Based on the above setup for Docker, you should have a hello-world Docker image pulled from Docker hub.

docker images

Step 2: Let’s pull a new Docker image from Docker hub to run nanoserver with IIS configured.

docker pull nanoserver/iis

Your final output should look like below.

docker-iis-nanoserver-for-windows-container

Step 3: After we have pulled the latest image from Docker hub, let’s run our first windows container by executing the below command.

docker run --name nanoiis -d -it -p 80:80 nanoserver/iis

After it will return a container ID that you can use to check container status, configuration, etc.

Step 4: Check our first container status by executing the below command.

docker ps -a -f status=running

Status output:

docker-iis-nanoserver-for-windows-container-status

Step 5: Now let’s get the IP address of our container to access it from the browser.

docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" nanoiis

Step 6: Copy the IP address that was returned to the PowerShell console and browse it in Internet Explorer.

In my case, I received 172.19.231.54. Yours may be different.

This is it! You have run your first Windows container on your Windows 10 machine. Thank you for following this tutorial.

The post Run your first Windows Container on your Windows 10 appeared first on TEKSpace Blog.

]]>
https://blog.tekspace.io/run-your-first-windows-container-on-your-windows-10/feed/ 0
Getting started with Kubernetes on windows 10 with Hyper-V https://blog.tekspace.io/getting-started-with-kubernetes-on-windows-10-with-hyper-v/ https://blog.tekspace.io/getting-started-with-kubernetes-on-windows-10-with-hyper-v/#respond Sat, 23 Mar 2019 01:11:53 +0000 https://blog.tekspace.io/index.php/2019/03/23/getting-started-with-kubernetes-on-windows-10-with-hyper-v/ If you are interested in learning how Kubernetes works, you came to the right place! In this tutorial, I will show you how to quickly set up a local Kubernetes environment using Minikube to run hello-world app in a container. Pre-requisites Let’s ensure we have prerequisites installed before we get started with Minikube installation. If

The post Getting started with Kubernetes on windows 10 with Hyper-V appeared first on TEKSpace Blog.

]]>
If you are interested in learning how Kubernetes works, you came to the right place! In this tutorial, I will show you how to quickly set up a local Kubernetes environment using Minikube to run hello-world app in a container.

Pre-requisites

Let’s ensure we have prerequisites installed before we get started with Minikube installation. If you already have the below items installed, you can skip them and proceed with Minikube setup.

Installing Minikube

Step 1: Open the PowerShell console as an administrator.

Step 2: Install Minikube by executing the below command:

choco install minikube

NOTE: It may take a while to install Minikube depending on your network speed.

Verify your installation succeeded, and it should look like as shown below:

Setting up Hyper-V environment

Step 1: Open Hyper-V manager.

Step 2: Open Virtual Switch Manager from the Action panel on the right-hand side.

Step 3: Select New virtual network switch -> select External -> click on Create Virtual Switch.

Step 4: Name your virtual switch Minikube Virtual Switch, select correct LAN settings that give access to the internet and click on apply and ok.

NOTE: If you already have virtual switch created before, you may not need to set up virtual switch. This instruction is for newly installed hyper-v environments.

Starting Minikube

Open PowerShell as an administrator. If you already have it opened then you can ignore this step.

Execute the below command to start Minikube:

minikube start --vm-driver hyperv --hyperv-virtual-switch "Minikube Virtual Switch"

NOTE: If your virtual switch name is different from Minikube Virtual Switch, you can replace that in the above command.

Once Minikube has started, you will receive the below output, and you are ready to execute the Kubernetes command and deploy a container.

setup output:

o   minikube v0.35.0 on windows (amd64)
>   Creating hyperv VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
@   Downloading Minikube ISO ...
 184.42 MB / 184.42 MB [============================================] 100.00% 0s
-   "minikube" IP address is 192.168.0.106
-   Configuring Docker as the container runtime ...
-   Preparing Kubernetes environment ...
@   Downloading kubeadm v1.13.4
@   Downloading kubelet v1.13.4
:   Waiting for pods: apiserver proxy etcd scheduler controller addon-manager dns
-   Configuring cluster permissions ...
-   Verifying component health .....
+   kubectl is now configured to use "minikube"
=   Done! Thank you for using minikube!

To check if you have a successful connection to Kubernetes cluster, execute the below command from the PowerShell console.

kubectl get pods -n kube-system

Output:

NAME                               READY   STATUS    RESTARTS   AGE
coredns-86c58d9df4-87cj9           1/1     Running   0          3m5s
coredns-86c58d9df4-bg64j           1/1     Running   0          3m5s
etcd-minikube                      1/1     Running   0          2m9s
kube-addon-manager-minikube        1/1     Running   0          2m16s
kube-apiserver-minikube            1/1     Running   0          2m20s
kube-controller-manager-minikube   1/1     Running   0          2m14s
kube-proxy-wnxk4                   1/1     Running   0          3m5s
kube-scheduler-minikube            1/1     Running   0          2m23s
storage-provisioner                1/1     Running   0          2m4s

Deploying your first container

To deploy your first container in your Minikube cluster, execute deploy command.

kubectl create deployment hello-world --image=kitematic/hello-world-nginx

The above command will pull a new image from Docker hub from a public registry and run a container in your Minikube Kubernetes cluster.

To check the status of a container, execute the below command.

kubectl get pods

Output:

PS C:\Users\Ray> kubectl get pods
NAME                           READY   STATUS    RESTARTS   AGE
hello-world-7cbc87684d-pmwxl   1/1     Running   0          4m50s

Accessing your hello-world app

In order to access your hello-world application outside of Kubernetes cluster, you need to expose it as a service.

kubectl expose deployment hello-world --port=80 --type=NodePort

Once the service has been created, you will need to get a port number of your exposed service to be able to browse the application. Execute the below command.

kubectl.exe get services

output:

PS C:\Users\Ray> kubectl.exe get services
NAME          TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
hello-world   NodePort    10.96.79.70   <none>        80:31548/TCP   8m9s
kubernetes    ClusterIP   10.96.0.1     <none>        443/TCP        21h

When you expose a service, Kubernetes will automatically create a port number randomly. In my case it is 31548 for hello-world application. I will append this at the end of the Minikube node IP address to access the application.

To get Minikube IP address, execute the below command:

minikube ip

In my case, I received 192.168.0.112. I will use this IP address to access the application as shown in the below screenshot.

Kubernetes dashboard

Kubernetes provides a free dashboard to also manage your cluster via UI. To access Kubernetes dashboard, you will need to execute the below Minikube command.

minikube dashboard 

You will see below output upon initialization.

PS C:\Users\Ray\Downloads> minikube.exe dashboard
-   Enabling dashboard ...
-   Verifying dashboard health ...
-   Launching proxy ...
-   Verifying proxy health ...
-   Opening http://127.0.0.1:53782/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your default browser...

Once the initialization is completed, the dashboard should open in your default browser. If it didn’t open you can browse it by opening this link

You are all set! You can now navigate the dashboard and get familiar with pods, services, and many more.

Thank you for following this tutorial! Hope this helped you get started with Kubernetes.

The post Getting started with Kubernetes on windows 10 with Hyper-V appeared first on TEKSpace Blog.

]]>
https://blog.tekspace.io/getting-started-with-kubernetes-on-windows-10-with-hyper-v/feed/ 0
Generate Self-Signed certificate in Windows 7 https://blog.tekspace.io/generate-self-signed-certificate-in-windows-7/ https://blog.tekspace.io/generate-self-signed-certificate-in-windows-7/#respond Tue, 20 Feb 2018 20:13:48 +0000 https://blog.tekspace.io/index.php/2018/02/20/generate-self-signed-certificate-in-windows-7/ To generate self-signed certificates we will use makecert.exe. You will need to first download Windows SDK for Windows 7 or later. Download and install Windows SDK. Once you have downloaded and installed Windows SDK. Go to SDK folder by executing the below command. Generate Root CA Now, we will generate a root certificate. We will

The post Generate Self-Signed certificate in Windows 7 appeared first on TEKSpace Blog.

]]>
To generate self-signed certificates we will use makecert.exe. You will need to first download Windows SDK for Windows 7 or later.

Download and install Windows SDK.

Once you have downloaded and installed Windows SDK. Go to SDK folder by executing the below command.

cd C:\Program Files (x86)\Windows Kits\10\bin\x64

Generate Root CA

Now, we will generate a root certificate. We will use the root ca certificate to bind with client certificate later in this article.

makecert -sky exchange -r -n "CN=MyRootCert" -pe -a sha256 -len 2048 -ss Root

The above command will generate root ca and load it in Trusted Root Certificate -> Certificates folder.

Create client certificate

makecert.exe -n "CN=client.example.com" -pe -sky exchange -m 96 -ss My -in "MyRootCert" -is root -a sha256

The above command will create client certificate called client.example.com with MyRootCert binded together and load it in Personal -> Certificates folder under your user profile.

NOTE: If you have Windows 10 or Windows Server 2016 OS. You can use native PowerShell cmdlets to generate self-signed certificates.

The post Generate Self-Signed certificate in Windows 7 appeared first on TEKSpace Blog.

]]>
https://blog.tekspace.io/generate-self-signed-certificate-in-windows-7/feed/ 0
Install Kubernetes CLI on Windows 10 https://blog.tekspace.io/install-kubernetes-cli-on-windows-10/ https://blog.tekspace.io/install-kubernetes-cli-on-windows-10/#respond Sun, 28 Jan 2018 01:29:16 +0000 https://blog.tekspace.io/index.php/2018/01/27/install-kubernetes-cli-on-windows-10/ If you are looking to access Kubernetes Cluster from your windows machine. Look no further! I will show you how to install Kubernetes kubectl command line utility by leveraging Chocolatey installer. Note. I will be using Windows 10 to demonstrate. Now lets go ahead and get started by opening PowerShell as administrator and execute below

The post Install Kubernetes CLI on Windows 10 appeared first on TEKSpace Blog.

]]>
If you are looking to access Kubernetes Cluster from your windows machine. Look no further! I will show you how to install Kubernetes kubectl command line utility by leveraging Chocolatey installer.

Note. I will be using Windows 10 to demonstrate.

Now lets go ahead and get started by opening PowerShell as administrator and execute below command.

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Now that Chocolatey has been installed, we will go ahead with Kubernetes CLI setup.

Install Kubernetes CLI

Open PowerShell as an administrator and execute the below command.

choco install kubernetes-cli

You will be prompted to confirm if you want to proceed forward with the installation. Go ahead and say yes by typing Y and hit enter.

Connect to Kubernetes Cluster with Kubectl

Once you have install Kubernetes cli. Go to your Kubernetes master node and copy config file from ~/.kube/config to your windows machine to any location. We will move that file to required location once we create .kube directory on windows. Follow below steps.

Open PowerShell as an administrator and execute below commands.

cd ~

Above command will take you to your user home directory. In user home directory create folder called .kube. If it already exist, you can skip this step.

mkdir .kube

Once the above directory has been created, we need to copy config file from Kubernetes master node to .kube folder. Earlier I mentioned to copy config file to your windows machine. Take that file and drop it on your under ~\.kube location path.

Basic operations

After you have followed the steps shown above, let’s go ahead and test connectivity with your Kubernetes cluster.

kubectl.exe config get-clusters

If the above command returns the name of the cluster, then you have applied changes successfully. The below command will get information from your master node.

kubectl.exe version -o yaml

For me, I received the following output. Yours may vary depending on your cluster configuration.

clientVersion:
  buildDate: 2018-01-04T11:52:23Z
  compiler: gc
  gitCommit: 3a1c9449a956b6026f075fa3134ff92f7d55f812
  gitTreeState: clean
  gitVersion: v1.9.1
  goVersion: go1.9.2
  major: "1"
  minor: "9"
  platform: windows/amd64
serverVersion:
  buildDate: 2018-01-18T09:42:01Z
  compiler: gc
  gitCommit: 5fa2db2bd46ac79e5e00a4e6ed24191080aa463b
  gitTreeState: clean
  gitVersion: v1.9.2
  goVersion: go1.9.2
  major: "1"
  minor: "9"
  platform: linux/amd64

Let’s execute one more command to ensure we are successfully connected to the Kubenetes cluster.

kubectl.exe get nodes

If you received something similar to what I have received below, then you are fully connected to the cluster, and you can go ahead and manage your cluster from a Windows machine.

NAME               STATUS    ROLES     AGE       VERSION
k8s-master-node    Ready     master    3h        v1.9.2
k8s-worker-node1   Ready     <none>    3h        v1.9.2

If you have any questions or have trouble setting up kubernetes-cli on your Windows machine. Drop in a comment below, and I would be happy to help you out.

The post Install Kubernetes CLI on Windows 10 appeared first on TEKSpace Blog.

]]>
https://blog.tekspace.io/install-kubernetes-cli-on-windows-10/feed/ 0