不受任何控制器(Deployment,ReplicaSets,Jobs)控制的Pod稱之爲裸Podgit
FOO_SERVICE_HOST=<the host the Service is running on> FOO_SERVICE_PORT=<the port the Service is running on>
若是代碼中要訪問Service,不要使用上述環境變量,最好使用Service的dns名稱,上述環境變量只是爲了解決有些老的系統沒法使用DNS查找問題的臨時方案github
hostPort
,由於會限制Pod被調度的可能若是隻是想訪問某個端口進行debug,可使用apiserver proxy或kubectl port-forwardjson
若是確實須要暴露某個Pod的端口到主機端口,建議使用Service中的NodePort
api
{ app: myapp, tier: frontend, phase: test, deployment: v3 }
,Service能夠經過Selector實現跨Deployment組織資源;Deployment能夠經過標籤實現無中斷更新app
IfNotPresent
,kubelet只有在本地不存在的狀況下才會去拉取鏡像。若是想每次執行都拉取鏡像能夠指定策略:imagePullPolicy: Always
還有一種方法是指定:latest
tag,也會每次都拉取鏡像frontend
生產環境避免使用這種方式url
kubectl apply -f <directory>
或kubectl create -f <directory>
,會匹配目錄中的.yaml .yml .json 文件kubectl run
和kubectl expose
命令快速建立Deployment和Service,參考Use a Service to Access an Application in a Cluster