import re
import os
import sys

POD_NAME = sys.argv[1];
NODE_PORT = sys.argv[2];
with open("dd.yml",'w') as f:
    f.write(
'''
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ''' + POD_NAME + '''
  labels: 
    app: ''' + POD_NAME + '''
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ''' + POD_NAME + '''
  template:
    metadata:
      labels:
        app: ''' + POD_NAME + '''
    spec:
      containers:
        - name: app
          image: karthickas/bcpdashboard:latest
          ports:
            - containerPort: 9097
          imagePullPolicy: Never
          env:
          - name: SPRING_DATASOURCE_URL
            value: jdbc:mysql://bcp-mysql:3306/bcp?autoReconnect=true&useSSL=false
      imagePullSecrets:
        - name: regcred
---

apiVersion: v1  
kind: Service  
metadata:  
  name: ''' + POD_NAME + '''  
spec:
  selector:
    app: ''' + POD_NAME + '''
  ports:
    - port: 9097
      targetPort: 9097
      nodePort: ''' + NODE_PORT + '''
  type: NodePort
---
'''
)