Wakatime of Kube Project :
Ref :
-
-
https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/ (Kubectl)
-
https://minikube.sigs.k8s.io/docs/start/ (Minikube)
| No. | English Title (ชื่อเรื่องภาษาอังกฤษ) | Thai Title (ชื่อเรื่องภาษาไทย) |
|---|---|---|
| 1) | Step #Installation [ Kubernetes ] on Windows and Create [ Minikube ] | ขั้นตอน การติดตั้ง [Kubernetes] บน Windows and Create [ Minikube ] |
| 2) | Step #Traefik Deploy on [ MiniKube ] | ขั้นตอน Traefik Deploy บน [ MiniKube ] |
| 3) | Step #Web Deploy used Image [ rancher/hello-world ] | ขั้นตอน Web Deploy ใช้ Image [ rancher/hello-world ] |
| 4) | Set file hosts on Windows | ตั้งค่า file hosts บน Windows |
| 5) | Expected Results | ผลที่คาดว่าจะได้รับ |
(ขั้นตอน การติดตั้ง [Kubernetes] บน Windows and Create [ Minikube ])
-
Install and check verion kubectl on Windows. (ติดตั้งและเช็คเวอร์ชั่น kubectl บน Windows)
Run Powershell in Admin state. ( Run Powershell ด้วยสถานะ Admin )
> curl.exe -LO "https://dl.k8s.io/release/v1.26.0/bin/windows/amd64/kubectl.exe" > kubectl version --client
-
Install minikube on Windows. (ติดตั้ง minikube บน Windows)
> 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 #After that, config path of minikube on Environment Variables. (กำหนด path ของ minikub บน Environment Variables)
-
Create minikube and allow aceess to Kubernetes App. (สร้าง minikube และอนุญาตการเข้าถึง Kubernetes App)
> minikube start #Start using minitube(เริ่มต้นการใช้งาน minikube) > minikube dashboard #Commands for minitube dashboards(คำสั่งแสดง dashboard ของ minikube) > minikube tunnel #Config, Available Kubernetes(กำหนดให้สามารถใช้ Kubernetes ได้)
To prepare the device, install using Kubernetes, install kubectl and minikube as appropriate.
(การเตรียมความพร้อมของอุปกรณ์, การติดตั้งใช้ Kubernetes ให้ติดตั้ง kubectl และ minikube ตามความเหมาะสม)
(ขั้นตอน Traefik Deploy บน [ MiniKube ])
- Learn How to install Traefik step by step. (ศึกษาการติดตั้ง Traefik ตามขั้นตอน) => kuberplay-tragik
Download file helm => helm-v3.11.2
For config, Run PowerShell on Windows, and then edit file. ymal All files specified as namespaces : default
(โดยสำหรับ helm ให้ run ผ่าน powershell on Windows จากนั้นทำการแก้ไข file.ymal ทุกไฟล์ที่มีระบุ namespace : default)
##Set namespace
namespace: defaultThen define the path of helm on the environment variable.
(จากนั้นมีการกำหนด path ของ helm บน Environment Variables)
In the file traefik-dashboard.yaml, define the host name as traefik.spcn22.local in the matching routing specification.
(ใน file traefik-dashboard.yaml กำหนดในส่วน spec ที่ routes ที่ match ชื่อ Host คือ traefik.spcn22.local )
CLICK show code : traefik-dashboard.yaml
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: traefik-basic-authen
namespace: default
spec:
basicAuth:
secret: dashboard-auth-secret
removeHeader: true
---
apiVersion: v1
data:
users: dXNlcjokMnkkMDUkR0Z3WUZKWkVIdUZlVEoxb3hOMnB0dXBURXpIWEN4djRZenQ4STV3T1kxcTFsZmZxY2M5T0cKCg==
kind: Secret
metadata:
name: dashboard-auth-secret
namespace: default
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: traefik-dashboard
namespace: default
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/router.middlewares: traefik-basic-authen
spec:
entryPoints:
- websecure
routes:
- match: Host(`traefik.spcn22.local`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))
kind: Rule
middlewares:
- name: traefik-basic-authen
namespace: default
services:
- name: api@internal
kind: TraefikService
Use the following command to create files for auth-secret and dashboard-secret.yml by wsl (Ubuntu) on Windows.
(ใช้คำสั่งต่อไปนี้ผ่าน wsl(Ubuntu) on Windows เพื่อสร้าง file ของ auth-secret และ dashboard-secret.yml)
> htpasswd -nB user | tee auth-secret #Set password(กำหนด password)
> kubectl create secret generic -n traefik dashboard-auth-secret --from-file=users=auth-secret -o yaml --dry-run=client | tee dashboard-secret.yaml
#Create `dashboard-secret.yml`
-
OUTPUT : After finsih Created
auth-secret(หลังสร้างauth-secret)
-
OUTPUT : After finsih Created
dashboard-secret.yml(หลังสร้างdashboard-secret.yml)
-
OUTPUT : After finsih Created
auth-secretanddashboard-secret.yml, it's show (หลังสร้างauth-secretและdashboard-secret.ymlจะแสดง)
Then copy user of file dashboard-secret.yaml to user of file traefik-dashboard.yaml
(จากนั้นทำการ copy ที่ user ของ file dashboard-secret.yaml ไปเปลี่ยนที่ user ของ file traefik-dashboard.yaml )
Use the following command to Traefik Deploy. (ใช้สั่งต่อไปนี้เพื่อ Traefik Deploy)
> kubectl apply -f traefik-dashboard.yaml(ขั้นตอน Web Deploy ใช้ Image [ rancher/hello-world ])
- Create file
rancheer.yaml(สร้างไฟล์rancheer.yaml)
In the file rancher.yaml, define the host name as web.spcn22.local in the matching routing specification.
(ใน file rancher.yaml กำหนดในส่วน spec ที่ routes ที่ match ชื่อ Host คือ web.spcn22.local )
CLICK show code : rancheer.yaml
apiVersion: v1
kind: Service
metadata:
name: rancher
namespace: default
spec:
selector:
app: rancher
ports:
- port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rancher
spec:
selector:
matchLabels:
app: rancher
template:
metadata:
labels:
app: rancher
spec:
containers:
- name: rancher
image: rancher/hello-world
resources:
limits:
memory: "128Mi"
cpu: "100m"
ports:
- containerPort: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: traefik-ingress
namespace: default
spec:
entryPoints:
- web
- websecure
routes:
- match: Host(`spcn22.local`)
kind: Rule
services:
- name: rancher
port: 80- Deploy rancher
kubectl apply -f rancheer.yaml
(ตั้งค่า file hosts บน Windows)
- Open file hosts of Windows and Set the IP Address and hostname from the
rancher.yamlandtraefik-dashboard.yamlas (เปิด file hosts ของ Windows และตั้งค่า IP Address และชื่อ hostname จากrancher.yamlandtraefik-dashboard.yamlคือ ) : traefik.spcn22.local, web.spcn22.local
Form Config in file hosts:
127.0.0.1 traefik.spcnxx.local
127.0.0.1 web.spcnxx.local
(ผลที่คาดว่าจะได้รับ)
- SHOW : After finsih Traefik Deploy on Minikube (หลัง Traefik Deploy บน Minikube)
- SHOW : After finsih Deploy rancher (หลัง Deploy rancher)
- SHOW : After finsih All Deploy (หลัง Deploy ทั้งหมด)




