Kubernetes基礎:開啓雲原生之門 - 筆記

Google開源, 基於Google內部Borghtml

  • 2014 開源
  • 2015 捐贈給CNCF
  • 2017 Kubernetes打敗Swarm和Mesos,成爲容器管理與調度變排領域的首選平臺和事實標準
  • 2018 CNCF畢業

演變

  • 物理單機(~2000)
  • 虛擬化 初期(2001~2009)
    • VMware Xen KVM
    • Iaas: AWS(2006) GCE(2008)
  • 虛擬化 成熟期(2010~至今)
    • OpenStack(2010)
    • AWS Azure Aliyun GCE
    • 容器化(2013~)
      • Docker將已有技術(LXC cgroups Union FS)整合包裝,造成一種標準鏡像格式
  • 元原生 初期(2015~至今)
    • 前提 應用容器化和微服務器化
    • CNCF K8s 2015

K8S

  • 容器編排管理平臺
  • 可移植雲平臺

K8S集羣初體驗

Service 部署

kubectl get nodesnode

hello-service.yaml 配置文件後端

kubectl create -f hello-service.yaml --record 建立service kubectl get svc!grep hello-service 查看服務是否建立成功 kubectl describe svc/hello-service 查看詳細信息 kubectl run -i --tty busybox --image=busybox --restart=Never 建立容器並進入容器命令行 nslookup hello-serviceapi

deployment部署

hello-development.yaml配置文件 kubectl create -f hello-deployment.yaml --record=true deployment kubectl get deployments 列出deployments安全

請求自動負載均衡

kubectl get pods|grep hello kubectl logs -f hello-deployment-xxxxx-xxxx 查看日誌 經過日誌查看能夠發現服務調用被自動負載均衡到多個服務上服務器

服務伸縮

擴展 修改development的配置文件, 修改replicas 有2改成3 運行 kubectl apply -f hello-deployment.yaml架構

版本升級

修改development的配置文件, 修改image 選項的鏡像版本 運行 kubectl apply -f hello-deployment.yaml 運行命令查看 kubectl rollout status deployment/hello-deployment 逐一升級,替換升級全部podapp

快速回滾升級 kubectl rollout undo deployments/hello-deployment負載均衡

kubernetes1.13.1+etcd3.3.10+flanneld0.10集羣部署 https://www.kubernetes.org.cn/5025.html微服務

K8s架構和組件

Master組件

  • Scheduler
    • 經過API Server的Watch接口
  • Controller Manager
    • controller核心管理者
  • API Server
    • 集羣控制的惟一入口,提供RESTful API控制集羣
    • 外部控制內部的通訊交互中樞
    • 提供安全機制
  • etcd
    • 集羣數據配置中心

Node組件

  • Kubelet
    • Master和node直接的橋樑
  • Kube-proxy
    • Service抽象概念的實現,將service請求按策略分發到後端Pod上

K8S基礎概念

Kubernates對象模型 Kind Metadata Spec Operation api(kubectl)操做方法 Status etcd動態信息

Name和UID

  • 標識 Namespace
  • 將物理集羣劃分爲多個虛擬集羣 Label
  • 鍵值對
  • 經過label selector 查詢和篩選創建對象間的關係 Annotations

k8s對象分類

  • workload
  • discovery&load balance
  • config&storage
  • cluster
相關文章
相關標籤/搜索