TheArKa

kubernetes.yaml

Sep 10th, 2021 (edited)
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.13 KB | None | 0 0
  1. # Database Service
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5.   name: database-billing-service
  6. spec:
  7.   ports:
  8.     - port: 5432
  9.  
  10. ---
  11.  
  12. # Database Endpoint
  13. apiVersion: v1
  14. kind: Endpoints
  15. metadata:
  16.   name: database-billing-service
  17. subsets:
  18.   - addresses:
  19.       - ip: 192.168.9.199
  20.     ports:
  21.       - port: 5432
  22.  
  23. ---
  24.  
  25. # Influx Service
  26. apiVersion: v1
  27. kind: Service
  28. metadata:
  29.   name: influx-billing-service
  30. spec:
  31.   ports:
  32.     - port: 80
  33.  
  34. ---
  35.  
  36. # Influx Endpoint
  37. apiVersion: v1
  38. kind: Endpoints
  39. metadata:
  40.   name: influx-billing-service
  41. subsets:
  42.   - addresses:
  43.       - ip: 192.168.9.42
  44.     ports:
  45.       - port: 80
  46.      
  47. ---
  48.  
  49. # Keycloak Service
  50. apiVersion: v1
  51. kind: Service
  52. metadata:
  53.   name: keycloak-billing-service
  54. spec:
  55.   type: ExternalName
  56.   externalName: auth.kc-service.com # it's a real domain
  57.   ports:
  58.     - port: 80
  59.  
  60. ---
  61.  
  62. # Billing API Env
  63. apiVersion: v1
  64. kind: ConfigMap
  65. metadata:
  66.   name: billing-api-env
  67. data:
  68.   NODE_ENV: development
  69.  
  70.   KYECLOAK_SERVER_URL: keycloak-billing-service.default.svc.cluster.local/auth
  71.   # Other Keycloak env
  72.  
  73.   APP_PORT: "1234"
  74.   APP_URL: localhost
  75.   APP_NAME: "Billing Management API"
  76.  
  77.   INFLUX_HOST: influx-billing-service.default.svc.cluster.local
  78.   # Other Influx env
  79.  
  80.   PROD_DB_HOSTNAME: database-billing-service.default.svc.cluster.local
  81.   # Other DB env
  82.  
  83.   REDIS_HOST: localhost
  84.   REDIS_PORT: "6379"
  85.  
  86. ---
  87.  
  88. # Billing Web Env
  89. apiVersion: v1
  90. kind: ConfigMap
  91. metadata:
  92.   name: billing-web-env
  93. data:
  94.   REACT_APP_BASENAME: "Billing Management"
  95.   REACT_APP_API_HOST: "localhost:1234"
  96.   REACT_APP_KC_AUTH_SERVER_URL: keycloak-billing-service.default.svc.cluster.local/auth
  97.  
  98.  
  99. ---
  100.  
  101. # Billing Deployment
  102. apiVersion: apps/v1
  103. kind: Deployment
  104. metadata:
  105.   name: billing-management-deployment
  106. spec:
  107.   replicas: 3
  108.   selector:
  109.     matchLabels:
  110.       app: billing-management
  111.   template:
  112.     metadata:
  113.       name: billing-management
  114.       labels:
  115.         app: billing-management
  116.     spec:
  117.       containers:
  118.         - name: billing-redis
  119.           image: "redis"
  120.           ports:
  121.             - containerPort: 6379
  122.         - name: billing-api
  123.           image: "my-image-bill-api"
  124.           ports:
  125.             - containerPort: 1234
  126.           args:
  127.            - sh
  128.             - -c
  129.             - npm install && npx sequelize db:migrate && npm start
  130.           envFrom:
  131.             - configMapRef:
  132.                 name: billing-api-env
  133.         - name: billing-web
  134.           image: "my-image-bill-web"
  135.           ports:
  136.             - containerPort: 80
  137.           envFrom:
  138.             - configMapRef:
  139.                 name: billing-web-env
  140.  
  141. ---
  142.  
  143. # Billing Service
  144. apiVersion: v1
  145. kind: Service
  146. metadata:
  147.   name: billing-service
  148. spec:
  149.   selector:
  150.     app: billing-management
  151.   ports:
  152.     - name: billing-api
  153.       port: 1234
  154.       targetPort: 1234
  155.     - name: billing-web
  156.       port: 80
  157.       targetPort: 80
  158.  
  159. ---
  160.  
  161. # Inggress
  162. apiVersion: networking.k8s.io/v1
  163. kind: Ingress
  164. metadata:
  165.   name: billing-ingress
  166.   annotations:
  167.     nginx.ingress.kubernetes.io/ssl-redirect: "false"
  168.     nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
  169. spec:
  170.   rules:
  171.     - host: api.meetaza.dev
  172.       http:
  173.         paths:
  174.           - path: /v1/billing
  175.             pathType: Exact
  176.             backend:
  177.               service:
  178.                 name: billing-service
  179.                 port:
  180.                   number: 1234
  181.     - host: billing.meetaza.dev
  182.       http:
  183.         paths:
  184.           - path: /
  185.             pathType: Exact
  186.             backend:
  187.               service:
  188.                 name: billing-service
  189.                 port:
  190.                   number: 80
  191.  
  192. ---
  193.  
  194. # Additional Ingress ConfigMap
  195. apiVersion: v1
  196. kind: ConfigMap
  197. metadata:
  198.   name: ingress-nginx-controller
  199.   namespace: ingress-nginx
  200. data:
  201.  # hsts: "false"
  202.   # hsts-max-age: "0"
  203.   ssl-redirect: "false"
  204.   hsts: "true"
  205.   hsts-include-subdomains: "true"
  206.   hsts-max-age: "0"
  207.   hsts-preload: "false"
  208.  
  209. ---
  210.  
  211. # CURL for Testing
  212. apiVersion: v1
  213. kind: Pod
  214. metadata:
  215.   name: curl
  216.   labels:
  217.     name: curl
  218. spec:
  219.   containers:
  220.     - name: curl
  221.       image: khannedy/nginx-curl
Add Comment
Please, Sign In to add comment