• 关于DeploymentConfig的思考


     为什么是deploymentconfig而不是Kubernetes的deployment

     在new-app的时候openshift直接创建了一个deploymentconfig并部署成rc,开始并不理解为什么要这么做,后来看到下面这个命令才大概明白,原因主要有两点:

    • deploymentconfig在创建的时候通过new-app自动生成,避免直接从无到有去写一个deployment的yaml文件,减少了出错。
    • deployment并不具备回滚的功能,如果部署到一个版本就无法回滚到上一个版本或者更前一个版本了,而dc有个revision,同时保留了之前部署版本的配置。如下:

    如果回滚可以通过下面命令

    oc rollback openshift-tomcat --to-version=2
    • 创建new-app的时候除了创建dc,还会创建一个服务,名字和app名字一样

    如果需要在容器运行前就带入环境变量

    oc new-app openshift-tomcat --name=openshift-tomcat --env DEPLOY_MODE=stg

    带入多个

    C:minishift-1.26.1-windows-amd64>oc new-app openshift-tomcat --name=openshift-tomcat --env DEPLOY_MODE=stg  SITE=sz
    warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
    --> Found image a4dc2a4 (6 hours old) in image stream "myproject/openshift-tomcat" under tag "latest" for "openshift-tomcat"
    
        temp.builder.openshift.io/myproject/openshift-tomcat-3:d91ff45d
        ---------------------------------------------------------------
        Platform for building and running JEE applications on Tomcat
    
        Tags: builder, tomcat
    
        * This image will be deployed in deployment config "openshift-tomcat"
        * Port 8080/tcp will be load balanced by service "openshift-tomcat"
          * Other containers can access this service through the hostname "openshift-tomcat"
    
    --> Creating resources ...
        deploymentconfig.apps.openshift.io "openshift-tomcat" created
        service "openshift-tomcat" created
    --> Success
        Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
         'oc expose svc/openshift-tomcat'
        Run 'oc status' to view your app.

    容器运行中设置环境变量

    C:minishift-1.26.1-windows-amd64>oc set env dc/openshift-tomcat DEPLOY_MODE="prd"
    deploymentconfig.apps.openshift.io/openshift-tomcat updated

    列出环境变量

    C:minishift-1.26.1-windows-amd64>oc set env dc/openshift-tomcat --list
    # deploymentconfigs/openshift-tomcat, container openshift-tomcat
    DEPLOY_MODE=stg
  • 相关阅读:
    借助GitStats进行项目统计
    sql查重复数据
    git增删远程分支
    iOS类继承及重用
    键盘消息多次被触发
    salt未持久化保存导致应用启动时候的网络请求失败(没有权限)
    resize view from nib引起的子控制器视图(childviewcontroller)部分区域无响应
    python脚本实现自动为png类型图片添加@2x后缀
    企业级后台列表常用操作
    java集合总结
  • 原文地址:https://www.cnblogs.com/ericnie/p/9919620.html
Copyright © 2020-2023  润新知