hbhe0316
作者hbhe03162019-01-04 11:00
数据库管理员, IBM

ICP部署应用

字数 1382阅读 1893评论 1赞 3

1.创建hbhe namespace

[root@master home]# kubectl create namespace hbhe
namespace/hbhe created

2.将tomcat上传至ICP仓库

[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

vba9frb7gj

vba9frb7gj

3.部署应用,名为hbhe-tomcat

通过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
phmii6485ya

phmii6485ya

4.登录ICP

[root@master nginx]# cloudctl login -a https://mycluster.icp:8443 --skip-ssl-validation
nbw9vjpcv5o

nbw9vjpcv5o

5.访问应用

默认情况下,所有 Pod 只能在集群内部访问。对于上面这个例子,要访问应用只能直接访问容器的 8080 端口。为了能够从外部访问应用,我们需要将容器的 8080 端口映射到节点的端口。
[root@master tomcat]# kubectl expose deployment/hbhe-tomcat --type="NodePort" --port 8080

i4hjq3e8gya

i4hjq3e8gya

[root@master tomcat]# kubectl get svc
xjwh4r3fm27

xjwh4r3fm27

[root@master tomcat]# curl http://192.168.56.100:30517/hellojsp/
dl771wt77b

dl771wt77b

6.扩展应用

[root@master tomcat]# kubectl get deployment
[root@master tomcat]# kubectl scale deployments/hbhe-tomcat --replicas=5
tbwoxyjoooc

tbwoxyjoooc

scale down应用,执行命令完,可以看到目前之前三个Pod
[root@master tomcat]# kubectl scale deployments/hbhe-tomcat --replicas=3
[root@master tomcat]# kubectl get deployment
vwleaonkq8g
vwleaonkq8g

7.滚动更新

[root@master tomcat]# kubectl set image deployments/hbhe-tomcat hbhe-tomcat=mycluster.icp:8500/hbhe/tomcat7:v2.0
ax580qmas19

ax580qmas19

可以看到,curl出来的结果是v2版本
z293daofocn
z293daofocn

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

3

添加新评论1 条评论

zyl290760647zyl290760647技术支持, bjyd
2019-01-04 11:36
在做set image的时候 我一般都是加上 --record参数,这样在kubec rollout history的时候能够清楚的看见每一个REVISION 都做了什么样的更新操作!
Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广