Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] JSONPath feature #1873

Merged
merged 15 commits into from
Jul 6, 2023
Merged

[FEATURE] JSONPath feature #1873

merged 15 commits into from
Jul 6, 2023

Conversation

cmwylie19
Copy link
Contributor

@cmwylie19 cmwylie19 commented Jul 1, 2023

Description

Based on the condition in src/cmd/tools/wait.go, conditionally decide betweb a jsonpath or conditon waitType.

Related Issue

Fixes #1872

Relates to #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

┌─[cmwylie19@Cases-MacBook-Pro] - [~/zarf] - [2023-07-01 10:26:32]
└─[0] <git:(1872 8bf66067) > kubectl create -f -<<EOF                                                                                                                                                      
apiVersion: apps/v1
kind: StatefulSet
metadata:
  creationTimestamp: null
  labels:
    app: test-sts
  name: test-sts
spec:
  replicas: 23
  selector:
    matchLabels:
      app: test-sts
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: test-sts
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}
EOF
./build/zarf-mac-apple tools wait-for sts test-sts '{.status.availableReplicas}'=23

statefulset.apps/test-sts created
  ✔  Waiting for sts/test-sts to be {.status.availableReplicas}=23.                                                                                                                              
┌─[cmwylie19@Cases-MacBook-Pro] - [~/zarf] - [2023-07-01 10:27:11]
└─[0] <git:(1872 8bf66067) > k get sts 
NAME       READY   AGE
test-sts   23/23   39s

Opens possibility for more complex waits:

# --for=jsonpath='{}'=value
# Wait for the pod "busybox1" to contain the status phase to be "Running".
kubectl wait --for=jsonpath=“{.status.availableReplicas}”=2 sts/test-sts
kubectl wait --for=jsonpath='{.status.phase}'=Running po/busybox1
kubectl wait --for=jsonpath='{.status.containerStatuses[0].ready}'=true po/busybox1
kubectl wait --for=jsonpath='{.spec.containers[0].ports[0].containerPort}'=80 po/busybox1
kubectl wait --for=jsonpath='{.spec.nodeName}'=knode0 po/busybox1

Signed-off-by: Case Wylie <[email protected]>
@netlify
Copy link

netlify bot commented Jul 1, 2023

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 6f9015b
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/64a70326a1ff0d0008264f5d

@cmwylie19 cmwylie19 self-assigned this Jul 1, 2023
src/pkg/utils/misc.go Outdated Show resolved Hide resolved
src/cmd/tools/wait.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Racer159 Racer159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to run make docs-and-schema

src/cmd/tools/wait.go Outdated Show resolved Hide resolved
@cmwylie19 cmwylie19 requested review from mike-winberry, Madeline-UX and a team as code owners July 5, 2023 18:36
Copy link
Contributor

@Racer159 Racer159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!!!

@Racer159 Racer159 merged commit dae4961 into zarf-dev:main Jul 6, 2023
@cmwylie19 cmwylie19 deleted the 1872 branch July 6, 2023 21:38
Racer159 added a commit that referenced this pull request Jul 27, 2023
## Description
Expose Prometheus metrics through /metrics HTTP endpoint.
Add example of how to scrape metrics.

This PR also tests:

- [Named Ports
PR](https://github.com/cmwylie19/zarf/blob/d5a9cf2a9a16d56a0fd6dca72ac6e695f5ae8835/examples/manifests/httpd-service.yaml#L13)
- [Wait-For PR
(jsonPath)](https://github.com/cmwylie19/zarf/blob/d5a9cf2a9a16d56a0fd6dca72ac6e695f5ae8835/examples/manifests/zarf.yaml#L26)
## Related Issue

Fixes #1849
<!-- or -->
Relates to #1693 #1873 
## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed

---------

Signed-off-by: Case Wylie <[email protected]>
Co-authored-by: Wayne Starr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSONPath wait-for condition
2 participants