1.图示
2.yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
prometheus.io/scrape: 'true'
labels:
app: es-api-gateway
appname: es-api-gateway
env: pro
name: es-api-gateway
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 2
revisionHistoryLimit: 10
selector:
matchLabels:
app: es-api-gateway
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
prometheus.io/path: /actuator/prometheus
prometheus.io/scrape: 'true'
labels:
app: es-api-gateway
appname: es-api-gateway
env: pro
spec:
containers:
- env:
- name: LANG
value: en_US.UTF-8
- name: LANGUAGE
value: 'en_US:en'
- name: LC_ALL
value: en_US.UTF-8
- name: JAVA_HOME
value: /opt/java/openjdk
image: >-
registry.aliyuncs.com/wx-k8s-pro/es-api-gateway:v2020-0731-113135
imagePullPolicy: IfNotPresent
lifecycle:
postStart:
exec:
command:
- /bin/sh
- '-c'
- >-
mkdir -p /home/mount/${HOSTNAME} && ln -s
/home/mount/${HOSTNAME}
/home/wx/services/es-api-gateway/logs
name: es-api-gateway
ports:
- containerPort: 11000
name: http
protocol: TCP
resources:
limits:
cpu: 2100m
memory: 2500Mi
requests:
cpu: 10m
memory: 1Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/localtime
name: volume-localtime
- mountPath: /home/mount
name: volume-1588659668375
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /etc/localtime
type: ''
name: volume-localtime
- hostPath:
path: /home/wx/services/es-api-gateway
type: ''
name: volume-1588659668375
3.理解限制资源与所需资

资源限制(limits):限制容器最大使用资源量,超出限制容器重启
所需资源(requests):例如~node资源4核4G内存,4核=4000m,4G=4096MiB,控制此node可以部署多少个容器