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

在b站看视频的好处广州最新新闻事件

在b站看视频的好处,广州最新新闻事件,物业公司和开发公司哪个好,深圳外贸soho网站建设HPA pod的数量进行扩缩容 针对控制器创建的pod deployment: replica: 静态:edit yaml:apply -f HPA:基于cpu的利用率来实现pod数量的自动伸缩。 Horizontal pod autoscaling yaml文件————主流——————…

HPA

pod的数量进行扩缩容

针对控制器创建的pod

deployment:

replica:

静态:edit

yaml:apply -f

HPA:基于cpu的利用率来实现pod数量的自动伸缩。

Horizontal pod autoscaling

yaml文件————主流——————>必须要有资源控制这个字段才能生效。

命令行 生成hpa的配置

比要条件:

前置比要条件:控制创建,而且必须能设置副本数

配置的必要条件:必须要声明pod的资源控制。

依赖环境:

metrices-server hpa使用的依赖环境。k8s使用集群资源的集中查询器。收集资源使用数据,给HPA,scheduller等等使用

echo 1 > /proc/sys/vm/drop_caches # 释放页面缓存 
echo 2 > /proc/sys/vm/drop_caches # 释放目录项和inode缓存 
echo 3 > /proc/sys/vm/drop_caches # 释放所有缓存

[root@master01 hpa]# vim hpa.yaml
​
apiVersion: apps/v1
kind: Deployment
metadata:name: hpa-test1labels:hpa: test1
spec:replicas: 1selector:matchLabels:hpa: test1template:metadata:labels:hpa: test1spec:containers:- name: centosimage: centos:7command: ["/bin/bash", "-c", "yum install -y epel-release --nogpgcheck && yum install -y stress --nogpgcheck && sleep 3600"]volumeMounts:- name: yum1mountPath: /etc/yum.repos.d/resources:limits:cpu: "1"memory: 512Mivolumes:- name: yum1hostPath:path: /etc/yum.repos.d
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:name: hpa-centos1
spec:scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: hpa-test1
#就是用来匹配需要监控器类型和名称
#资源占用率高,要扩容,扩容的数量
#资源占用率低,要缩容,最小的保持数量
#定义扩缩容的指标,阈值。minReplicas: 1maxReplicas: 6targetCPUUtilizationPercentage: 50
#占用50%的cpu
​
[root@master01 nginx1]# kubectl top node node01 
NAME     CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
node01   328m         16%    1938Mi          52%   
[root@master01 hpa]# kubectl get hpa
NAME          REFERENCE               TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
hpa-centos2   StatefulSet/hpa-test1   0%/50%    1         6         2          2m13s
nginx1        Deployment/nginx1       1%/80%    1         6         1          64m

扩容和缩容的速度

扩容是一旦达到阈值,会立即扩容。

缩容的速度会相对较慢。

为了保证pod的正常工作,扩容必须要快。

缩容的时候为了保证pod的资源突然又变大了,可以继续维持pod的数量。在一定时间之内,pod占用的资源维持在了较低的比率,然后开始慢慢缩容。

对命名空间做资源限制:

[root@master01 hpa]# vim ns.yaml 
apiVersion: v1
kind: ResourceQuota
metadata:name: ns-xy102namespace: xy102
#对指定的命名空间进行资源限制
spec:hard:pods: "20"
#设置该命名空间可以创建pod的最大数量requests.cpu: "2"
#只能使用2个cpurequests.memory: 1Gi
#只能使用1个G的内存limits.cpu: "3"limits.memory: 2Gi
#limits是最多能使用多少configmaps: "10"
#创建configmap的数量限制persistentvolumeclaims: "4"
#创建pvc请求的限制secrets: "10"
#创建加密配置文件的限制services: "10"
#创建service的限制
​
[root@master01 hpa]# kubectl apply -f ns.yaml 
resourcequota/ns-xy102 created
[root@master01 hpa]# kubectl describe namespaces xy102 
Name:         xy102
Labels:       <none>
Annotations:  <none>
Status:       Active
​
Resource QuotasName:                   ns-xy102Resource                Used  Hard--------                ---   ---configmaps              1     10limits.cpu              0     3limits.memory           0     2Gipersistentvolumeclaims  0     4pods                    0     20requests.cpu            0     2requests.memory         0     1Gisecrets                 1     10services                0     10
​
No LimitRange resource.

limitRange:

只要是创建在这个命令空间的pod。都会根据limitRange的配置来对所有的pod进行统一的资源限制

[root@master01 hpa]# vim limitRange.yaml
​
apiVersion: v1name: xy102-limit
apiVersion: v1
kind: LimitRange
metadata:name: xy102-limitnamespace: xy102
#指定命名空间
spec:limits:- default:
#直接加default就相当于是上限memory: 1Gicpu: "4"defaultRequest:
#这个就是软限制memory: 1Gicpu: "4"type: Container
#指定类型,Container  pod  pvc
​
[root@master01 hpa]# kubectl describe namespaces xy102 
Name:         xy102
Labels:       <none>
Annotations:  <none>
Status:       Active
​
Resource QuotasName:                   ns-xy102Resource                Used  Hard--------                ---   ---configmaps              1     10limits.cpu              0     3limits.memory           0     2Gipersistentvolumeclaims  0     4pods                    0     20requests.cpu            0     2requests.memory         0     1Gisecrets                 1     10services                0     10
​
Resource LimitsType       Resource  Min  Max  Default Request  Default Limit  Max Limit/Request Ratio----       --------  ---  ---  ---------------  -------------  -----------------------Container  memory    -    -    1Gi              1Gi            -Container  cpu       -    -    4                4              -
​

helm:

nginx ingress

deployment

svc

ingress

heml提供了一个模板,可以一键化的部署微服务。

通过打包的方式,把所有需要的yaml文件集合一起,然后一键部署。

可以支持回滚。

heml

k8s的部署可以配置,可以集成,可以动态修改

三个概念:

Chart:部署安装k8s微服务的模板。类似于linux里面的rpm包。

Repository:仓库,仓库用来保存Chart

Release:当我们使用chart部署微服务时。每部署一次就会有一个Release。(理解为版本号)

[root@master01 opt]# rz -E
rz waiting to receive.
[root@master01 opt]# tar -xf helm-v3.10.0-linux-amd64.tar.gz
[root@master01 opt]# ls
linux-amd64
[root@master01 opt]# cd linux-amd64/
[root@master01 linux-amd64]# mv helm /usr/local/bin/
[root@master01 linux-amd64]# vim /etc/profile
source <(kubectl completion bash)
[root@master01 linux-amd64]# source /etc/profile
​
#安装仓库和模板
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add stable http://mirror.azure.cn/kubernetes/charts
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo add incubator https://charts.helm.sh/incubator
###上面这几个在master命令行输入
#更新当前所有仓库的chart
​
[root@master01 linux-amd64]# helm show chart aliyun/nginx-lego 
###查看chart的详情
​
[root@master01 linux-amd64]# helm repo remove aliyun
​
[root@master01 linux-amd64]# helm  install redis1 stable/redis -n default       
###用helm创建redis的pod
[root@master01 linux-amd64]# helm uninstall redis1 
release "redis1" uninstalled
###删除helm创建的pod

使用helm的yaml模板
[root@master01 opt]# mkdir helm
[root@master01 opt]# cd helm/
[root@master01 helm]# helm create nginx1
Creating nginx1
[root@master01 helm]# yum -y install tree
[root@master01 helm]# tree nginx1/
nginx1/
├── charts                  #依赖环境,一般为空,也不需要
├── Chart.yaml              #包含chart的元信息,chart的版本,名称等等
├── templates               #包含了部署k8s的应用pod的模板文件
│   ├── deployment.yaml     #基于控制器
│   ├── _helpers.tpl        
│   ├── hpa.yaml            #做hpa的监控,自动伸缩
│   ├── ingress.yaml        #对外访问
│   ├── NOTES.txt
│   ├── serviceaccount.yaml #创建服务账号
│   ├── service.yaml        #创建service的清单
│   └── tests
│       └── test-connection.yaml
└── values.yaml             #我们的配置在values里面完成,集合在了这个配置里面,当配置完成之后,可以通过values配置把参数传给 template里面的模板文件,进行覆盖。
​
3 directories, 10 files
[root@master01 nginx1]# vim values.yaml 
replicaCount: 3  ##更改副本数
​tag: "1.22"
#tag:使用镜像的版本号,不改默认最新
​
ingress:enabled: true
​
​hosts:- host: www.xy102.compaths:- path: /pathType: Prefix
​
resources:limits:cpu: 100mmemory: 128Mi# requests:#   cpu: 100m#   memory: 128Mi
​
autoscaling:enabled: trueminReplicas: 1maxReplicas: 6targetCPUUtilizationPercentage: 80

[root@master01 helm]# helm package nginx1/
Successfully packaged chart and saved it to: /opt/helm/nginx1-0.1.0.tgz
[root@master01 helm]# ls
nginx1  nginx1-0.1.0.tgz
[root@master01 helm]# helm install nginx1 /opt/helm/nginx1-0.1.0.tgz 
#第一次部署,release就是版本号,版本号1

http://www.ritt.cn/news/27906.html

相关文章:

  • 莱芜都市网官网seo优化论坛
  • wordpress站点进入时弹窗西安网是科技发展有限公司
  • 做公司的网站的需求有哪些内容全网营销推广方案
  • 建设银行信用卡管理中心网站首页百度教育会员
  • 建网站主机优化大师电脑版官方免费下载
  • 主流做网站网站建设全网营销
  • spark怎么做网站数据库seo优化范畴
  • 那里有做网站搜索引擎优化方法有哪几种
  • 在网站上做招聘版面网络营销的六大特征
  • php做网站框架哪个公司的网站制作
  • 中恒建设集团有限公司 网站搜索引擎入口大全
  • 自己做网站 有名6一份完整的市场调查方案
  • 有域名在本机上做网站推广赚钱的软件
  • 做区域分析的地图网站提高工作效率
  • 一起做网站广州重庆网站推广
  • 常平做网站百度推广首次开户需要多少钱
  • 网站建设含意如何优化网络速度
  • 外贸网站设计制作优化推广江苏网站推广
  • 淘客网站是怎么做的seo是什么职业
  • wordpress做商城网站吗资阳市网站seo
  • 网站备案接入商变更搜索引擎优化培训班
  • 怎么做韩剧网站的翻译淄博seo网络公司
  • 浦东做网站app平台搭建需要多少钱
  • 家居网站模板哈尔滨seo
  • html网站注册页面做网络推广要学些什么
  • 外贸网站哪个好搜索引擎营销名词解释
  • 上海住房和城乡建设厅网站首页广州竞价托管代运营
  • 手机网站怎样排版最好免费搭建自己的网站
  • 网站建设与运营财务预算网络营销的策划流程
  • 正规网站建设费用推广app赚佣金平台有哪些