0

I am trying to create a dynamic YAML for the Kubernetes workflow step https://docs.rundeck.com/docs/learning/howto/how2kube.html#kubernetes-workflow-steps https://docs.rundeck.com/docs/learning/howto/passing-variables.html

screenshot

when I try to pass the var in the YAML script like ${data.VAR0} (reference Rundeck sharing variables across job steps) it seems the system doesn't get the value.

any clue/other approach to it? thanks in advance

1 Answers1

0

You need to generate the data variable first using some output filter I made an example using the Kubernetes plugin against a cluster.

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 837d506a-0816-4b56-8428-26072487b83a
  loglevel: INFO
  name: KubernetesTest
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - exec: echo "nginx"
      plugins:
        LogFilter:
        - config:
            invalidKeyPattern: \s|\$|\{|\}|\\
            logData: 'true'
            name: mydata
            regex: (.*)
            replaceFilteredResult: 'false'
          type: key-value-data
    - configuration:
        config_file: /Users/user/.kube/config
        debug: 'false'
        namespace: mynamespace
        type: Pod
        verify_ssl: 'false'
        yaml: |-
          apiVersion: v1
          kind: Pod
          metadata:
            name: nginx
          spec:
            containers:
            - name: ${data.mydata}
              image: nginx:latest
              ports:
              - containerPort: 8080
      nodeStep: true
      type: Kubernetes-Create
    keepgoing: false
    strategy: node-first
  uuid: 837d506a-0816-4b56-8428-26072487b83a

Check the first step, it prints the app name and generates the `${data.mydata} in the second step.

Same for options, you can use the ${option.myoption} format in your YAML Kubernetes definition.

MegaDrive68k
  • 3,768
  • 2
  • 9
  • 51
  • Thank you, and for your article too. Unfortunately I have to use another approach the `${data.anyVar}` doesn't accept the multiline and it's impossible to use the component created passing the entire YAML as file. – Marco Carminati Mar 15 '23 at 08:34