Tuesday, November 19, 2019

Setting Up Kubernetes (K8s) on Windows



DOWNLOAD & INSTALL :

1. Install Google Cloud SDK

2. Install kubectl
      gcloud components install kubectl


3. Install minikube
      Download, Rename and Copy to location
      C:\ & C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin
      minikube.exe 

4. Start Minikube
      minikube version
      minikube start
      minikube start --show-libmachine-logs --alsologtostderr
         minikube status
         minikube ssh
      minikube stop
      minikube delete

      minikube logs

     enable minikube addons:     
     minikube addons list
        minikube addons enable dashboard


5. kubectl Helper Commands:
      kubectl version -o json
      kubectl get namespace
      kubectl config use-context minikube
      kubectl cluster-info
      kubectl config view
      kubectl get nodes

      kubectl get all
      kubectl get all -n kube-system


6. Installing K8s Dashboard using kubectl

1. Deploy the Kubernetes dashboard to your single node cluster
kubectl apply -f  https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

2. Create a file => dashboard-admin-sa.yaml
# ------------------- Dashboard Service Account ------------------- #
apiVersion: v1
kind: ServiceAccount
metadata:
  name: dashboard-admin-sa
  namespace: kube-system
---
# ------------------- Dashboard-Cluster-Role ------------------- #
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: dashboard-admin-sa
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: dashboard-admin-sa
  namespace: kube-system


6. Open Cmder

7. Apply the service account and cluster role binding to your cluster
    kubectl apply -f dashboard-admin-sa.yaml

8. Start the kubectl proxy
    kubectl proxy

9. Get Token
    kubectl get secrets -n kube-system
    kubectl describe secrets dashboard-admin-sa -n kube-system

10. Run Dashboard
    minikube addons open dashboard
    minikube dashboard --url
 curl http://127.0.0.1:8001/ 
 http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

11. Delete Dasboard
      kubectl get all -n kube-system
      kubectl delete deployment kubernetes-dashboard --namespace kube-system
      service, role, rolebinding, sa, secret


12. Choose Token
paste the output from the previous command into the Token field, and
choose SIGN IN