--以yaml格式输出:pod\configmap\service\ingress\deployment
kubectl get pod platform-financeapi-deployment-6d9ff7dc8f-l774l -n alpha --output=yaml kubectl get configmap platform-website-config -n alpha --output=yaml kubectl get service platform-website -n alpha --output=yaml kubectl get ingress platform-website-ingress -n alpha --output=yaml kubectl get deployment platform-website-deployment -n alpha --output=yaml
#describe pod\deployments\service\

kubectl desribe pods platform-website-deployment-5bbb9b7976-fjrnk -n alpha

kubectl describe deployment platform-website-deployment -n alpha

kubectl describe service platform-website -n alpha

kubectl describe configmap platform-website-config -n alpha

kubectl describe ingress platform-website-ingress -n alpha

  

OOMKilled : out of memory (OOM)

  

Memory units

The memory resource is measured in bytes.

You can express memory as a plain integer or a fixed-point integer with one of these suffixes: E, P, T, G, M, K, Ei, Pi, Ti, Gi, Mi, Ki

128974848, 129e6, 129M , 123Mi

  

memory requests and limits

By configuring memory requests and limits for the Containers that run in your cluster, you can make efficient use of the memory resources available on your cluster’s Nodes.

By keeping a Pod’s memory request low, you give the Pod a good chance of being scheduled.

By having a memory limit that is greater than the memory request, you accomplish two things:

  • The Pod can have bursts of activity where it makes use of memory that happens to be available.
  • The amount of memory a Pod can use during a burst is limited to some reasonable amount.

CPU units

The CPU resource is measured in cpu units. One cpu, in Kubernetes, is equivalent to:

  • 1 AWS vCPU
  • 1 GCP Core
  • 1 Azure vCore
  • 1 Hyperthread on a bare-metal Intel processor with Hyperthreading

Fractional values are allowed. A Container that requests 0.5 cpu is guaranteed half as much CPU as a Container that requests 1 cpu.

You can use the suffix m to mean milli. For example 100m cpu, 100 millicpu, and 0.1 cpu are all the same. Precision finer than 1m is not allowed.

CPU is always requested as an absolute quantity, never as a relative quantity; 0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine.

CPU requests and limits

By configuring the CPU requests and limits of the Containers that run in your cluster, you can make efficient use of the CPU resources available on your cluster’s Nodes.

By keeping a Pod’s CPU request low, you give the Pod a good chance of being scheduled.

By having a CPU limit that is greater than the CPU request, you accomplish two things:

  • The Pod can have bursts of activity where it makes use of CPU resources that happen to be available.
  • The amount of CPU resources a Pod can use during a burst is limited to some reasonable amount.

Quality of Service (QoS) classes

Kubernetes uses QoS classes to make decisions about scheduling and evicting Pods.

When Kubernetes creates a Pod it assigns one of these QoS classes to the Pod:

  • Guaranteed
  • Burstable
  • BestEffort

For a Pod to be given a QoS class of Guaranteed:

  • Every Container in the Pod must have a memory limit and a memory request, and they must be the same.
  • Every Container in the Pod must have a cpu limit and a cpu request, and they must be the same.

A Pod is given a QoS class of Burstable if:

  • The Pod does not meet the criteria for QoS class Guaranteed.
  • At least one Container in the Pod has a memory or cpu request.

For a Pod to be given a QoS class of BestEffort,

  • the Containers in the Pod must not have any memory or cpu limits or requests.

Create a Pod that has two Containers

apiVersion: v1
kind: Pod
metadata:
name: qos-demo-4
namespace: qos-example
spec:
containers: - name: qos-demo-4-ctr-1
image: nginx
resources:
requests:
memory: "200Mi" - name: qos-demo-4-ctr-2
image: redis

Notice that this Pod meets the criteria for QoS class Burstable.

That is, it does not meet the criteria for QoS class Guaranteed, and one of its Containers has a memory request. 

Assign an extended resource to a Pod

To request an extended resource, include the resources:requests field in your Container manifest.

Extended resources are fully qualified with any domain outside of *.kubernetes.io/.

Valid extended resource names have the form example.com/foo where example.com is replaced with your organization’s domain and foo is a descriptive resource name.

apiVersion: v1
kind: Pod
metadata:
name: extended-resource-demo
spec:
containers:
- name: extended-resource-demo-ctr
image: nginx
resources:
requests:
example.com/dongle: 3
limits:
example.com/dongle: 3

In the configuration file, you can see that the Container requests 3 dongles.  

apiVersion: v1
kind: Pod
metadata:
name: extended-resource-demo-2
spec:
containers:
- name: extended-resource-demo-2-ctr
image: nginx
resources:
requests:
example.com/dongle: 2
limits:
example.com/dongle: 2

Kubernetes will not be able to satisfy the request for two dongles, because the first Pod used three of the four available dongles.

Configure a Pod to Use a Volume for Storage

A Container’s file system lives only as long as the Container does, so when a Container terminates and restarts, changes to the filesystem are lost.

For more consistent storage that is independent of the Container, you can use a Volume.

This is especially important for stateful applications, such as key-value stores and databases.

For example, Redis is a key-value cache and store.

Configure a volume for a Pod

This Pod has a Volume of type emptyDir that lasts for the life of the Pod, even if the Container terminates and restarts.

apiVersion: v1
kind: Pod
metadata:
name: redis
spec:
containers:
- name: redis
image: redis
volumeMounts:
- name: redis-storage
mountPath: /data/redis
volumes:
- name: redis-storage
emptyDir: {}
#pod:redis
kubectl get pod redis –watch
kubectl exec -it redis – /bin/bash #go to /data/redis, and create a file:
root@redis:/data# cd /data/redis/
root@redis:/data/redis# echo Hello > test-file #list the running processes
root@redis:/data/redis# ps aux #kill the redis process
#where <pid> is the redis process ID (PID)
root@redis:/data/redis# kill #In your original terminal, watch for changes to the redis Pod
kubectl get pod redis –watch #At this point, the Container has terminated and restarted. This is because the redis Pod has a restartPolicy of Always.
kubectl exec -it redis – /bin/bash #goto /data/redis, and verify that test-file is still there
root@redis:/data# cd /data/redis/

  

  

kubernetes 实战2_命令_Configure Pods and Containers的更多相关文章

  1. kubernetes 实战4_命令_Configure Pods and Containers

    Configure Service Accounts for Pods A service account provides an identity for processes that run in ...

  2. kubernetes 实战3_命令_Configure Pods and Containers

    Configure a Pod to Use a PersistentVolume for Storage how to configure a Pod to use a PersistentVolu ...

  3. kubernetes 实战5_命令_Assign Pods to Nodes&Configure a Pod to Use a ConfigMap

    Assign Pods to Nodes how to assign a Kubernetes Pod to a particular node in a Kubernetes cluster. Ad ...

  4. kubernetes 实战6_命令_Share Process Namespace between Containers in a Pod&Translate a Docker Compose File to Kubernetes Resources

    Share Process Namespace between Containers in a Pod how to configure process namespace sharing for a ...

  5. kubernetes实战(二十八):Kubernetes一键式资源管理平台Ratel安装及使用

    1. Ratel是什么? Ratel是一个Kubernetes资源平台,基于管理Kubernetes的资源开发,可以管理Kubernetes的Deployment.DaemonSet.Stateful ...

  6. Kubernetes实战总结 - 阿里云ECS自建K8S集群

    一.概述 详情参考阿里云说明:https://help.aliyun.com/document_detail/98886.html?spm=a2c4g.11186623.6.1078.323b1c9b ...

  7. kubernetes实战(二十六):kubeadm 安装 高可用 k8s v1.16.x dashboard 2.x

    1.基本配置 基本配置.内核升级.基本服务安装参考https://www.cnblogs.com/dukuan/p/10278637.html,或者参考<再也不踩坑的Kubernetes实战指南 ...

  8. kubernetes实战(二十九):Kubernetes RBAC实现不同用户在不同Namespace的不同权限

    1.基本说明 在生产环境使用k8s以后,大部分应用都实现了高可用,不仅降低了维护成本,也简化了很多应用的部署成本,但是同时也带来了诸多问题.比如开发可能需要查看自己的应用状态.连接信息.日志.执行命令 ...

  9. kubernetes实战(三十):CentOS 8 二进制 高可用 安装 k8s 1.17.x

    1. 基本说明 本文章将演示CentOS 8二进制方式安装高可用k8s 1.17.x,相对于其他版本,二进制安装方式并无太大区别. 2. 基本环境配置 主机信息 192.168.1.19 k8s-ma ...

随机推荐

  1. mysql批量插入,批量更新

    进行批量操作的时候,一定要事先判断数组非空 <insert id="batchInsert"parameterType="java.util.List"& ...

  2. 类中静态成员变量 && 无法解析的外部符号

    [1]如下代码及编译错误 如标题,不做赘述. [2]原因及解决方案 原因:之所以报如上编译错误,因为静态成员变量未初始化. 解决方案:类中静态成员需要在类外进行初始化.其格式为:类型 类名::静态成员 ...

  3. jfinal 项目 控制层、ORM层、AOP层,在发表之前一定要记得保存

    一.ORM简介 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术.简单的说,ORM是通过使用描述对象和数据 ...

  4. plsql注册-转

    注册码:Product Code:4t46t6vydkvsxekkvf3fjnpzy5wbuhphqzserial Number:601769 password:xs374ca https://blo ...

  5. numpy.random随机数生成

    seed 确定随机数生成器的种子 permutation 返回一个序列的随机排列或返回一个随机排列的返回 shuffle 对一个序列就地随机乱序 rand 产生均匀分布的样本值 randint 从给定 ...

  6. 转:CTE(公共表表达式)——WITH子句

    来自:<Microsoft SQL Server 2008技术内幕:T-SQL语言基础> 一.公共表表达式(CTE,Common Table Expression)是在SQL Server ...

  7. Python+OpenCV图像处理(二)——打印图片属性、设置图片存储路径、电脑摄像头的调取和显示

    一. 打印图片属性.设置图片存储路径 代码如下: #打印图片的属性.保存图片位置 import cv2 as cv import numpy as np #numpy是一个开源的Python科学计算库 ...

  8. web前端学习路线:HTML5教程之前端模块化开发

    1. 命名冲突 首先从一个简单的习惯开始. 由于以前一直做 JavaEE 开发的缘故,在 JavaScript 开发中,我已经习惯将项目中的一些通用功能抽象出来,形成一个个的独立函数,以便于实现代码复 ...

  9. 怎样从外网访问内网Tomcat?

    本地安装了一个Tomcat,只能在局域网内访问,怎样从外网也能访问到本地的Tomcat呢?本文将介绍具体的实现步骤. 准备工作 安装并启动Tomcat 默认安装的Tomcat端口是8080. 实现步骤 ...

  10. 知乎上一个比较好的学习QT的公众号<<跟小豆君学Qt>>

    公众号网址:https://zhuanlan.zhihu.com/p/28472916