apiVersion: xl/v2
kind: Blueprint

metadata:
  name: GCP-Microservice-GKE-with-JHipster
  description: |
    The blueprint deploys an e-commerce microservice application to GCP GKE.
    XL Deploy does the provisioning and deployment, while XL Release orchestrates everything.
  author: XebiaLabs
  version: 2.0
  instructions: Please read the generated file "xebialabs/USAGE.md" for further usage instructions.

spec:
  parameters:
  # General variables
  - name: AppName
    type: Input
    prompt: What is the name of the application?
  # GCP specific variables
  - name: GCPProjectID
    type: Input
    prompt: What is the GCP project ID?
  - name: K8SMasterUser
    type: Input
    prompt: What is the username for Kubernetes cluster?
    default: admin
  - name: K8SMasterPassword
    type: SecretInput
    prompt: What is the password for Kubernetes cluster? (minimum 16 characters)
    validate: !expr "regex('^(\\\\S){16,}$', K8SMasterPassword)"
  - name: GCPRegion
    type: Select
    prompt: "Select the GCP region:"
    options:
      - label: Taiwan
        value: asia-east1
      - label: Hong Kong
        value: asia-east2
      - label: Japan
        value: asia-northeast1
      - label: India
        value: asia-south1
      - label: Singapore
        value: asia-southeast1
      - label: Australia (Sydney)
        value: australia-southeast1
      - label: Finland
        value: europe-north1
      - label: Belgium
        value: europe-west1
      - label: England
        value: europe-west2
      - label: Germany
        value: europe-west3
      - label: Netherlands
        value: europe-west4
      - label: Canada
        value: northamerica-northeast1
      - label: Brazil
        value: southamerica-east1
      - label: Iowa, USA
        value: us-central1
      - label: South Carolina, USA
        value: us-east1
      - label: Northern Virginia, USA
        value: us-east4
      - label: Oregon, USA
        value: us-west1
      - label: California, USA
        value: us-west2

  - name: ProvisionCluster
    type: Confirm
    prompt: Do you want to provision a new GCP GKE cluster?
  - name: ClusterName
    type: Input
    prompt: What is the name of the cluster?
  - name: ClusterEndpoint
    type: Input
    prompt: What is the endpoint for the cluster, example https://104.155.109.230
    promptIf: !expr "!ProvisionCluster"
  - name: Namespace
    value: xl-demo
  - name: EnableCICD
    type: Confirm
    prompt: Do you want to enable CI/CD integration with Jenkins?
  - name: StoreAdminUsername
    value: admin
  - name: StoreAdminPassword
    type: SecretInput
    value: admin
  - name: XLDUrlForXLR
    type: Input
    prompt: XL Deploy URL for XL Release (This will only be used in the XL Release template)
    default: http://xl-deploy:4516

  - name: GenerateDockerComposeSetup
    type: Confirm
    prompt: "Do you want to generate a docker-compose setup with the tools to run this blueprint?"
    default: false

  includeAfter:
  - blueprint: xl-devops-platform
    includeIf: GenerateDockerComposeSetup
    parameterOverrides:
    - name: UseXLDeploy
      value: true
    - name: XLDeployPort
      value: 4516
    - name: UseXLRelease
      value: true
    - name: XLReleasePort
      value: 5516
    - name: JetPackOrEnterprise
      value: "XL Enterprise"
    - name: XLVersion
      value: "9.0.0"
    - name: UseDockerProxy
      value: false
    - name: UseJenkins
      value: !expr "EnableCICD"
    - name: JenkinsPort
      value: 8080
    - name: JenkinsBranch
      value: gke-blueprint

  files:
  - path: xebialabs/xld-infra-env.yaml.tmpl
  - path: xebialabs/xld-terraform-apps.yaml.tmpl
  - path: xebialabs/xld-kubernetes-invoice-app.yaml.tmpl
  - path: xebialabs/xld-kubernetes-store-app.yaml.tmpl
  - path: xebialabs/xld-kubernetes-notification-app.yaml.tmpl
  - path: xebialabs/xlr-pipeline-ci-cd.yaml.tmpl
  - path: xebialabs/xlr-pipeline-destroy.yaml.tmpl
  - path: xebialabs/USAGE.md.tmpl
  - path: terraform/gke/main.tf
    writeIf: ProvisionCluster
  - path: terraform/gke/outputs.tf
    writeIf: ProvisionCluster
  - path: terraform/gke/variables.tf
    writeIf: ProvisionCluster
  - path: terraform/vpc/main.tf
    writeIf: ProvisionCluster
  - path: terraform/vpc/outputs.tf
    writeIf: ProvisionCluster
  - path: terraform/vpc/variables.tf
    writeIf: ProvisionCluster
  - path: terraform/.gitignore
    writeIf: ProvisionCluster
  - path: terraform/backend.tf.tmpl
    writeIf: ProvisionCluster
  - path: terraform/main.tf
    writeIf: ProvisionCluster
  - path: terraform/outputs.tf
    writeIf: ProvisionCluster
  - path: terraform/variables.tf
    writeIf: ProvisionCluster
  - path: xebialabs.yaml
