Setup kuberntes local environment with minikube

 Setup kuberntes local environment with minikube:

  1. Pre-requisite
    1. Minikube – Install on your local (instructions below)
    2. Docker – Install on your local
    3. Azure Subscription Access – “playground” as a contributor. 
    4. Azure VM Access:

                                                               i.      Access is with your Azure Cloud Shell. 

        1. Use storage account cloudpsocap in resource group " playground-rg”.

                                                             ii.      Upload attached PEM file to your cloud bash. https://devcoops.com/how-to-upload-files-to-azure-cloud-shell/

                                                           iii.      Execute to Ssh to the VM - ssh -I <file.pem> azureuser@linuxtrainingvm.centralus.cloudapp.azure.com

  1. Instructions on how to install Minikube.
    1. Open PowerShell with administrator privilege

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

    1. Open CMD with Administrator privilege and execute below

set HTTP_PROXY=http://genproxy.org.com:8080

set HTTPS_PROXY=http://genproxy.org.com:8080

set NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.39.0/24

{/path/to/Minikube}/Minikube.exe start or copy Minikube.exe to C:\Windows\System32 folder.

    1. Also download kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/ and copy it in C:\Windows\System32 dir.

 

Useful Commands:

#After downloading minikube you need to start: 
minikube detlete or minikube start # to stop and start minikube

#After install check the version of kubectl:
kubectl version --client
kubectl version --client --output=yaml 
kubectl cluster-info # To verify kubectl configuration


pod.yaml file
apiVersion: v1
kind: Pod
metadata:
  name: pod-demo
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
    - containerPort: 80
    resources:
      limits:
        cpu: 50m
        memory: 100Mi
      requests:
        cpu: 50m
        memory: 100Mi


podp.yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: premium-pod-demo
  labels:
    app: premium
spec:
  replicas: 2
  selector:
    matchLabels:
      app: premium
  template:
    metadata:
      labels:
        app: premium
    spec:
      containers:
      - name: demo
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        resources:
          limits:
            cpu: 50m
            memory: 100Mi
          requests:
            cpu: 50m
            memory: 100Mi

kubectl apply -f pod.yaml

kubectl describe pod

kubectl apply -f podp.yaml

kubectl apply -f podp.yaml && kubectl get pods -w   

kubectl get deploy


kubectl scale deployment/premium-pod-demo --replicas=5

kubbectl get pods

kubectl scale deployment/premium-pod-demo --replicas=2

kubectl get deploy

OR

kubectl scale deployment/premium-pod-demo --replicas=5 

kubectl detlete -f podp.yaml

Comments

Popular posts from this blog

Cloud Computing in simple

How to Write an Effective Design Document

Bookmark