Uploaded image for project: 'OpenShift Service Mesh'
  1. OpenShift Service Mesh
  2. OSSM-8340

[DOC] Add a note for preventing parameter expansion

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • OSSM 3.0-TP1
    • None
    • False
    • None
    • False
    • Documentation (Ref Guide, User Guide, etc.)

      In the chapter Configuring OpenShift Monitoring with Service Mesh, there is

      Apply a PodMonitor object to collect metrics from Istio proxies:
      ```
      apiVersion: monitoring.coreos.com/v1
      kind: PodMonitor
      metadata:
        name: istio-proxies-monitor
        namespace: istio-system 
      spec:
      ...
        podMetricsEndpoints:
      ...
          - action: replace
            regex: (\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})
            replacement: '[$2]:$1'
      ...
      ```
      

      however, the PodMonitor contains a special character $. So when a user copies that text from the documentation and tries to apply that resource via inline command as

      oc apply -f - <<EOF <pod monitor yaml from doc> EOF 

      the bash does parameter expansion, so the final resource contains

      replacement: '[]:'

      instead of

      replacement: '[$2]:$1'

      Unfortunately, structurally it is correct so the resource is created and looks ok, however, it is invalid for Prometheus so there is an error in the Prometheus targets. ( so the metrics are missing and kiali will not shows metrics either)

      When the PodMonitor is created from the file as `oc apply -f podmonitor.yaml`, this isn't happening.
      ===

      Suggestion changes ( 2 options from my POV):

      1. Add a note to PodMonitor object to notify the user that this can happen, e.g.:
      ```
      ...
            replacement: '[$2]:$1 (2)
      ...
            replacement: '$2:$1' (2)
      ...
      ```
      
      
      (2) Note that the PodMonitor resource contains $ special character. Do not forget to prevent parameter expansion in case the PodMonitor is created inline as `oc apply -f - 'EOF' {PodMonitorYaml} EOF
      1. Rephrase step 2. to explicitly say that the resource should be created from the file ( same as in the Gateway chapter ), e.g.:
      2. Create a YAML file named podmonitor.yml that defines the pod monitor.
      ```
      <PodMonitor YAML text>
      ```
      
      3. Apply the YAML file by running the following command: `oc apply -f podmonitor.yml`

              Unassigned Unassigned
              mkralik@redhat.com Matej Kralik
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: