--- title: Kubenates 學習記錄 --- # Kubenates 學習記錄 ###### tags: `infrastructure` ## 概念 ### 服務部署單位 | pod | replica | replica set | deployment | | -------- | -------- | -------- | --- | | 單容器 | 多容器+設定 | replica + 彈性的selecor 對應目標 | replica set + rollup, rollback | | command部署 | yaml部署 | yaml部署 | yaml部署、指令rollback, rollout | 開port方式: 1- kubectl expose (便利) 2- service.yaml (可控性更高) ## 初始化 1. 安裝 minikube -- 相比正式的k8, 這僅限提供單節點做為練習 測試: minikube version (於brew install minikube前須先 brew install kubectl) 2. 啟動mk, minikube start kubectl 操控k8, minikube 操控節點 3. 建立k8 deployment ## 好用連結 1. 指令: http://docs.kubernetes.org.cn ## 常用指令 - 不易查到 1. 刪除pod , service kubectl delete pod kubernetes-demo-pod 要指名刪除對象為pod or service,不能只輸入resource name ## 問題紀錄 1. Minikube, kubectl 彼此之間的關係? 2. brew install minikube 以後自動建立起來的Minikube image 存在的作用為何? 3. Service.yaml 的 port , target port, node port 三者差異? 答案參考: https://blog.csdn.net/xinghun_4/article/details/50492041 port:外部連入的端口 node port:外部連接到內部node的端口 target port:連接到pod的端口 4. 為何經由service 連線到pod ,使用瀏覽器跟使用ssh 輸入的port不一樣?https://cwhu.medium.com/kubernetes-implement-ingress-deployment-tutorial-7431c5f96c3e