apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
stratgy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
replicas: 2 # 告知 Deployment 运行 2 个与该模板匹配的 Pod
template:
metadata:
labels:
app: nginx
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: gcs
operator: In
values:
- gcs
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx
topologyKey: kubernetes.io/hostname
automountServiceAccountToken: false
containers:
- args:
- ip=`hostname -i` ; server_name="nginx" ; port="8080" ; /etc/jre/bin/java -jar -Dhwenvironment=pro -Dspring.config.additional-location=file:/opt/configmap/application.yml -Xmx1344M -Xms1344M -Xmn448M -XX:MaxMetaspaceSize=192M -XX:MetaspaceSize=192M -XX:+UseG1GC -Duser.timezone=GMT+08 /opt/xxxx.jar
command:
- /bin/sh
- -c
env:
- name: HOSTIP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
- name: PODIP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
name: nginx
image: nginx:1.14.2
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: "1"
memory: 4Gi
requests:
cpu: 300m
memory: 2000Mi
containers:
- command:
- /etc/jre/bin/java
- -jar
- -Dhwenvironment=pro
- -Dspring.config.additional-location=file:/opt/configmap/application.yml
- -Duser.timezone=GMT+08
- /opt/xxxx.jar
env:
- name: HOSTIP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
name: nginx
image: nginx:1.14.2
imagePullPolicy: Always
containers:
- command:
- bash
- -c
- /etc/jre/bin/java -jar -Dhwenvironment=pro -Dspring.config.additional-location=file:/opt/configmap/application.yml -Xmx1344M -Xms1344M -Xmn448M -XX:MaxMetaspaceSize=192M -XX:MetaspaceSize=192M -XX:+UseG1GC -Duser.timezone=GMT+08 /opt/xxxx.jar
env:
- name: HOSTIP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP