1 Star 0 Fork 0

mobikarl / k8s-for-docker-desktop

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README_en.md

Enable Kubernetes on Docker Desktop for Mac/Windows in China

中文 | English

NOTE:

  • The master branch is tested with Docker Desktop for Mac/Windows version 2.5.0.0 Edge (with Docker CE 20.10.0 and Kubernetes 1.19.3).
  • If you want to use with other version, pls check version of Kubernetes,Docker -> About Docker Desktop about
    • For Kubernetes v1.18.8, please use the v1.18.8 branch git checkout v1.18.8
    • For Kubernetes v1.18.6, please use the v1.18.6 branch git checkout v1.18.6
    • For Kubernetes v1.18.3, please use the v1.18.3 branch git checkout v1.18.3
    • For Kubernetes v1.16.5, please use the v1.16.5 branch git checkout v1.16.5
    • For Kubernetes v1.15.5, please use the v1.15.5 branch git checkout v1.15.5
    • For Kubernetes v1.15.4, please use the v1.15.4 branch git checkout v1.15.4
    • For Kubernetes v1.14.8, please use the v1.14.8 branch git checkout v1.14.8
    • For Kubernetes v1.14.7, please use the v1.14.7 branch git checkout v1.14.7
    • For Kubernetes v1.14.6, please use the v1.14.6 branch git checkout v1.14.6
    • For Kubernetes v1.14.3, please use the v1.14.3 branch git checkout v1.14.3
    • For Kubernetes v1.14.1, please use the v1.14.1 branch git checkout v1.14.1
    • For Kubernetes v1.13.0, please use the v1.13.0 branch git checkout v1.13.0
    • For Kubernetes v1.10.11, please use the v1.10.11 branch git checkout v1.10.11

Enable Kubernetes on Docker Desktop

Config registry mirror for Docker daemon with https://docker.mirrors.ustc.edu.cn only if in China

mirror

Optional: config the CPU and memory for Kubernetes, 4GB RAM or more is suggested.

resource

Preload Kubernetes images form Alibaba Cloud Registry Service, NOTE: you can modify the images.properties for your own images

On Mac, execute the following scripts

./load_images.sh

Or on Windows, execute the following scripts in PowerShell

 .\load_images.ps1

NOTE: if you failed to start PowerShell scripts for security policy, please execute Set-ExecutionPolicy RemoteSigned command in PowerShell with "Run as administrator" option.

Enable Kubernetes, and wait a while for Kubernetes is running

k8s

Config Kubernetes

Optional: switch the context to docker-desktop (In the former version, the context is docker-for-desktop)

kubectl config use-context docker-desktop

Verify Kubernetes installation

kubectl cluster-info
kubectl get nodes

Deploy Kubernetes dashboard

Install Kubernetes dashboard

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

or

kubectl create -f kubernetes-dashboard.yaml

Check Kubernetes Dashboard status

kubectl get pod -n kubernetes-dashboard

Start proxy for API server

kubectl proxy

Access Kubernetes dashboard

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Config Token for dashboard

For Mac

TOKEN=$(kubectl -n kube-system describe secret default| awk '$1=="token:"{print $2}')
kubectl config set-credentials docker-for-desktop --token="${TOKEN}"
echo $TOKEN

For Windows

$TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
kubectl config set-credentials docker-for-desktop --token="${TOKEN}"
echo $TOKEN

Login dashboard

resource

Choose Token, and input the output from above result

Or, choose Kubeconfig, select file from below path:

Win: %UserProfile%\.kube\config
Mac: $HOME/.kube/config

Click login, go to Kubernetes Dashboard

Install Helm

Install helm following the instruction on https://helm.sh/docs/intro/install/

For Mac OS

# Use homebrew on Mac
brew install helm

# add helm repo
helm repo add stable http://mirror.azure.cn/kubernetes/charts/

# update charts repo
helm repo update

For Windows

# Use Chocolatey on Windows
# NOTE: please ensure you can access googleapis
choco install kubernetes-helm

# add helm repo
helm repo add stable http://mirror.azure.cn/kubernetes/charts/

# update charts repo
helm repo update

Setup Istio

More details can be found in https://istio.io/docs/setup/getting-started/

Download Istio 1.5.0 and install CLI

curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.5.0 sh -
cd istio-1.5.0/
export PATH=$PWD/bin:$PATH

In Windows, you can download the Istio manually, or copy getLatestIstio.ps1 to your Istio directory, and execute the script.

NOTE: It refer the scripts from community.

.\getLatestIstio.ps1

Install Istio

istioctl manifest apply --set profile=demo

Check status of istio release

kubectl get pods -n istio-system

Enable automatic sidecar injection for default namespace

kubectl label namespace default istio-injection=enabled
kubectl get namespace -L istio-injection

Install Book Info sample

Please refer https://istio.io/docs/examples/bookinfo/

kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml

Check the resources of sample application

kubectl get svc,pod

Confirm the application is running

kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}') -c ratings -- curl productpage:9080/productpage | grep -o "<title>.*</title>"

Create Ingress Gateway

kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml

Check Gateway status

kubectl get gateway

Confirm the application is accessible

export GATEWAY_URL=localhost:80
curl -s http://${GATEWAY_URL}/productpage | grep -o "<title>.*</title>"

Open with browser http://localhost/productpage

Confirm application is running

export GATEWAY_URL=localhost:80
curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage

Cleanup sample application

samples/bookinfo/platform/kube/cleanup.sh

Delete Istio

istioctl manifest generate --set profile=demo | kubectl delete -f -

Repository Comments ( 0 )

Sign in to post a comment

About

Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
1
https://gitee.com/mobikarl/k8s-for-docker-desktop.git
git@gitee.com:mobikarl/k8s-for-docker-desktop.git
mobikarl
k8s-for-docker-desktop
k8s-for-docker-desktop
master

Search