apiVersion: xl/v2
kind: Blueprint

metadata:
  name: Kubernetes-Multicloud-Pipeline
  description: |
    An end-to-end blueprint that composes infrastructure (EKS / AKS / GKE), application (Kubernetes) and a pipeline.
  author: XebiaLabs
  version: 2.0
  instructions: Please read the generated file "xebialabs/USAGE-multicloud-pipeline.md" for further usage instructions.

spec:
  parameters:
  - name: Provider
    type: Select
    prompt: Which Kubernetes service provider do you want to use
    options:
    - label: Amazon
      value: EKS
    - label: Google Cloud
      value: GKE
    - label: Azure
      value: AKS
    - existing cluster

  - name: ClusterName
    type: Input
    prompt: "What do you want to name your cluster?"

  - 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: Namespace
    type: Input
    value: default

  - name: NamespaceTag
    type: Input
    value: kubernetes-namespace

  - name: GenerateDockerComposeSetup
    type: Confirm
    prompt: "Do you want to generate a docker-compose setup with the required tools to run this blueprint?"
    promptIf: !expr "Provider == 'existing cluster'"
    default: false

  includeAfter:
  - blueprint: kubernetes/environment
    includeIf: !expr "Provider == 'existing cluster'"
    parameterOverrides:
    - name: KubernetesName
      value: !expr "ClusterName"
    - name: KubernetesNamespace
      value: !expr "Namespace"

  - blueprint: aws/basic-eks-cluster
    includeIf: !expr "Provider == 'EKS'"
    fileOverrides:
    - path: xebialabs/aws-basic-eks-cluster.yaml
      writeIf: !expr "false"
    parameterOverrides:
    - name: ClusterName
      value: !expr "ClusterName"

  - blueprint: azure/basic-aks-cluster
    includeIf: !expr "Provider == 'AKS'"
    parameterOverrides:
    - name: ClusterName
      value: !expr "ClusterName"

  - blueprint: gcp/basic-gke-cluster
    includeIf: !expr "Provider == 'GKE'"
    fileOverrides:
    - path: xebialabs.yaml
      writeIf: !expr "false"
    parameterOverrides:
    - name: ClusterName
      value: !expr "ClusterName"

  - blueprint: kubernetes/application
    parameterOverrides:
    - name: NamespaceTag
      value: !expr "NamespaceTag"
    - name: Namespace
      value: !expr "Namespace"

  - blueprint: xl-devops-platform
    includeIf: GenerateDockerComposeSetup
    parameterOverrides:
    - name: UseXLDeploy
      value: true
    - name: XLDeployPort
      value: 4516
    - name: UseXLRelease
      value: true
    - name: XLReleasePort
      value: 5516
    - name: XLVersion
      value: "9.0"
    - name: UseDockerProxy
      value: false
    - name: UseJenkins
      value: false

  files:
  # XebiaLabs
  - path: xebialabs.yaml.tmpl
  - path: xebialabs/USAGE-multicloud-pipeline.md.tmpl
  - path: xebialabs/multicloud-pipeline.yaml.tmpl
    writeIf: !expr "Provider != 'EKS'"
  - path: xebialabs/multicloud-pipeline-aws.yaml.tmpl
    writeIf: !expr "Provider == 'EKS'"
    renameTo: xebialabs/multicloud-pipeline.yaml.tmpl