kuberneteskustomizelivenessprobe

how to replace or find correct path for kustomize


I have deployment and I want to replace "path" value in liveness probe section. What is correct path for this in kustomize?

- patch: |-
    - op: replace
      path: ??????????
      value:
        https://xyz.staging.something.eu/ping

    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        test: liveness
      name: liveness-http
    spec:
      containers:
      - name: liveness
        image: k8s.gcr.io/liveness
        args:
        - /server
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 3
          periodSeconds: 3

Solution

  • It is the yaml path. You follow the nodes from the parent down to the leaf-node you want to specify.

    Since you want the path node on httpGet of livenessProbe it will end with livenessProbe.httpGet.path.

    The parent node of livenessProbe is a bit trickier, notice it is an element of the list containers. You can specify it either through an index or through an attribute (EG name). So either containers[0] or containers[name=liveness].

    By now we have containers[0].livenessProbe.httpGet.path. The missing root node is spec, so spec.containers[0].livenessProbe.httpGet.path will do it.

    There is a bunch of other ways that this could be expressed as well. https://github.com/wwkimball/yamlpath#illustration seems like a good more in-depth explanation.