220 lines
No EOL
6.2 KiB
Markdown
220 lines
No EOL
6.2 KiB
Markdown
运行容器通过volumeMount方式挂载使用初始化容器中的可执行软件
|
|
|
|
```yaml
|
|
kind: Deployment
|
|
apiVersion: apps/v1
|
|
metadata:
|
|
name: echo-server-1
|
|
namespace: dev
|
|
labels:
|
|
app: echo-server-1
|
|
app.kubernetes.io/instance: echo-server-dev
|
|
annotations:
|
|
deployment.kubernetes.io/revision: '9'
|
|
managedFields:
|
|
- manager: cfe-apiserver
|
|
operation: Update
|
|
apiVersion: apps/v1
|
|
time: '2023-09-14T11:26:44Z'
|
|
fieldsType: FieldsV1
|
|
fieldsV1:
|
|
f:metadata:
|
|
f:labels:
|
|
.: {}
|
|
f:app: {}
|
|
f:app.kubernetes.io/instance: {}
|
|
f:spec:
|
|
f:progressDeadlineSeconds: {}
|
|
f:replicas: {}
|
|
f:revisionHistoryLimit: {}
|
|
f:selector: {}
|
|
f:strategy:
|
|
f:rollingUpdate:
|
|
.: {}
|
|
f:maxSurge: {}
|
|
f:maxUnavailable: {}
|
|
f:type: {}
|
|
f:template:
|
|
f:metadata:
|
|
f:labels:
|
|
.: {}
|
|
f:app: {}
|
|
f:spec:
|
|
f:containers:
|
|
k:{"name":"runtime"}:
|
|
.: {}
|
|
f:command: {}
|
|
f:env:
|
|
.: {}
|
|
k:{"name":"ARGS"}:
|
|
.: {}
|
|
f:name: {}
|
|
f:valueFrom:
|
|
.: {}
|
|
f:configMapKeyRef: {}
|
|
k:{"name":"JAVA_OPTS"}:
|
|
.: {}
|
|
f:name: {}
|
|
f:valueFrom:
|
|
.: {}
|
|
f:configMapKeyRef: {}
|
|
f:image: {}
|
|
f:imagePullPolicy: {}
|
|
f:name: {}
|
|
f:ports:
|
|
.: {}
|
|
k:{"containerPort":48080,"protocol":"TCP"}:
|
|
.: {}
|
|
f:containerPort: {}
|
|
f:name: {}
|
|
f:protocol: {}
|
|
f:resources: {}
|
|
f:terminationMessagePath: {}
|
|
f:terminationMessagePolicy: {}
|
|
f:volumeMounts:
|
|
.: {}
|
|
k:{"mountPath":"/opt"}:
|
|
.: {}
|
|
f:mountPath: {}
|
|
f:name: {}
|
|
f:readOnly: {}
|
|
f:dnsPolicy: {}
|
|
f:imagePullSecrets:
|
|
.: {}
|
|
k:{"name":"swrregistrykey"}: {}
|
|
f:initContainers:
|
|
.: {}
|
|
k:{"name":"busybox"}:
|
|
.: {}
|
|
f:command: {}
|
|
f:image: {}
|
|
f:imagePullPolicy: {}
|
|
f:name: {}
|
|
f:resources: {}
|
|
f:terminationMessagePath: {}
|
|
f:terminationMessagePolicy: {}
|
|
f:volumeMounts:
|
|
.: {}
|
|
k:{"mountPath":"/tmp"}:
|
|
.: {}
|
|
f:mountPath: {}
|
|
f:name: {}
|
|
f:restartPolicy: {}
|
|
f:schedulerName: {}
|
|
f:securityContext: {}
|
|
f:terminationGracePeriodSeconds: {}
|
|
f:volumes:
|
|
.: {}
|
|
k:{"name":"work"}:
|
|
.: {}
|
|
f:emptyDir: {}
|
|
f:name: {}
|
|
- manager: kube-controller-manager
|
|
operation: Update
|
|
apiVersion: apps/v1
|
|
time: '2023-09-14T11:26:47Z'
|
|
fieldsType: FieldsV1
|
|
fieldsV1:
|
|
f:metadata:
|
|
f:annotations:
|
|
.: {}
|
|
f:deployment.kubernetes.io/revision: {}
|
|
f:status:
|
|
f:availableReplicas: {}
|
|
f:conditions:
|
|
.: {}
|
|
k:{"type":"Available"}:
|
|
.: {}
|
|
f:lastTransitionTime: {}
|
|
f:lastUpdateTime: {}
|
|
f:message: {}
|
|
f:reason: {}
|
|
f:status: {}
|
|
f:type: {}
|
|
k:{"type":"Progressing"}:
|
|
.: {}
|
|
f:lastTransitionTime: {}
|
|
f:lastUpdateTime: {}
|
|
f:message: {}
|
|
f:reason: {}
|
|
f:status: {}
|
|
f:type: {}
|
|
f:observedGeneration: {}
|
|
f:readyReplicas: {}
|
|
f:replicas: {}
|
|
f:updatedReplicas: {}
|
|
subresource: status
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: echo-server-1
|
|
template:
|
|
metadata:
|
|
creationTimestamp: null
|
|
labels:
|
|
app: echo-server-1
|
|
spec:
|
|
volumes:
|
|
- name: work
|
|
emptyDir: {}
|
|
initContainers:
|
|
- name: busybox
|
|
image: server:202309141053
|
|
command:
|
|
- cp
|
|
- /opt/app.jar
|
|
- /tmp
|
|
resources: {}
|
|
volumeMounts:
|
|
- name: work
|
|
mountPath: /tmp
|
|
terminationMessagePath: /dev/termination-log
|
|
terminationMessagePolicy: File
|
|
imagePullPolicy: IfNotPresent
|
|
containers:
|
|
- name: runtime
|
|
image: openjdk:8-jdk
|
|
command:
|
|
- java
|
|
- '-jar'
|
|
- /opt/app.jar
|
|
- $ARGS
|
|
ports:
|
|
- name: http
|
|
containerPort: 48080
|
|
protocol: TCP
|
|
env:
|
|
- name: JAVA_OPTS
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: echo-server-cm
|
|
key: JAVA_OPTS
|
|
- name: ARGS
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: echo-server-cm
|
|
key: ARGS
|
|
resources: {}
|
|
volumeMounts:
|
|
- name: work
|
|
readOnly: true
|
|
mountPath: /opt
|
|
terminationMessagePath: /dev/termination-log
|
|
terminationMessagePolicy: File
|
|
imagePullPolicy: IfNotPresent
|
|
restartPolicy: Always
|
|
terminationGracePeriodSeconds: 30
|
|
dnsPolicy: ClusterFirst
|
|
securityContext: {}
|
|
imagePullSecrets:
|
|
- name: swrregistrykey
|
|
schedulerName: default-scheduler
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxUnavailable: 25%
|
|
maxSurge: 25%
|
|
revisionHistoryLimit: 10
|
|
progressDeadlineSeconds: 600
|
|
``` |