zoukankan      html  css  js  c++  java
  • Openshift中Configmap的使用

    先基于外部镜像构建一个deployment

    ericdeMacBook-Pro:nginx ericnie$ oc new-app ericnie2017/nginx:v1.0 --allow-missing-images --name=nginx-demo -n myproject
    --> Found Docker image 48a076d (9 minutes old) from Docker Hub for "ericnie2017/nginx:v1.0"
    
        * An image stream will be created as "nginx-demo:v1.0" that will track this image
        * This image will be deployed in deployment config "nginx-demo"
        * Ports 80/tcp, 8080/tcp will be load balanced by service "nginx-demo"
          * Other containers can access this service through the hostname "nginx-demo"
        * WARNING: Image "ericnie2017/nginx:v1.0" runs as the 'root' user which may not be permitted by your cluster administrator
    
    --> Creating resources ...
        imagestream "nginx-demo" created
        deploymentconfig "nginx-demo" created
        service "nginx-demo" 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/nginx-demo'
        Run 'oc status' to view your app.

    生成Route

    ericdeMacBook-Pro:nginx ericnie$ oc expose svc nginx-demo --hostname=nginx-demo-myproject.192.168.99.100.nip.io
    route "nginx-demo" exposed

    访问8080端口成功。

    查看镜像中的nginx.conf,发现最后配置是调用的config.d下的应用配置文件

    $ cat nginx.conf
    
    user  nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        keepalive_timeout  65;
    
        #gzip  on;
    
        include /etc/nginx/conf.d/*.conf;
    }

    然后建立一个nginx.conf文件,将8080端口修改为8011

    ericdeMacBook-Pro:nginx ericnie$ cat nginx.conf
    server{
        listen  8011;
        server_name _;
        location /{
          root  /usr/share/nginx/html;
          index index.html index.htm;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
          root  /usr/share/nginx/html;
        }
    }

    生成一个configmap

    ericdeMacBook-Pro:nginx ericnie$ oc create configmap nginx-conf --from-file=nginx.conf
    configmap "nginx-conf" created

    在OKD的resource的configmap下看到

    查看目前的pod配置文件目录

    切换回configmap,然后选择Add to Application

    保存后openshift会构建新的实例,原有应用访问失败

    修改Service后访问成功。

     

  • 相关阅读:
    1295. 统计位数为偶数的数字『简单』
    1281. 整数的各位积和之差『简单』
    697. 数组的度『简单』
    748. 最短完整词『简单』
    832. 翻转图像『简单』
    1446. 连续字符『简单』
    1455. 检查单词是否为句中其他单词的前缀『简单』
    1160. 拼写单词『简单』
    1304. 和为零的N个唯一整数『简单』
    1103. 分糖果 II『简单』
  • 原文地址:https://www.cnblogs.com/ericnie/p/9695130.html
Copyright © 2011-2022 走看看