k8s.tpl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: {{NAMESPACE}}
  5. ---
  6. apiVersion: v1
  7. kind: Service
  8. metadata:
  9. name: {{APP_NAME}}-nodeport
  10. namespace: {{NAMESPACE}}
  11. spec:
  12. type: NodePort
  13. ports:
  14. - port: 8080
  15. targetPort: 8080
  16. selector:
  17. app: {{APP_NAME}}
  18. ---
  19. apiVersion: v1
  20. kind: Service
  21. metadata:
  22. name: {{APP_NAME}}
  23. namespace: {{NAMESPACE}}
  24. spec:
  25. type: ClusterIP
  26. ports:
  27. - port: 8080
  28. protocol: TCP
  29. targetPort: 8080
  30. selector:
  31. app: {{APP_NAME}}
  32. ---
  33. apiVersion: apps/v1
  34. kind: Deployment
  35. metadata:
  36. name: {{APP_NAME}}
  37. namespace: {{NAMESPACE}}
  38. spec:
  39. selector:
  40. matchLabels:
  41. app: {{APP_NAME}}
  42. replicas: 1
  43. template:
  44. metadata:
  45. labels:
  46. app: {{APP_NAME}}
  47. spec:
  48. containers:
  49. - name: {{APP_NAME}}
  50. env:
  51. - name: TZ
  52. value: Asia/Shanghai
  53. image: {{IMAGE_URL}}:{{IMAGE_TAG}}
  54. imagePullPolicy: IfNotPresent
  55. ports:
  56. - containerPort: 8080
  57. name: port
  58. protocol: TCP
  59. command: ["/bin/sh"]
  60. args: ["-c", "set -e && java -jar app.jar --spring.profiles.active={{PROFILES}} --server.port=8080"]
  61. ---
  62. apiVersion: extensions/v1beta1
  63. kind: Ingress
  64. metadata:
  65. annotations:
  66. name: {{APP_NAME}}-ingress
  67. namespace: {{NAMESPACE}}
  68. spec:
  69. rules:
  70. - host: {{HOST}}
  71. http:
  72. paths:
  73. - backend:
  74. serviceName: {{APP_NAME}}
  75. servicePort: 8080
  76. path: /