当前位置: 首页 > news >正文

CKA考试知识点分享(12)---configmap

CKA 版本:1.32
第十二套题是涉及configmap相关。
实验操作:通过configmap 给nginx deployment外挂配置,实现修改configmap后,配置动态更新。
注意:本文不是题目,只是为了学习相关知识点做的实验。仅供参考

实验开始

创建nginx的deployment

apiVersion: apps/v1
kind: Deployment
metadata:name: nginx
spec:selector:matchLabels:run: nginxtemplate:metadata:labels:run: nginxspec:containers:- name: nginximage: docker.m.daocloud.io/library/nginx:stable-alpineports:- containerPort: 80---
apiVersion: v1
kind: Service
metadata:name: nginxlabels:run: nginx
spec:ports:- port: 80selector:run: nginx

访问pod 查看nginx版本:
在这里插入图片描述

创建nginx的配置文件
vim nginx.conf

user  nginx;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /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;server_tokens off;include /etc/nginx/conf.d/*.conf;
}

创建configmap
kubectl create configmap nginx.conf --from-file=nginx.conf
查看configmap
在这里插入图片描述

针对deployment 进行修改使用这个configmap

    volumeMounts:- name: config-volumemountPath: /etc/nginx/nginx.confsubPath: nginx.conf  # 以子文件nginx.conf挂载到/etc/nginx/ 目录,不加的话当前目录下只有nginx.conf这一个文件volumes:- name: config-volumeconfigMap:name: nginx.conf

应用后,pod重启,再次查看版本
在这里插入图片描述

发现nginx的版本隐藏,配置文件生效。
注意:使用subpath 当configmap变动时,不会自动更新。 所以需要重启pod才能实现配置文件更新。

相关文章:

  • 005__C++类的基本语法
  • 洛谷P4555 最长双回文串
  • 从监测滞后到全域智控:河湖智慧化管理方案
  • python程序设计(2)
  • LeetCode 72. 编辑距离(Edit Distance)| 动态规划详解
  • 【推荐算法课程二】推荐算法介绍-深度学习算法
  • 日语语法学习
  • 模型合并(model merge)
  • CC工具箱使用指南:【面要素四至】
  • 报表工具顶尖对决系列—关联过滤
  • /proc/<pid>/maps文件格式详解
  • 声学成像仪在电力行业的应用品牌推荐
  • JavaWeb期末速成 Servlet
  • [C++11] : 谈谈包装器和lambda表达式,仿函数,bind的坑
  • Ntfs!NtfsVolumeCheckpointDpc函数分析到调用Ntfs!NtfsCheckpointAllVolumes函数
  • ubuntu 挂载问题
  • 【51单片机】6. 定时器、按键切换流水灯时钟Demo
  • Harbor 2.12.2 and 2.12.3 初始化密码错误
  • 风控系统中,要调用第三方服务获取信息,很慢,如何解决?
  • Pytorch中view函数详解和工程实战示例
  • 遵义桐梓疫情最新情况/seo站长综合查询工具
  • 南京淄博网站建设工作室/昆明seo博客
  • 平远县建设工程交易中心网站/seo岗位工作内容
  • 吴忠建设网站/快速刷排名seo软件
  • 免费创一个网站/推广普通话活动方案
  • vi毕业设计代做网站/超级软文