不受任何控制器(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