apiVersion: apps/v1 kind: Deployment metadata: labels: app: $APP_NAME version: $APP_TAG name: $APP_NAME namespace: default #一定要写名称空间 spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 2 selector: matchLabels: app: $APP_NAME strategy: rollingUpdate: maxSurge: 50% maxUnavailable: 50% type: RollingUpdate template: metadata: labels: app: $APP_NAME version: $APP_TAG spec: imagePullSecrets: - name: dockerhub-id #提前在项目下配置访问阿里云的账号密码 containers: - image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG name: $APP_NAME imagePullPolicy: Always livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复 httpGet: path: /test port: 13145 initialDelaySeconds: 10 # 延迟xx秒开始执行 periodSeconds: 15 # 每隔15秒执行一次 timeoutSeconds: 10 # 10秒未返回结果则超时 failureThreshold: 10 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败 # successThreshold: 5 ports: - containerPort: 13145 protocol: TCP resources: limits: cpu: 99m memory: 65Mi env: - name: TZ value: "Asia/Shanghai" --- apiVersion: v1 kind: Service metadata: labels: app: $APP_NAME name: $APP_NAME namespace: default spec: type: NodePort externalTrafficPolicy: Local ports: - name: http protocol: TCP port: 13145 nodePort: 30045 selector: app: $APP_NAME