Skip to content

feat: wg-easy add preflights #59

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

nvanthao
Copy link
Member

@nvanthao nvanthao commented May 7, 2025

Add Preflight Checks to WireGuard Easy (wg-easy)

Overview

This PR adds preflight checks to the wg-easy chart.

Implementation Details

  • Each chart-specific preflight is defined as a Kubernetes Secret with label troubleshoot.sh/kind: preflight

  • Preflight specs are stored in each chart's templates directory:

    cert-manager/templates/secret-preflights.yaml
    wg-easy/templates/secret-preflights.yaml
  • Added new task helm-preflight to streamline verification

  • Updated container image to include the preflight binary

Current Status

  • The PR is based on In container only #55 and will be rebased once that PR is merged
  • The cert-manager preflight is currently a placeholder to demonstrate multiple preflight specs merging, not the final preflight content
  • The wg-easy preflight has been implemented with actual checks relevant to the chart

Testing

Locally verify preflight specs with:

helm template <chart-dir> | preflight - --dry-run

Next Steps

  • Finalize cert-manager preflights with actual checks
  • Consider adding preflights to additional charts

Copy link
Member

@chris-sanders chris-sanders left a comment

Choose a reason for hiding this comment

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

I was trying to do a review and then I realized you've based this on another active development branch but targeted the PR against main.

The problem is that means I'm not reviewing both PR's and I can't tell what you've changed and what the other PR is chaning.

If you base a PR on top of another existing branch I think we need to review against that other PR until it's merged so that the review is only of your current changes not everything from both branches.

@@ -48,6 +48,7 @@ Use tools to automate repetitive tasks, reducing human error and increasing deve

- Task-based workflow automation
- Helmfile for orchestration
- Container-based dev environment for consistency
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the phrase "dev environment" because that's not what it actually is and starts to imply you should shell into the container and install dev tools.

Suggested change
- Container-based dev environment for consistency
- Container-based workflow execution for consistency

Copy link
Member

@chris-sanders chris-sanders left a comment

Choose a reason for hiding this comment

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

Just watching the asciinema and again I don't know for sure if this is feedback from your PR or the branch you're building on top of but I'll note what I see either way.

  1. You ran a command 'ag' which I'm guessing is an alias or shortcut you've setup yourself? If so you shouldn't do that in a demo I don't know what that command does, hence I can't understand what you're trying to show us by running it.
  2. You've exposed your REPLICATED_API_TOKEN please rotate it and be more careful in the future about recording sensitive values.
  3. The output here is far to verbose, that's part of the cause of item 2 above, slim it down we shouldn't be showing task commands like you show here. Especially when they have API TOKENS in them. That goes for both the green and the white text, it's noisy look at the Embedded Cluster CLI outputs for a target of what good looks like. I think just disable all of the verbose output would be a good start.
  4. As I mentioned in yesterdays' standup, you shouldn't need cluster-create and setup-kubeconfig in your dependencies. As far as I can tell just setup-kubeconfig is sufficient because it already includes creating a cluster. We need to be careful not to unnecessarily re-run and steps for no reason.
  5. This is the biggest one, you're using a bash loop to make this work which is fine for development purposes however how do you see this working in a real install? An end user won't be using Taskfile or this repository, the preflight needs to work through Enterprise Portal and Embedded Cluster installs. Are you addressing that next? I'm fine with this implementation for developers but before we land anything we need to know what this means for end users.

@nvanthao
Copy link
Member Author

nvanthao commented May 8, 2025

many thanks @chris-sanders

  1. I use ag as a drop-in replacement for grep as it is faster
  2. many thanks I have rotated the token for the demo
  3. I removed -v=5 flag
  4. I removed dep cluster-create
  5. In real install, let me do a quick record of what I am seeing and share the thoughts with us in a Loom

@nvanthao
Copy link
Member Author

nvanthao commented May 8, 2025

This is the biggest one, you're using a bash loop to make this work which is fine for development purposes however how do you see this working in a real install? An end user won't be using Taskfile or this repository, the preflight needs to work through Enterprise Portal and Embedded Cluster installs. Are you addressing that next? I'm fine with this implementation for developers but before we land anything we need to know what this means for end users.

I've shared the Loom in our Slack channel, tldr;

  • for KOTS install in existing cluster, the preflights will run during kots install
  • for EC install, the preflight will happen in KOTS Admin Console UI
  • for helm install, Vendor Portal contains the instructions to run helm template | preflight per chart
  • for helm install, Enterprise Portal is missing preflights run instructions as of now

@nvanthao nvanthao requested a review from chris-sanders May 8, 2025 04:13
Copy link
Member

@chris-sanders chris-sanders left a comment

Choose a reason for hiding this comment

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

I just realized this is still targeting main and not the other PR.
I'm assuming all changes in this PR are yours since you asked for another review, is that accurate?

Comment on lines +1 to +28
apiVersion: v1
kind: Secret
metadata:
name: cert-manager-preflights
labels:
troubleshoot.sh/kind: preflight
type: Opaque
stringData:
preflight.yaml: |
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: cert-manager-preflights
spec:
analyzers:
- distribution:
outcomes:
- pass:
when: "== gke"
message: GKE is a supported platform
- pass:
when: "== k3s"
message: K3S is a supported platform
- fail:
when: "== kind"
message: This application does not support Kind
- warn:
message: The Kubernetes platform is not validated, but there are no known compatibility issues.
Copy link
Member

Choose a reason for hiding this comment

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

Let's not use any 'dummy' values. Cert-manager has a list of prerequisites documented. Use real requirements.

Comment on lines +65 to +70
# Install yq
&& BINARY=yq_linux_amd64 \
&& VERSION=v4.45.1 \
&& curl -Ls https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O \
&& tar xf ${BINARY}.tar.gz && rm ${BINARY}.tar.gz \
&& mv ${BINARY} /usr/local/bin/yq
Copy link
Member

Choose a reason for hiding this comment

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

Why did you move yq out of the package manager and into manual install? Are we using something that's so new it's not in packages yet?

@@ -1,90 +1,111 @@
version: "3"

vars:
Copy link
Member

Choose a reason for hiding this comment

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

There's a lot more changed here than the description says. This isn't just adding the preflight binary, can you explain what all of these container tasks are? They feel unrelated to the task at hand but I might just not understand.

cmds:
- task: check-image-exists
# Start with host networking for kubectl port-forward compatibility
Copy link
Member

Choose a reason for hiding this comment

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

The security implications of this are a bit concerning, although if it's necessary it's not something I would loose sleep over.

Can you explain why kubectl port-forward is needed? Is this running port-forward from within the container, or external to the container? Is there a reason you can't just expose a port rather than use host networking?

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.

3 participants