openshift 学习笔记-5 template使用
来源:互联网 发布:java定时任务 编辑:程序博客网 时间:2024/05/29 09:10
创建微服务 new-app
vito@caas:~$ oc new-project myciAlready on project "myci" on server "https://openshift-cluster.example.com:8443".You can add applications to this project with the 'new-app' command. For example, try: oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.gitto build a new example application in Ruby.vito@caas:~$ oc get projectNAME DISPLAY NAME STATUSmyci Activevito@caas:~$ oc new-app golang-builder:1.01~http://172.18.103.111/liujunbang/mybank.git --name=test-hello--> Found image 3de3f0e (3 weeks old) in image stream "openshift/golang-builder" under tag "1.01" for "golang-builder:1.01" builder golang 1.8 ------------------ Platform for building golang Tags: builder, golang * A source build using source code from http://172.18.103.111/liujunbang/mybank.git will be created * The resulting image will be pushed to image stream "test-hello:latest" * Use 'start-build' to trigger a new build * This image will be deployed in deployment config "test-hello" * The image does not expose any ports - if you want to load balance or send traffic to this component you will need to create a service with 'expose dc/test-hello --port=[port]' later--> Creating resources ... imagestream "test-hello" created buildconfig "test-hello" created deploymentconfig "test-hello" created--> Success Build scheduled, use 'oc logs -f bc/test-hello' to track its progress. Run 'oc status' to view your app.
应用创建成功。
1、顺便验证一下service 的功能,此时build完成,部署完成,微服务成功启动,但是没有创建service。此时进入启动的为服务容器内部,env检查环境变量,肯定没有service的信息,因为没有创建。
2、创建service
oc create -f service.yaml
yaml文件内容如下:
apiVersion: v1kind: Servicemetadata: labels: app: test-svc name: test-svc namespace: mycispec: ports: - name: test-ci port: 8081 protocol: TCP targetPort: 8081 selector: app: test-hello sessionAffinity: None type: ClusterIPstatus: loadBalancer: {}
3、执行扩展,把pod数量扩展微两个:
$ oc scale dc test-hello --replicas=2deploymentconfig "test-hello" scaled
4、进入容器内部,查看两个pod的环境变量:
第一个pod:
第二个pod:
我们发现,虽然创建了service,原来的pod里面仍然没有注入service的信息,必须重启pod以后,service的环境变量信息才能注入到pod中。
继续往下template
导出模板template
执行模板导入命令:
oc export bc,dc,svc,is,route -o json –as-template=”test-template” > ~/test-template.yaml
本地生成yaml文件:
test-template.yaml
导入模板 create template
1、模板创建
oc create -f test-template.yaml
2、在web console 中使用模板创建项目,搜索test-template模板
3、创建
4、创建完成
5、查看进度
6、完成后,访问测试微服务
阅读全文
0 0
- openshift 学习笔记-5 template使用
- openshift template
- openshift 学习笔记-1
- openshift 学习笔记-2
- OpenShift使用笔记
- openshift 学习笔记-4 Jenkins
- openshift/origin学习记录(5)——添加Template(模板)并基于模板部署应用
- h5学习笔记:weui text/template 使用
- openshift 学习笔记-6 secret and quota
- openshift 学习笔记-7 度量和日志
- openshift使用
- class template学习笔记
- template学习笔记
- C++ TEMPLATE 学习笔记
- jade template 学习笔记
- C++ template 学习笔记
- Go Template学习笔记
- ExtJS4学习笔记八--Template的使用
- 基于HTML5和WebGL的3D网络拓扑结构图
- CDH安装过程
- Python Logging模块的简单使用(转)
- 设计模式学习(六)
- iOS-检测设备的WiFi是否打开?
- openshift 学习笔记-5 template使用
- ubuntu下关于profile和bashrc中环境变量的理解
- FFmepg基本使用流程
- 3 disconf在springboot下动态配置各个属性,基于docker环境
- 安卓常用代码片段
- 湘潭大学-基于Dragonboard 410c的实时公交站牌系统设计(二)
- 【caffe跑试验遇到错误:Check failed: error == cudaSuccess (2 vs. 0) out of memory】
- 架构
- Android RecyclerView简单通用适配器