SlideShare a Scribd company logo
林永和 2022/2
kubernetes 容器管理平台
基礎概念及應⽤
Speaker
• 什麼是kubernetes

• 介紹 p4~p7

• 元件 p8~p11

• 使⽤ p12~p15

• kubernetes應⽤

• 選型參考 p16~p17

• 本⽇k8s lab⽬標 p18

• Lab參考畫⾯ p19~p36

• 本地開發 p37~p42
本⽇主題
⼤型主機 、 虛擬主機 、 容器
謹慎評估使⽤場景後才會知道最適合的使⽤架構
容器化管理
kubernetes or docker swarm 選擇不是唯⼀
kubernetes ⽣態系
困難的是規劃
你以為只要有kubernetes就好了 實際上還有相關的關聯系統(圖為範例),更多在下⼀⾴
20220224台中演講k8s
什麼是k8s
kubernetes簡稱k8s , 以下為架構圖以及運作原理
Architecture CRI CNI
核⼼元件


https://kubernetes.io/docs/concepts/overview/components/
尚有DNS及網路元件等等...
YAML
k8s的resources都是yaml(json)
• Kubernetes API

• Kubectl api-resources

• Kubectl explain

• Kubectl create and dry-run
服務的運⾏
pod , service , ingress
• 服務的最⼩單位 pod

• Deployment、DaemonSet、
StatefulSet、Job

• 特殊的pod : static pod

• 提供服務存取的 service

• ClusterIP、NodePort、
LoadBalancer、ExternalName

• 服務揭露讓外部存取服務的 ingress

• 種類繁多
使⽤k8s後的改變
Devops 不再是傳統infra , developer區隔了
gitops讓開發更順暢
argoCD 、
fl
uxCD 、
fl
eet
k8s的選擇永遠不⽌⼀種
operator也是⼀種管理服務⽣命週期的做法
本段節錄redhat 對kubernetes operator的說法


Operator Framework


The Operator Framework is an open source project that provides developer and runtime
Kubernetes tools, enabling you to accelerate the development of an operator.


The Operator Framework includes:


•Operator SDK: Enables developers to build operators based on their expertise without
requiring knowledge of Kubernetes API complexities.


•Operator Lifecycle Management: Oversees installation, updates, and management of the
lifecycle of all of the operators running across a Kubernetes cluster.


•Operator Metering: Enables usage reporting for operators that provide specialized services.


⽽operator也可以根據需求⾃⼰撰寫,並且有些軟體有寫好的operator直接使⽤。
不只是使⽤,出事了,該怎麼辦
除錯流程
• 善⽤kubectl指令

• describe , logs , events

• 了解服務流向

• containers?

• pod to pod

• pod to service

• pod to internet

• same namespace or di
ff
erent

• iptables , DNS

• observability基礎建設
玲瑯滿⽬的k8s任君挑選
one k8s di
ff
erent distro
• 原⽣k8s

• redhat openshift

• OKD (community openshift)

• Rancher

• Vmware Tanzu

• google GKE (anthos)

• Amazon EKS 

• Microsoft AKS

• Alibaba ACK

• kind

• k3d

• minikube

• microk8s …
tanzu 多雲⽣態系
Tanzu Application Service – A modern runtime for Java, .NET and Node apps

Tanzu Application Platform – modular, application-aware platform providing developer
tooling to build and deploy software quickly and securely

Tanzu Build Service – Build containers from source code for Kubernetes

Tanzu Application Catalog – Curated container catalog

Tanzu Data Services – Cloud native data and messaging
including GemFire, RabbitMQ, SQL and Greenplum

Tanzu Kubernetes Grid – Enterprise Ready Kubernetes runtime

Tanzu Mission Control – Centralized cluster management

Tanzu Observability – Enterprise observability for multi-cloud environments

Tanzu Service Mesh – Enterprise-class service mesh
湯組(⽇⽂) k8s太輕 , openshift太重 , 雲平台太貴 , 可以試試看tanzu
Tanzu Kubernetes Grid (TKG),為提供⼀致的 kubernetes 使⽤體驗,與
原⽣的 Kubernetes 完全兼容。根據部署和管理⽅式的不同,⼜分為 Tanzu
Kubernetes Grid Service for vSphere( TKGs)和 Tanzu Kubernetes Grid
Muti-cloud (TKGm)。
實戰TCE (免錢社群版)
注意 : TCE,TKGm 2022時下僅⽀援 vSphere 、AWS、Azure
allinone local develop environment

Linux

4 core

8G ram

30GB disk

nonroot docker permission
bootstrap server

Linux

2 core

6G ram

nonroot docker permission
management cluster

Linux

nonroot docker permission

same subnet with workload cluster
workload cluster

Linux

nonroot docker permission

same subnet with management cluster
安裝準備 slide中⽤mac,但是實戰範例⽤linux
mac的主機需求




安裝docker


https://docs.docker.com/desktop/mac/install/


系統cgroup檢查




如果不是version: 1的話


要⽤docker 4.2版本https://docs.docker.com/desktop/mac/release-notes/#docker-
desktop-420


最終cgroup要是1




安裝kubectl


https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/
玩看看docker
常⽤docker 指令參考:


本地image相關操作


docker images 確認本地image


docker save 把image存成檔案


docker load 把檔案載入到本地


docker rmi 刪除不要的image


docker build 把dockerfile 建成image


本地運⾏相關操作


docker run 執⾏容器


docker ps 確認⽬前執⾏容器資訊


docker exec 進入容器


docker logs 檢查容器log


儲存庫相關操作


docker login 登入儲存庫


docker push 推送image到儲存庫


docker pull 從儲存庫拉image
TCE 安裝體驗1
接著開始下載tanzu TCE


mac的下載位置


https://github.com/vmware-tanzu/community-edition/releases/download/
v0.9.1/tce-darwin-amd64-v0.9.1.tar.gz




開始解包前我習慣會先看看內容有什麼




看起來正常,就解包吧


直接執⾏ ./install.sh就會開始安裝了,有兩⾏可以確認是否安裝成功




上圖中的


| initializing    successfully initialized CLI 和 Installation complete!


接著就可以執⾏看看tanzu command
TCE 安裝體驗2
Tanzu cli 的常⽤功能


tanzu kubernetes 叢集管理、建置


tanzu management-cluster create


tanzu management-cluster get


tanzu management-cluster kubeconfig get


tanzu cluster create


tanzu cluster list


tanzu cluster kubeconfig get


tanzu cluster scale


tanzu cluster upgrade


tanzu kubernetes package 管理


tanzu package repository list


tanzu package repository get


tanzu package repository add


tanzu package repository update


tanzu package available list


tanzu package available get


tanzu package install


tanzu package installed list


tanzu package installed get


tanzu package installed update


tanzu package installed delete
TCE 安裝體驗3
接著就可以開始安裝TCE的management cluster


tanzu management-cluster create --ui


這樣會啟動tanzu的web ui介⾯




這個會⾃動把⾴⾯開出來


沒有開出來的話也可以⾃⼰開網⾴⽤127.0.0.1:8080開起來


Tanzu cluster安裝


UI介⾯


Command


Command + 設定好的cluster config file


Config file 範例:


CLUSTER_NAME: aws-mgmt-cluster


CLUSTER_PLAN: dev


INFRASTRUCTURE_PROVIDER: aws


ENABLE_CEIP_PARTICIPATION: true


TMC_REGISTRATION_URL: https://tmc-
org.cloud.vmware.com/installer?
id=[...]&source=registration


ENABLE_AUDIT_LOGGING: true


CLUSTER_CIDR: 100.96.0.0/11


SERVICE_CIDR: 100.64.0.0/13


IDENTITY_MANAGEMENT_TYPE: oidc or ldap


TKG_CUSTOM_IMAGE_REPOSITORY: "custom-image-
repository.io/yourproject"


TKG_CUSTOM_IMAGE_REPOSITORY_CA_CERTIFICATE:
"LS0t[...]tLS0tLQ=="
TCE 安裝體驗4
第⼀個實驗會⽤docker啟動,也就是創造⼀個本地開發環境


名字的部分可以⾃由命名,這是給management-cluster的名字。


cidr的部分要注意的是,受同⼀個management cluster管理的workload
cluster的service和pod ip會在這個設定內,所以可以規劃⼀下。


proxy部分則是看⾃⼰有沒有需要對外的proxy設定。
TCE 安裝體驗5
點選deploy後會有⼀個設定⾴⾯可以review。


下⾯也有⼀⾏command可以先複製下來,後⾯如果有運⾏問題可以⽤這
⾏重跑,v越多資訊就越詳細,想看詳細的也可以v 10,按下去就會開始
執⾏囉。


也可以發現有⼀個configfile可以去看看是怎麼寫的,可以作為⽇後想要
客製化的參考。


安裝開始後就會看到他總共有8個步驟要執⾏,每個步驟主要的功能和印
出來的log都滿清楚的。
TCE 安裝體驗6
作業其實就是先⽤kind裝bootstrap 然後安裝management cluster 把相關檔案丟給management cluster,之後bootstrap就沒⽤囉


可以開⼀個視窗觀察,發現會⾃⼰啟動bootstrap 的container
TCE 安裝體驗7
除了⾴⾯以外,在⼀開始tanzu 開ui的terminal介⾯也可以看到相關訊息
TCE 安裝體驗8
開始安裝management cluster就會多出management cluster的相關container , 因為⼀些緣故,以下改⽤ubuntu主機接續範例
TCE 安裝體驗9
可以觀察到部署management的過程中產⽣的
container以及作業時進⾏哪些package安裝。
TCE 安裝體驗10
順利的話management安裝⼤概10分鐘完
成,完成的時候可以看到⼀些相關建議。
TCE 安裝體驗11
可以透過tanzu指令確認management cluster
的資訊,也可以透過tanzu login的⽅式去登入
不同的management cluster。


同時因為management cluster其實也是k8s,
所以也可以⽤kubectl的指令來玩看看。
TCE 安裝體驗12
真正需要來拿運⾏服務的k8s對tanzu來說是
workload cluster,透過docker的⽅式佈署的
話,也可以透過docker觀察安裝過程的變
化。
TCE 安裝體驗13
安裝完成後⼀樣會有提⽰完成。
TCE 安裝體驗14
如同management cluster,會需要將
kubeconfig拿出來,這樣才⽅便使⽤。
TCE 安裝體驗15
對於需要運⾏服務的cluster,會需要關⼼資
源是否不夠使⽤,所以tanzu也有提供scale
node的功能,擴充的⽅式非常的容易。
TCE 最終理想架構
Skaffold本地開發神器
developer
Pod
Kubernetes
使⽤ska
ff
old前 使⽤ska
ff
old後
超靈體OVER-SOUL 服務 in k8s
Skaffold 介紹
Skaffold 會透過監控的⽅式去看指定的⽬錄,
當有異動時會判斷是靜態檔案或是需要重新
build服務,接著推送到⽬前使⽤k8s中佈署。
skaffold 使⽤體驗1
skaffold使⽤的程式⽬錄最低本需要有
dockerfile、skaffold的yaml、要佈署的yaml、
程式
skaffold 使⽤體驗2
Skaffold dev的⽅式去⾃動監控我的程式⽬錄
skaffold 使⽤體驗3
同時⽤skaffold dev的terminal和kubectl的
terminal觀察變化,可以清楚地看到服務成功
的佈署以及source code的變化。
skaffold 使⽤體驗4
常⽤的IDE(如 vscode )使⽤起來的時候感覺
就更明顯了,同時vscode 搭配skaffold和
cloud run也能夠更快入的進⾏開發。


社群推薦 CNTUG


Cloud native Taiwan user group
臉書社團


https://fb.cloudnative.tw


telegram討論群


https://t.me/cntug
參考資料
https://www.netadmin.com.tw/netadmin/zh-tw/feature/C5A86F4783EB41789147E4D2246CC985?page=1



https://dotblogs.com.tw/Christian_Lee/2019/03/25/Windows_Docker_Container

https://s3.cn-north-1.amazonaws.com.cn/www.sh-silverlining.com/Kubernetes/%E8%8B%B1%E6%96%87/The+key+to+kubernetes%2C+have+you+got+it.htm

https://docs.docker.com/engine/swarm/how-swarm-mode-works/nodes/

https://kubernetes.io/

https://docs.microsoft.com/zh-tw/azure/architecture/reference-architectures/containers/aks-microservices/aks-microservices

https://landscape.cncf.io/

https://medium.com/jorgeacetozi/kubernetes-master-components-etcd-api-server-controller-manager-and-scheduler-3a0179fc8186

https://www.cnblogs.com/MimiSnowing/p/14822813.html

https://www.hwchiu.com/ithome/2019/network/day11.html

https://www.hwchiu.com/k8s-course-2.html

https://hiskio.com/courses/349/about?promo_code=13LY5RE

https://kubernetes.io/docs/concepts/overview/kubernetes-api/

https://kubernetes.io/docs/reference/kubectl/overview/

https://kubernetes.io/docs/tasks/con
fi
gure-pod-container/static-pod/

https://iximiuz.com/en/posts/kubernetes-api-structure-and-terminology/

https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/

https://itnext.io/stitching-kubernetes-jenkins-sonarqube-and-github-using-kubesphere-567ee413f8dd

https://www.cht.com.tw/home/campaign/gxc/c4/public-cloud/solution-1.html

https://morioh.com/p/05ce86b2ad73

https://myyhhuang.com/2021/08/18/%E4%B8%89%E5%A4%A7gitops-solution/

https://www.redhat.com/zh/topics/containers/what-is-a-kubernetes-operator

https://blog.pichuang.com.tw/20211129-kubernetes-service-troubleshoot/

https://veducate.co.uk/tanzu-terminology/

https://txconsole.com/how-to-build-tanzu-kubernetes-grid-in-air-gap-system/

https://williamlam.com/2021/10/introducing-vmware-tanzu-community-edition-tce-tanzu-kubernetes-for-everyone.html

https://tanzucommunityedition.io/docs/latest/cli-installation/

https://cormachogan.com/2022/02/10/deploying-a-tanzu-kubernetes-cluster-using-tanzu-cli-in-vsphere-with-tanzu/

https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-mgmt-clusters-create-con
fi
g-
fi
le.html

https://docs.vmware.com/en/VMware-Tanzu/services/tanzu-reference-architecture/GUID-reference-designs-index.html

https://ska
ff
old.dev/docs/

https://github.com/GoogleContainerTools/ska
ff
old/tree/main/examples/getting-started

More Related Content

PDF
Kubernetes Basics
PDF
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
PDF
Open shift 4 infra deep dive
PDF
Kubernetes 101
PPTX
Introduction to CNI (Container Network Interface)
PPTX
Kubernetes Introduction
PDF
Kubernetes 101
PDF
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Basics
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Open shift 4 infra deep dive
Kubernetes 101
Introduction to CNI (Container Network Interface)
Kubernetes Introduction
Kubernetes 101
Kubernetes Concepts And Architecture Powerpoint Presentation Slides

What's hot (20)

PPTX
Rancher and Kubernetes Best Practices
PDF
我的 DevOps 故事
PDF
Achieving CI/CD with Kubernetes
PDF
Autoscaling Kubernetes
PPTX
Kubernetes PPT.pptx
PDF
What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginn...
ODP
Kubernetes Architecture
PDF
Kubernetes Introduction
PPTX
01. Kubernetes-PPT.pptx
PPTX
Challenges of Kubernetes On-premise Deployment
PDF
Introduction to kubernetes
PDF
Quick introduction to Kubernetes
PDF
Kubernetes - A Comprehensive Overview
PPTX
Docker Container Security - A Network View
PDF
架構這件事 - Azure 可以幫助什麼 - 如何選擇使用什麼 Azure 服務
PDF
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
PPTX
Service Discovery In Kubernetes
PDF
Advanced Deployment Strategies with Kubernetes and Istio
PDF
GitOps with ArgoCD
PPTX
コンテナネットワーキング(CNI)最前線
Rancher and Kubernetes Best Practices
我的 DevOps 故事
Achieving CI/CD with Kubernetes
Autoscaling Kubernetes
Kubernetes PPT.pptx
What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginn...
Kubernetes Architecture
Kubernetes Introduction
01. Kubernetes-PPT.pptx
Challenges of Kubernetes On-premise Deployment
Introduction to kubernetes
Quick introduction to Kubernetes
Kubernetes - A Comprehensive Overview
Docker Container Security - A Network View
架構這件事 - Azure 可以幫助什麼 - 如何選擇使用什麼 Azure 服務
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Service Discovery In Kubernetes
Advanced Deployment Strategies with Kubernetes and Istio
GitOps with ArgoCD
コンテナネットワーキング(CNI)最前線
Ad

Similar to 20220224台中演講k8s (20)

PPTX
Windows Container 101: dotNET, Container, Kubernetes
PPTX
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
PPTX
Kubernetes (K8s) 簡介 | GDSC NYCU
PPTX
Oh K8s Is Swag - Kubernetes Basics
PDF
Introduction to K8S Big Data SIG
PDF
淺談 Kubernetes於大數據生態系的相關開發近況
PDF
How to use kubernetes build microservices 如何運用 Kubernetes 打造微服務生態圈
PDF
企業導入微服務實戰 - updated
PDF
Build your own kubernetes apiserver and resource type
PDF
Kubernetes 地端自建 v.s. GKE,哪個更適合你? @Devfest Taipei 2024
PPTX
Kubernetes+(K8s)+介绍.pptx,适合初学者的一些k8s说明与介绍
PDF
企業導入微服務實戰 - updated
PDF
廣宣學堂: 企業導入微服務實戰
PDF
Extend the Kubernetes API with CRD and Custom API Server
PDF
Kubernetes project update and how to contribute
PPTX
Kubeflow Machine Learning Toolkit for Kubernetes (SDN x Cloud Native Meetup #4)
PDF
Debug Your Kubernetes Network
PPT
Network Design in Cloud-ready IDC
PPTX
AKS 與開發人員體驗 (Kubernetes 大講堂)
PDF
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
Windows Container 101: dotNET, Container, Kubernetes
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
Kubernetes (K8s) 簡介 | GDSC NYCU
Oh K8s Is Swag - Kubernetes Basics
Introduction to K8S Big Data SIG
淺談 Kubernetes於大數據生態系的相關開發近況
How to use kubernetes build microservices 如何運用 Kubernetes 打造微服務生態圈
企業導入微服務實戰 - updated
Build your own kubernetes apiserver and resource type
Kubernetes 地端自建 v.s. GKE,哪個更適合你? @Devfest Taipei 2024
Kubernetes+(K8s)+介绍.pptx,适合初学者的一些k8s说明与介绍
企業導入微服務實戰 - updated
廣宣學堂: 企業導入微服務實戰
Extend the Kubernetes API with CRD and Custom API Server
Kubernetes project update and how to contribute
Kubeflow Machine Learning Toolkit for Kubernetes (SDN x Cloud Native Meetup #4)
Debug Your Kubernetes Network
Network Design in Cloud-ready IDC
AKS 與開發人員體驗 (Kubernetes 大講堂)
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
Ad

20220224台中演講k8s