微服务部署-k8s-yaml

微服务部署-k8s-yaml

标签: k8s  

[TOC]

增加了hostalias、configmap、java启动参数等等,优先级高于Dockerfile

---
apiVersion: v1
data:
  common: |-
    server:
      tomcat:
        uri-encoding: UTF-8
        accesslog:
          enabled: true
          directory: /logs
          pattern: '%h %l %u %t %r %s %b %{Referer}i %{User-Agent}i %D'
kind: ConfigMap
metadata:
  name: tm-mi 
  namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: tm-mi
  name: tm-mi
  namespace: default
spec:
  minReadySeconds: 90
  replicas: 2
  selector:
    matchLabels:
      name: tm-mi
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        name: tm-mi
    spec:
      containers:
      - args:
        - -server
        - -Xms1600m
        - -Xmx1600m
        - -Xmn400m
        - -XX:SurvivorRatio=4
        - -Xss320K
        - -XX:+UseConcMarkSweepGC
        - -XX:+PrintGC
        - -verbose:gc
        - -Xloggc:/logs/gc.log
        - -XX:+PrintGCDetails
        - -XX:+PrintGCDateStamps
        - -XX:+ExplicitGCInvokesConcurrent
        - -jar
        - xk-tm-service-mi.jar
        command:
        - java
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: prod,common
        - name: SPRING_DATASOURCE_USERNAME
          value: "cld_tm_mi"
        - name: SPRING_DATASOURCE_PASSWORD
          value: "XTYL#0419prod"
        image: harbor.xikang.com/bj_xk_xtyl/tm-mi:550560_07141803
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: 8520
            scheme: HTTP
          initialDelaySeconds: 300
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 1
        name: tm-mi
        ports:
        - containerPort: 8520
          name: 8520tcp00
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: 8520
            scheme: HTTP
          initialDelaySeconds: 30
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 30
        volumeMounts:
        - mountPath: /logs
          name: log-storage
        - mountPath: /opt/tm-mi-service/config/application-common.yml
          name: config-common
          subPath: common
        workingDir: /opt/tm-mi-service
      hostAliases:
      - hostnames:
        - tm-redis
        ip: 10.3.32.169
      - hostnames:
        - tm-activemq
        ip: 10.3.32.169
      - hostnames:
        - 10-3-58-12.xikang.com
        ip: 10.3.58.12
      - hostnames:
        - tm-mysql-mi
        ip: 10.3.140.14
      restartPolicy: Always
      volumes:
      - hostPath:
          path: /data/logs/tm-mi
        name: log-storage
      - configMap:
          name: tm-mi
          optional: false
        name: config-common


---
kind: Service
apiVersion: v1
metadata:
  name: tm-mi
  labels:
    name: tm-mi
spec:
  type: NodePort 
  ports:
  - protocol: TCP
    nodePort: 31809
    targetPort: 8520
    port: 8520
  selector:
    name: tm-mi

「真诚赞赏,手留余香」

Uwei

请我喝杯咖啡?

使用微信扫描二维码完成支付

相关文章