kubernetes常用的deploy模板,验证编写deploy配置文件numberofcopiesreplicas:10#标签选择器selector:matchLabels:name:hostname-test-cby#更新策略strategy:rollingUpdate:maxSurge:3#最大更新数量maxUnavailable:3#更新滚动日期时不可用的最大数量updatetemplatetype:Rollat??e:????metadata:??????labels:????????name:?hostname-test-cby????spec:??????#?配置容器??????containers:??????-?name:?hostname-test-cby?#容器名????????image:?nginx?#镜像????????imagePullPolicy:?IfNotPresent?#?拉取策略????????resources:??????????requests:????????????cpu:"100m"#CpulimitMemory:"300M"#Memorylimitation#"LivenessProbe:httpget:Path:/#detectingpathport:80#portinitialdelaySeconds:15#第一次检测等待TimeOutSeconds:3#等待多少秒等待时间多少秒。#就绪探针readinessProbe:httpget:Path:/#检测路径port:80#portinitialdelaySeconds:10#第一次检测等待TimeOutSeconds:3#等待多少秒#环境变量env:-name:cBYVALUE:Chenby#配置容器端口Ports:-Containerport:80#Configuration挂载到目录Volumemounts:-Mountpath:/usr/share/nginx/html/name:Data#MountVolumes:-name:Path:/html/type:directory#ConfigurationspecifiedresolutionhostAliases:-ip:"192.168.1.1"#IP地址hostnames:-"cby"#hostname-"cby.chenby.cn"#hostname-ip:"192.168-hostsname:IP地址"chenby"#hostname-"chenby.chenby.cn"#hostnameroot@hello:~#执行部署配置文件root@hello:~#kubectlapply-fdeploy.yamldeployment.apps/hostname-test-cbycreatedroot@hello:~#mkdir/htmlroot@hello:~#echo123>/html/index.htmlroot@Hello:?#kubectl获取POD-Owidename准备状态重新启动年龄IP节点提名节点准备gateshostname-test-test-cby-86df45bf-9fx5n1/1Test-CBY-86DF45BF-CMV2B1/1运行043S172.17.125.37K8S-NODE01hostname-test-test-cby-86df45bf45bf-f45bf-f45bf-f6drb1/1运行043S172.17.125.41K8S-NODE01<无><无无>hostname-test-cby-86df45bf-g79x21/1运行043S172.27.14.232K8S-NODE02hostName-test-cby-86df45bf-H6Blv1/1hostname-test-cby-86df45bf-hqjnj1/1正在运行043s172.17.125.40k8s-node01<无>Hostname-Test-CBY-86DF45BF-JT2RZ1Running043S172.27.14.236K8S-NODE02Hostname-Test-CBY-8JJN1/1RunningNODE02Hostname-Test-CBY-86DF45BF-VFKBT1运行043S172.17.125.39K8S-NODE01<无>主机名-TEST-86DF45BF-Z2x2X1/3SNING043SNING.14.234k8s-node02<无><无>root@hello:~#enterpodto检查#访问测试root@hello:~#curl172.17.125.38123root@hello:~#root@hello:~#kubectlexechostname-test-cby-86df45bf-9fx5n-it--/bin/bashroot@hostname-test-cby-86df45bf-9fx5n:/##查看dns解析root@hostname-test-cby-86df45bf-9fx5n:/#cat/etc/resolv.confsearchdefault.svc.cluster.localsvc.cluster.localcluster.localnameserver10.96.0.10optionsndots:5root@hostname-test-cby-86df45bf-9fx5n:/##检查host配置是否生效root@hostname-test-cby-86df45bf-9fx5n:/#cat/etc/hosts#Kubernetes管理的hostsfile.127.0.0.1localhost::1localhostip6-localhostip6-loopbackfe00::0ip6-localnetfe00::0ip6-mcastprefixfe00::1ip6-allnodesfe00::2ip6-allrouters172.27.14.197hostname-test-cby-86df45bf-9fx5n#HostAliases.192.168.1.1添加的条目1.cn2。cn2cby.chen.10chenbychenby.chenby.cnroot@hostname-test-cby-86df45bf-9fx5n:/##查看环境变量root@hostname-test-cby-86df45bf-9fx5n:/#echo$cbychenbyroot@hostname-test-cby-86df45bf-9fx5n:/#https://www.oiox.cn/https://www.chenby.cn/https://cby-chen.github.io/https://blog.csdn.net/qq\_33921750https://my.oschina.net/u/3981543https://www.zhihu.com/people/...https://segmentfault.com/u/hp...https://juejin.cn/user/331578...https://cloud.tencent.com/dev...https://www.jianshu.com/u/0f8...https://www.toutiao.com/c/使用。..CSDN、GitHub、知乎,开源中国,师傅,掘金,简书,腾讯云,今日头条,个人博客,可全网搜索《小陈运维》文章主要发表于微信公众号:《Linux运维交流社区》