[root@master home]# kubectl create namespace hbhe
namespace/hbhe created
[root@master tomcat]# docker tag tomcat7:v1.0 mycluster.icp:8500/hbhe/tomcat7:v1.0
[root@master tomcat]# docker push mycluster.icp:8500/hbhe/tomcat7:v1.0
通过kubectl run部署应用,应用名为hbhe-tomcat
--images为mycluster.icp:8500/hbhe/tomcat7:v1.0
--port对外端口为8080
[root@master tomcat]# kubectl run hbhe-kubernetes-tomcat --image=mycluster.icp:8500/hbhe/tomcat7:v1.0 --port=8080
[root@master nginx]# cloudctl login -a https://mycluster.icp:8443 --skip-ssl-validation
默认情况下,所有 Pod 只能在集群内部访问。对于上面这个例子,要访问应用只能直接访问容器的 8080 端口。为了能够从外部访问应用,我们需要将容器的 8080 端口映射到节点的端口。
[root@master tomcat]# kubectl expose deployment/hbhe-tomcat --type="NodePort" --port 8080
[root@master tomcat]# kubectl get svc
[root@master tomcat]# curl http://192.168.56.100:30517/hellojsp/
[root@master tomcat]# kubectl get deployment
[root@master tomcat]# kubectl scale deployments/hbhe-tomcat --replicas=5
[root@master tomcat]# kubectl set image deployments/hbhe-tomcat hbhe-tomcat=mycluster.icp:8500/hbhe/tomcat7:v2.0
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞3
添加新评论1 条评论
2019-01-04 11:36