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

Support running with restricted PSA enforcement enabled (part 1) #2572

Merged
merged 14 commits into from
Jul 24, 2023

Commits on Jul 14, 2023

  1. Support restricted PSA enforcement in basic setup

    This enables running Consul in a basic configuration with PSA enforcement
    set to restricted on the namespace where Consul is deployed. (This
    requires deploying the CNI to a different privileged namespace).
    
    On OpenShift, we have the option to set the security context or not. If
    the security context is unset, then it is set automatically by OpenShift
    SCCs. However, we prefer to set the security context to avoid useless
    warnings on OpenShift and to reduce the config difference between
    OpenShift and plain Kube. By default, OpenShift namespaces have the
    audit and warn PSA labels set to restricted, so we receive pod security
    warnings when deploying Consul to OpenShift even though the pods will be
    able to run.
    Paul Glass committed Jul 14, 2023
    Configuration menu
    Copy the full SHA
    45d3af0 View commit details
    Browse the repository at this point in the history
  2. Test: Support TestConnectInject on OpenShift + CNI

    * When `-enable-openshift` and `-enable-cni` are set, configure the CNI
      settings correctly for OpenShift, which must look like:
    
      ```
      connectInject:
        cni:
          enabled: true
          multus: true
          cniBinDir: /var/lib/cni/bin
          cniNetDir: /etc/kubernetes/cni/net.
      ```
    
    * Add `-cni-namespace` flag to support deploying the CNI into a separate
      namespace. This is needed to testing with the CNI when restricted PSA
      enforcement is enabled on the namespace where Consul is deployed
      because the CNI cannot run in a PSA-restricted namespace.
    * Add `-app-namespace` and `-secondary-app-namespace` flags to support
      deploying test applications into a specific namespace. This is needed
      to test with restricted PSA enforcement enabled on the Consul
      namespace because our test applications require a bit more privilege.
    * Update the ConnectHelper to configure the NetworkAttachmentDefinition
      required to be compatible with the CNI on OpenShift.
    * Add fixtures for static-client and static-server for OpenShift. This
      is necessary because the deployment configs must reference the network
      attachment definition when using the CNI on OpenShift.
    * Update tests in the `acceptance/tests/connect` directory to either
      run or skip based on -enable-cni and -enable-openshift (all but two
      cases are skipped for now).
    Paul Glass committed Jul 14, 2023
    Configuration menu
    Copy the full SHA
    cf9715f View commit details
    Browse the repository at this point in the history
  3. fix: Use security context template

    Paul Glass committed Jul 14, 2023
    Configuration menu
    Copy the full SHA
    ff5c24b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9e83262 View commit details
    Browse the repository at this point in the history
  5. fix: Respect user-provided securityContext settings

    Paul Glass committed Jul 14, 2023
    Configuration menu
    Copy the full SHA
    e45cc5a View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2023

  1. Merge remote-tracking branch 'origin/main' into pglass/NET-185/basic-…

    …connect-test
    
    Also (oops I did this as part of the rebase/merge):
    
    - Remove the -app-namespace test flags.
    - Instead, support enabling an app namespace in Connect Helper
      so that tests can choose which namespace to use for applications.
    - Add -restricted-psa-enforcement-enabled flag.
    Paul Glass committed Jul 19, 2023
    Configuration menu
    Copy the full SHA
    0671525 View commit details
    Browse the repository at this point in the history
  2. Remove -cni-namespace flag

    Paul Glass committed Jul 19, 2023
    Configuration menu
    Copy the full SHA
    cbc48f7 View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2023

  1. Update bats tests

    Paul Glass committed Jul 20, 2023
    Configuration menu
    Copy the full SHA
    2790c63 View commit details
    Browse the repository at this point in the history
  2. Add changelog entry

    Paul Glass committed Jul 20, 2023
    Configuration menu
    Copy the full SHA
    7b2e6d3 View commit details
    Browse the repository at this point in the history
  3. Set runAsUser on vanilla kube

    Setting a non-root user is necessary when `runAsNotRoot: true` is
    configured in the securityContext. By setting `runAsUser: 100`, we are
    most compatible with all of the consul, consul-dataplane, and
    consul-k8s-control-plane images which all contain a user id 100.
    
    On OpenShift, this is unnecessary because `runAsUser` is set
    automatically (if it is unset), and by setting it explicitly we would
    require the `anyuid` SCC which would bump the namespace out of the
    `restricted` PSA profile.
    Paul Glass committed Jul 20, 2023
    Configuration menu
    Copy the full SHA
    2b2eefb View commit details
    Browse the repository at this point in the history
  4. Fix acceptance framework unit test

    Paul Glass committed Jul 20, 2023
    Configuration menu
    Copy the full SHA
    d0af4f0 View commit details
    Browse the repository at this point in the history

Commits on Jul 21, 2023

  1. Merge remote-tracking branch 'origin/main' into pglass/NET-185/basic-…

    …connect-test
    Paul Glass committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    fb98d10 View commit details
    Browse the repository at this point in the history
  2. Fix rebase errors

    Paul Glass committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    57c89ab View commit details
    Browse the repository at this point in the history
  3. Rename flag to -enabled-restricted-psa-enforcement

    Paul Glass committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    b8c37fb View commit details
    Browse the repository at this point in the history