先基於外部鏡像構建一個deploymenthtml
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.
生成Routenginx
ericdeMacBook-Pro:nginx ericnie$ oc expose svc nginx-demo --hostname=nginx-demo-myproject.192.168.99.100.nip.io route "nginx-demo" exposed
訪問8080端口成功。app
查看鏡像中的nginx.conf,發現最後配置是調用的config.d下的應用配置文件tcp
$ 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端口修改成8011ide
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; } }
生成一個configmapthis
ericdeMacBook-Pro:nginx ericnie$ oc create configmap nginx-conf --from-file=nginx.conf configmap "nginx-conf" created
在OKD的resource的configmap下看到spa
查看目前的pod配置文件目錄3d
切換回configmap,而後選擇Add to Applicationcode
保存後openshift會構建新的實例,原有應用訪問失敗orm
修改Service後訪問成功。