[k8s]cm挂到不同镜像如何获取env?
2017-09-16 16:53
288 查看
要求每个pod挂相同cm模板,得到属于自己的配置
具体实现
以filebeat镜像为例:docker-entrypoint.sh #!/bin/bash set -ex echo "pod-ip is $POD_IP" sed -i "s#\#pod-ip#pod-ip: $POD_IP#g" /etc/filebeat/filebeat.yml #注意这句 filebeat -e -c /etc/filebeat/filebeat.yml
Dockerfile FROM docker.elastic.co/beats/filebeat:5.4.1 COPY docker-entrypoint.sh /usr/local/bin/ #RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["docker-entrypoint.sh"]
apiVersion: v1 kind: ConfigMap metadata: name: tomcat-spring data: filebeat.yml: | filebeat.prospectors: - input_type: log fields: service-name: tomcat-spring #pod-ip # docker-entrypoint.sh会替换这行,具体,先sed获取pod变量值,然后替换这个#pod-ip. paths: - "/log/*.txt" multiline: pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{3}' negate: true match: after output.elasticsearch: hosts: ["elasticsearch.logging.svc.cluster.local:9200"] username: "elastic" password: "changeme" template.name: "filebeat" template.path: "filebeat.template.json" template.overwrite: true index: "filebeat-docker-test" # Available log levels are: critical, error, warning, info, debug logging.level: info
相关文章推荐
- Django表单提交后,如何获取相同name的不同value值
- 不同web如何通讯之 html页面获取传递的参数
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- 教你如何在中国区加速部署k8s,且实现自定义设置拥有k8s镜像的仓库与其命名空间
- 001--easyui 中如何获取不同input的值,并且进行比较呢?
- 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)?
- 如何在不同的语言/平台中获取Android ID
- 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)?
- IOS6及以后如何标识不同设备&获取用户的唯一标示符
- 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)
- 如何在不同系统下使用 Java 获取系统 IP
- k8s之使用secret获取私有仓库镜像
- 如何获取不同cell上的button点击事件
- 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)?
- RevitAPI: 如何获取MirrorElement函数镜像之后的结果元素
- [python]如何使用virtualenvwrapper切换不同版本的python?
- React Native 如何获取不同屏幕的像素密度
- Hacking with Angular:如何在深层嵌套ngRepeat中获取不同层级的$index
- 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)?
- 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)