![](/img/trans.png)
[英]How to deploy docker image on container through kubernetes YAML file?
[英]Deploy Docker container to Kubernetes using yaml file
我正在尝试使用YAML文件(本地系统)将Docker容器部署到Kubernetes。
第1部分:Docker容器(工作正常)
第2部分:Kubernetes(无效)
错误:无法访问网站
泊坞窗:
Kubernetes:
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: jenkins
spec:
selector:
matchLabels:
app: tomcat
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat-jenkins
image: $DOCKER-ID/tomcat-jenkins:3
ports:
- containerPort: 80
# Service
apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
selector:
app: tomcat
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 31011
type: NodePort
在Kubenetes容器中部署容器后,我无法访问应用程序。
我不确定我的deployment.yaml文件是否包含某些语法错误。
在NodePort上公开服务时,可以使用http:// NodeIP:NodePort`访问它。 对于以上服务,nodeport的值为31011。
这是一个详细的教程 ,解释了在k8s上公开该服务。
ClusterIP(默认)-在群集的内部IP上公开服务。 这种类型使得只能从群集内访问服务。
NodePort-使用NAT在群集中每个选定节点的相同端口上公开服务。 使用:使服务可从群集外部访问。 ClusterIP的超集。
LoadBalancer-在当前云中创建一个外部负载平衡器(如果支持),并为该服务分配一个固定的外部IP。 NodePort的超集
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.