Kubernetes

Kubernetes In Docker [KInD]

graph LR image([image]) --> |used by|container subgraph pod direction TB container end
graph LR subgraph deployment direction TB subgraph pod container end end

Create a Cluster and look around

  1. Get started

    kind create cluster
    

    output

    Creating cluster "kind" ...
    āœ“ Ensuring node image (kindest/node:v1.25.0) šŸ–¼
    āœ“ Preparing nodes šŸ“¦
    āœ“ Writing configuration šŸ“œ
    āœ“ Starting control-plane šŸ•¹ļø
    āœ“ Installing CNI šŸ”Œ
    āœ“ Installing StorageClass šŸ’¾
    Set kubectl context to "kind-kind"
    You can now use your cluster with:
    
    kubectl cluster-info --context kind-kind
    
    Have a nice day! šŸ‘‹
    
  2. standard kubectl commands

    
    ```text
    kubectl cluster-info --context kind-kind
    

    output

    Kubernetes control plane is running at https://127.0.0.1:56236
    CoreDNS is running at https://127.0.0.1:56236/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
    
    To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
    

    And taking a look at the context

    kubectl config current-context
    

    output

    kind-kind
    

Create our first resource

  1. Running things directly

    !!WARN: This is not the recommended way to run things in Kubernetes!!

    kubectl run --image gcr.io/google-containers/busybox mypod
    

    output

    pod/mypod created
    
  2. Inspect the pod

    kubectl get pod
    

    output

    NAME    READY   STATUS             RESTARTS      AGE
    mypod   0/1     CrashLoopBackOff   1 (12s ago)   16s
    
  3. Look at "all" the things

    kubectl get all
    

    output

    NAME        READY   STATUS             RESTARTS     AGE
    pod/mypod   0/1     CrashLoopBackOff   1 (3s ago)   7s
    
    NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
    service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   13m
    

Alternative ā€” Windows Hyper-V

A Hyper-what-now?

Big words! It's a piece like VMWare, VirtualBox, Hyper-V ā€” which is built into Windows

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

output

Path          :
Online        : True
RestartNeeded : False

Install kind

Alternative ā€” Install minikube

  • Follow the instructions in minikube start

  • Download minikube.exe

    New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force
    Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing
    
  • Add the executable to your path

    $oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::User)
    if ($oldPath.Split(';') -inotcontains 'C:\minikube'){ `
      [Environment]::SetEnvironmentVariable('Path', $('C:\minikube;{0}' -f $oldPath), [EnvironmentVariableTarget]::User) `
    }
    
  • Reload your path. The easiest way is to stop and start your terminal again.

    If you use VS Code do not use Developer: Reload Window. You will need to close and open the full application.

    VS Code Reload Window Command

    The same applies other tools like JetBrains products if you use them.

    Get-Command minikube
    

    Output

    CommandType     Name                                               Version    Source
    -----------     ----                                               -------    ------
    Application     minikube.exe                                       0.0.0.0    C:\minikube\minikube.exe
    


Children
  1. CPU Limits
  2. Misc
  3. Pod