Showing posts with label YAML. Show all posts
Showing posts with label YAML. Show all posts

Thursday, August 13, 2020

How to add gwin to windows CMD or cmder?

it is very useful to use vi editor to compose yaml file for Kubernetes. we can launch the VI or VIM editor by typing vi or vim in the CMD or cmder.

 if you are not comfortable working with vi or vim. there is GUI version of vi call gwin.

you can download a copy of gwin for windows from the link below.

 https://www.vim.org/download.php#pc

1.  you should run the exe file with administrator privilege to ensure the file can install into the proper location.

2. second step you can either run this script in the powershell window

 Set-alias gvim "C:\Program Files (x86)\Vim\vim82\gvim.exe"

or add the application path (C:\Program Files (x86)\Vim\vim82\gvim.exe) to the Path variable in the Environment Variable Window

 

 

then you can launch gwin editor from CMD or cmder

 

 

 


Monday, July 13, 2020

how to setup Azure Kubernetes Service cluster and configure Kubernetes dashboard with AZ CLI?

it is very easy to create and run a  AKS cluster with few AZ CLI commands.

1. create a resource group for AKS

az group create --name dan-aks-rg --location eastus

2. create an AKS cluster

az aks create --resource-group dan-aks-rg --name dan-cluster

3.get the credentials for the cluster, this will download the credetenials and store in the config file
under this path C:\Users\admin\.kube

az aks get-credentials --resource-group dan-aks-rg --name dan-cluster

4. install the Kubernetes cli utility

az ask install-cli

5. install Kubernetes dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml

6. Access the dashboard. there are two way to access the Kubernetes dashboard.
 from AZ CLI

az aks browse --resource-group dan-aks-rg --name dan-cluster

it will automatically lauch in the web browser

http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/


or we can use kubectl proxy to access the Kubernetes Dashboard UI. Type Kubectl proxy in the CMD windows, then hit enter and launch the web chrome and paste the following url in the url windows to launch the kubernetes dashboard.

kubectl proxy 

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/overview?namespace=default

7. Trouble shot tips

if you see an empty kubernetes dashboard with warming message
"secrets is forbidden: User "clusterUser" cannot list resource "secrets" in API group "" in the namespace "default"

it is permission issue. you can resolve this following steps, you need to replace the clusterUser with specific name that was shown in your error message.

  • kubectl delete clusterrolebinding kubernetes-dashboard

    kubectl delete clusterrolebinding kubernetes-dashboard -n kube-system

    kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard --user=clusterUser

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-clusterrolebinding-em-

Monday, February 24, 2020

A cool tool to validate the yaml content on building the docker-compose.yml file.

after i added a docker-compose project the asp.net solution, then i try to build the docker-compose file to generate all the images.

however i always encounter error without specific message. the root of cause this issue is that
YAML follows indentation structure very strictly. one extra space or tab will cause this issue.

this online tool will be a great help on validation your content in YAML.

https://onlineyamltools.com/validate-yaml

here is my sample docker-compose file, after i pasted it in the yaml box, the line causes the issue highlights immediately in the errors box

version: '3.7'

services:
  webapi_dotnetcore:
    image: ${DOCKER_REGISTRY-}webapidotnetcore
    build:
      context: .
      dockerfile: WebAPI_DotNetCore/Dockerfile

  db:
    image: mcr.microsoft.com/mssql/server
    environment:
         - ACCEPT_EULA=Y
         - SA_PASSWORD=Password_01
  ports:
   - '1433:1433'