From 2cb591917de7e4e2099f0b5fef2c02ec552371f5 Mon Sep 17 00:00:00 2001 From: pepsi Date: Wed, 21 Sep 2022 16:23:01 +0800 Subject: [PATCH] add docker file&deployment.yaml --- Dockerfile | 3 ++ deployment.yaml | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 Dockerfile create mode 100644 deployment.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5cf849c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM harbor.axzo.cn/images_base/jdk1.8-fc:v1 +COPY xlog-server/target/xlog-server.jar ./xlog-server.jar +ENTRYPOINT [{ENTRYPOINT}] diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 0000000..06ab3af --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,123 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {ProjectName} +spec: + minReadySeconds: 2 + replicas: 1 + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: {ProjectName} + template: + metadata: + labels: + app: {ProjectName} + prometheus: {PROMETHEUS} + logging: '{LOGGING}' + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: work + operator: In + values: + - {nodeSelector} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - {ProjectName} + topologyKey: kubernetes.io/hostname + weight: 100 + terminationGracePeriodSeconds: 60 ##k8s将会给应用发送SIGTERM信号,可以用来正确、优雅地关闭应用,默认为30秒 + containers: + - name: {ProjectName} + image: registry.cn-hangzhou.aliyuncs.com/axzo-k8s/{namespace}-{ProjectName}:{BUILD_ID} + imagePullPolicy: Always + livenessProbe: #该pod是存活的,不存活则需要重启 + httpGet: + path: /checkDeath + port: {port} + scheme: HTTP + initialDelaySeconds: 60 ## equals to the maximum startup time of the application + couple of seconds + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + readinessProbe: #kubernetes认为该pod是启动成功的 + httpGet: + path: /checkDeath + port: {port} + scheme: HTTP + initialDelaySeconds: 30 ## equals to minimum startup time of the application + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + volumeMounts: + - name: tz-config + mountPath: /etc/localtime + - name: jmx-exporter + mountPath: /data/jmx + env: + - name: NACOS_HOST + value: {NACOS_HOST} + - name: NACOS_PORT + value: "{NACOS_PORT}" + - name: NACOS_NAMESPACE_ID + value: {NACOS_NAMESPACE_ID} + - name: NACOS_PROFILES_ACTIVE + value: {NACOS_PROFILES_ACTIVE} + - name: MY_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: MY_POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + ports: + - containerPort: {port} + resources: + limits: + memory: {limitMemory} + requests: + memory: {requestsMemory} + imagePullSecrets: + - name: aliyun + volumes: + - name: tz-config + hostPath: + path: /usr/share/zoneinfo/Asia/Shanghai + - name: jmx-exporter + persistentVolumeClaim: + claimName: jmx + +--- + +apiVersion: v1 +kind: Service +metadata: + name: {ProjectName} + labels: + app: {ProjectName} +spec: + type: ClusterIP + ports: + - port: {port} + targetPort: {port} + selector: + app: {ProjectName}