github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/examples/variables/jackal.yaml (about)

     1  kind: JackalPackageConfig
     2  metadata:
     3    name: variables
     4    description: Example nginx package to demonstrate Jackal variables
     5  
     6  # Constants are defined on package create and do not change on deploy
     7  # This demonstrates setting the nginx version to bake into the package using a package variable (PKG_TMPL)
     8  # NOTE: package templates (PKG_TMPL) only apply to jackal.yaml files so defining this here turns into ###JACKAL_CONST_NGINX_VERSION### on deploy
     9  # ALSO NOTE: the PKG_TMPL is surrounded by quotes ("") inside of the jackal.yaml, while this is not required for deploy-time variables, PKG_TMPLs will be removed as comments without them
    10  constants:
    11    - name: NGINX_VERSION
    12      value: "###JACKAL_PKG_TMPL_NGINX_VERSION###"
    13      pattern: "^[\\w\\-\\.]+$"
    14  
    15  # Demonstrates injecting custom variables into a K8s resource
    16  variables:
    17    # OPTIONAL_FOOTER injects a configurable footer into the site but has an empty default with no description and will not prompt the user interactively
    18    - name: OPTIONAL_FOOTER
    19      autoIndent: true
    20    # STYLE sets the CSS styles for the site with a default and does not prompt the user for them (note the autoIndent key and that it is multi-line)
    21    - name: STYLE
    22      default: |
    23        body { font-family: sans-serif; color: white; background: #0a0e2e; }
    24        pre { color: white; background: black; }
    25      autoIndent: true
    26    # SITE_NAME sets the name of the site and will ask the user interactively if it is not set on the CLI or in the config file
    27    - name: SITE_NAME
    28      description: The name of the site you are deploying (i.e. Lula Website)
    29      prompt: true
    30      pattern: "^[\\w\\s\\-\\.]+$"
    31    # ORGANIZATION sets the organization to Defense Unicorns as a default but prompts the user if they would like to override it
    32    - name: ORGANIZATION
    33      description: The organization providing the site
    34      default: Defense Unicorns
    35      prompt: true
    36      pattern: "^[\\w\\s\\-\\.]+$"
    37    # AWS_REGION sets the region to set in the modified-terraform file and sets `sensitive` so that it will not be saved in the log
    38    - name: AWS_REGION
    39      default: us-east-1
    40      sensitive: true
    41    # MODIFIED_TERRAFORM sets a filepath for a terraform file to be used as the contents of a template
    42    - name: MODIFIED_TERRAFORM
    43      default: modified-terraform.tf
    44      autoIndent: true
    45      sensitive: true
    46      type: file
    47  
    48  components:
    49    # The following component templates the provided .tf file with the defined AWS_REGION
    50    # NOTE: this component does not actually execute this file in this example
    51    - name: variables-with-terraform
    52      description: Change a value in a regular file with a Jackal variable. Set AWS_REGION variable to modify the file.
    53      required: true
    54      files:
    55        - source: simple-terraform.tf
    56          target: modified-terraform.tf
    57      actions:
    58        onDeploy:
    59          after:
    60            # This command uses Jackal to return the SHASUM of the terraform file (`type: file` variables will return the filepath instead of the contents when used in actions due to constraints on env var size)
    61            - cmd: ./jackal prepare sha256sum ${JACKAL_VAR_MODIFIED_TERRAFORM}
    62              # `mute` is set to exclude the command output from being shown (since we are treating it as sensitive below)
    63              mute: true
    64              setVariables:
    65                - name: MODIFIED_TERRAFORM_SHASUM
    66                  # `sensitive` is set to exclude the command output from the logs
    67                  sensitive: true
    68                  # `pattern` here will ensure that we get a properly formatted sha256 sum back from the jackal prepare command
    69                  pattern: "^[\\da-f]{64}$"
    70  
    71    # The following component deploys nginx to the cluster using the defined variables
    72    - name: variables-with-nginx
    73      description: "This component deploys nginx version ###JACKAL_PKG_TMPL_NGINX_VERSION### to the cluster"
    74      required: true
    75      images:
    76        # This sets the nginx image tag to the same PKG_TMPL used for the constant above to keep the jackal.yaml and nginx-deployment.yaml in sync
    77        - "nginx:###JACKAL_PKG_TMPL_NGINX_VERSION###"
    78      manifests:
    79        - name: variables-with-nginx
    80          files:
    81            - nginx-configmap.yaml
    82            - nginx-deployment.yaml
    83            - nginx-service.yaml
    84      actions:
    85        onDeploy:
    86          after:
    87            - wait:
    88                cluster:
    89                  kind: pod
    90                  namespace: nginx
    91                  name: app=nginx
    92                  condition: Ready