Openshift中Configmap的使用
2024-08-26 12:52:13
先基于外部镜像构建一个deployment
ericdeMacBook-Pro:nginx ericnie$ oc new-app ericnie2017/nginx:v1. --allow-missing-images --name=nginx-demo -n myproject
--> Found Docker image 48a076d ( 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 /tcp, /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 ; error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid; events {
worker_connections ;
} 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 ; #gzip on; include /etc/nginx/conf.d/*.conf;
}
然后建立一个nginx.conf文件,将8080端口修改为8011
ericdeMacBook-Pro:nginx ericnie$ cat nginx.conf
server{
listen ;
server_name _;
location /{
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page /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后访问成功。
最新文章
- Apache多端口监听
- 在Eclipse里查看Java字节码
- [安卓] 4、CheckBox、RadioButton和Toast简单用法
- CocoStudio教程三:认识并利用CocoStudio的果实 运行2.2.1版本
- 字符截取 支持UTF8/GBK
- resin的简单介绍和使用
- SQL Server 2005下载安装
- C++学习(五)
- API例子:用Python驱动Firefox采集网页数据
- js复制button在ie下的解决方式
- [转]iOS hacking resource collection
- 蓝牙协议 基于TI cc2540 模块的理解(转)
- jQuery插件开发详解
- ●BZOJ 3551 [ONTAK2010]Peaks(在线)
- Linux内存管理 (8)malloc
- Android快速实现二维码扫描--Zxing
- Sprint冲刺第二阶段之6---10天(下)
- spoj gss1 gss3
- MapGIS Mobile开发
- Hdu1548 A strange lift 2017-01-17 10:34 35人阅读 评论(0) 收藏