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

multus: add host checking to validation tool #14230

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlaineEXE
Copy link
Member

@BlaineEXE BlaineEXE commented May 16, 2024

In order to help users check that they have implemented the newly-added Multus host configuration prerequisites, add a check to the validation tool to verify connectivity.

Because users who are already running clusters with Multus enabled, add a flag that allows users to only check for host configuration prerequisites. This mode will not start the large number of clients that would normally be started because those clients could disrupt a running Rook cluster negatively.

Host checking pods require host network access. Many Kubernetes
distributions have pod security features enabled. In order to allow
non-Vanilla distros to run this tool, allow specifying a service account
that pods will run as, which can be configured by the admin to allow
test pods.

Manual validation tests:

  • flakiness check still works
  • expect to fail when NAD doesn't have route
  • cleanup cleans up host checkers
  • expect to fail when host doesn't have route
  • expect to succeed when NAD and host routing is correct
  • --host-check-only results in tool stopping after host check succeeds
  • --host-check-only exits with early success when public-net is unset
  • tool enters host check only mode when --host-check-only flag AND/OR config file config is set
  • test on openshift - works, but needs SA+role+binding to allow with SCCs
    • add example resources needed for openshift?
  • update documentation to mention using the validation tool
  • fix KinD-based CI tests

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

@BlaineEXE BlaineEXE force-pushed the multus-validation-test-add-host-checking branch 5 times, most recently from 2b5e387 to 0355394 Compare May 20, 2024 22:49
@BlaineEXE BlaineEXE added this to In progress in v1.14 via automation May 28, 2024
@BlaineEXE BlaineEXE force-pushed the multus-validation-test-add-host-checking branch from f96dbc6 to ea13a6a Compare May 31, 2024 15:36
Copy link

mergify bot commented Jun 4, 2024

This pull request has merge conflicts that must be resolved before it can be merged. @BlaineEXE please rebase it. https://rook.io/docs/rook/latest/Contributing/development-flow/#updating-your-fork

@BlaineEXE BlaineEXE force-pushed the multus-validation-test-add-host-checking branch from 4dc2e85 to 639a122 Compare June 4, 2024 19:32
In order to help users check that they have implemented the newly-added
Multus host configuration prerequisites, add a check to the validation
tool to verify connectivity.

Because users who are already running clusters with Multus enabled, add
a flag that allows users to only check for host configuration
prerequisites. This mode will not start the large number of clients that
would normally be started because those clients could disrupt a running
Rook cluster negatively.

Host checking pods require host network access. Many Kubernetes
distributions have pod security features enabled. In order to allow
non-Vanilla distros to run this tool, allow specifying a service account
that pods will run as, which can be configured by the admin to allow
test pods.

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
@BlaineEXE BlaineEXE force-pushed the multus-validation-test-add-host-checking branch from 639a122 to 8fc06e7 Compare June 7, 2024 22:39
@BlaineEXE
Copy link
Member Author

I was able to get this working on openshift, but I wasn't able to define my own custom SCC. The pod was perpetually saying that it wasn't allowed by any SCC, and the custom SCC was never in the list. @subhamkrai or @Madhu-1 do you remember if you saw this issue when testing other things and how you might've resolved that?

kind: SecurityContextConstraints
apiVersion: security.openshift.io/v1
metadata:
  name: multus-validation-test
# host checker daemonset runs on host network
allowHostNetwork: true
allowedCapabilities: ["NET_BIND_SERVICE"]
runAsUser:
  type: MustRunAsNonRoot
seLinuxContext:
  type: RunAsAny
# disallow everything noncritical
allowPrivilegedContainer: false
allowHostDirVolumePlugin: false
allowHostPID: false
allowHostIPC: false
allowHostPorts: false
readOnlyRootFilesystem: true
users:
  - system:serviceaccount:openshift-storage:multus-validation-test
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: multus-validation-test
  namespace: openshift-storage

In the end, I was able to get this working by instead specifying a Role and RoleBinding that allowed the SA to use an existing SCC (hostnetwork-v2). I think this solution is a safe go-forward strategy, but I'm still curious why my first attempt didn't work.

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: multus-validation-test
  namespace: openshift-storage
rules:
  - apiGroups:
      - security.openshift.io
    resourceNames:
      - hostnetwork-v2
    resources:
      - securitycontextconstraints
    verbs:
      - use
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: multus-validation-test
  namespace: openshift-storage
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: multus-validation-test
subjects:
  - kind: ServiceAccount
    name: multus-validation-test
    namespace: openshift-storage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
v1.14
In progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant